2019-04-09 19:09:09 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Shopify mappings
|
|
|
|
*
|
|
|
|
* @package WooCommerce\Admin\Importers
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add Shopify mappings.
|
|
|
|
*
|
|
|
|
* @since 3.7.0
|
2019-04-15 13:24:56 +00:00
|
|
|
* @param array $mappings Importer columns mappings.
|
|
|
|
* @param array $raw_headers Raw headers from CSV being imported.
|
2019-04-09 19:09:09 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2019-04-15 13:24:56 +00:00
|
|
|
function wc_importer_shopify_mappings( $mappings, $raw_headers ) {
|
|
|
|
// Only map if this is looks like a Shopify export.
|
|
|
|
if ( 0 !== count( array_diff( array( 'Title', 'Body (HTML)', 'Type', 'Variant SKU' ), $raw_headers ) ) ) {
|
|
|
|
return $mappings;
|
|
|
|
}
|
2019-04-09 19:09:09 +00:00
|
|
|
$shopify_mappings = array(
|
2019-04-15 13:26:49 +00:00
|
|
|
'Variant SKU' => 'sku',
|
|
|
|
'Title' => 'name',
|
|
|
|
'Body (HTML)' => 'description',
|
|
|
|
'Quantity' => 'stock_quantity',
|
|
|
|
'Variant Inventory Qty' => 'stock_quantity',
|
|
|
|
'Image Src' => 'images',
|
|
|
|
'Variant Image' => 'images',
|
|
|
|
'Variant SKU' => 'sku',
|
|
|
|
'Variant Price' => 'sale_price',
|
|
|
|
'Variant Compare At Price' => 'regular_price',
|
|
|
|
'Type' => 'category_ids',
|
|
|
|
'Variant Grams' => 'weight',
|
2019-04-09 19:09:09 +00:00
|
|
|
);
|
|
|
|
return array_merge( $mappings, $shopify_mappings );
|
|
|
|
}
|
2019-04-15 13:24:56 +00:00
|
|
|
add_filter( 'woocommerce_csv_product_import_mapping_default_columns', 'wc_importer_shopify_mappings', 10, 2 );
|