/var/www/html_de/wp-content/plugins/woocommerce/includes/admin/importers/mappings/shopify.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
 * Shopify mappings
 *
 * @package WooCommerce\Admin\Importers
 */

if ( ! defined'ABSPATH' ) ) {
    exit;
}

/**
 * Add Shopify mappings.
 *
 * @since 3.7.0
 * @param array $mappings    Importer columns mappings.
 * @param array $raw_headers Raw headers from CSV being imported.
 * @return array
 */
function wc_importer_shopify_mappings$mappings$raw_headers ) {
    
// Only map if this is looks like a Shopify export.
    
if ( !== countarray_diff( array( 'Title''Body (HTML)''Type''Variant SKU' ), $raw_headers ) ) ) {
        return 
$mappings;
    }
    
$shopify_mappings = array(
        
'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',
        
'Tags'                      => 'tag_ids_spaces',
        
'Variant Grams'             => 'weight',
        
'Variant Requires Shipping' => 'meta:shopify_requires_shipping',
        
'Variant Taxable'           => 'tax_status',
    );
    return 
array_merge$mappings$shopify_mappings );
}
add_filter'woocommerce_csv_product_import_mapping_default_columns''wc_importer_shopify_mappings'10);

/**
 * Add special wildcard Shopify mappings.
 *
 * @since 3.7.0
 * @param array $mappings    Importer columns mappings.
 * @param array $raw_headers Raw headers from CSV being imported.
 * @return array
 */
function wc_importer_shopify_special_mappings$mappings$raw_headers ) {
    
// Only map if this is looks like a Shopify export.
    
if ( !== countarray_diff( array( 'Title''Body (HTML)''Type''Variant SKU' ), $raw_headers ) ) ) {
        return 
$mappings;
    }
    
$shopify_mappings = array(
        
'Option%d Name'  => 'attributes:name',
        
'Option%d Value' => 'attributes:value',
    );
    return 
array_merge$mappings$shopify_mappings );
}
add_filter'woocommerce_csv_product_import_mapping_special_columns''wc_importer_shopify_special_mappings'10);

/**
 * Expand special Shopify columns to WC format.
 *
 * @since 3.7.0
 * @param  array $data Array of data.
 * @return array Expanded data.
 */
function wc_importer_shopify_expand_data$data ) {
    if ( isset( 
$data['meta:shopify_requires_shipping'] ) ) {
        
$requires_shipping wc_string_to_bool$data['meta:shopify_requires_shipping'] );

        if ( ! 
$requires_shipping ) {
            if ( isset( 
$data['type'] ) ) {
                
$data['type'][] = 'virtual';
            } else {
                
$data['type'] = array( 'virtual' );
            }
        }

        unset( 
$data['meta:shopify_requires_shipping'] );
    }
    return 
$data;
}
add_filter'woocommerce_product_importer_pre_expand_data''wc_importer_shopify_expand_data' );