Last active
April 19, 2017 14:59
-
-
Save EricBusch/a9e7c909d792493c3b3a689720e8caeb to your computer and use it in GitHub Desktop.
This code is for using the Comparison Sets plugin on products not imported by the WooCommerce Importer plugin. It will use the SKU value as the EAN value so that Comparison Sets can be generated from EAN values as well as the product name for products added to WooCommerce manually. [datafeedr][dfrcs]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add "sku" value as "ean" to $source. | |
* | |
* @param array $source | |
* @param WC_Product $product | |
* | |
* @return array Updated $source array. | |
*/ | |
add_filter( 'dfrcs_wc_source', 'mycode_add_ean_to_source', 20, 2 ); | |
function mycode_add_ean_to_source( $source, $product ) { | |
if ( isset( $source['id'] ) ) { | |
return $source; | |
} | |
$ean = $product->get_sku(); | |
$source['ean'] = $ean; | |
return $source; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment