Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Created January 18, 2018 17:03
Show Gist options
  • Save hedqvist/742b97990024259298c6c80ebf44e306 to your computer and use it in GitHub Desktop.
Save hedqvist/742b97990024259298c6c80ebf44e306 to your computer and use it in GitHub Desktop.
Do not sync retailer product (where SKU ends in _1)
<?
function check_sync_woocommerce_product($check, $product_id){
$wc_product = wc_get_product($product_id);
$sku = $wc_product->get_sku();
$sku_chnk = explode('_', $sku);
$to_sync = (int) end($sku_chnk) == 1 ? false : true;
if($to_sync){
return $check;
} else {
add_filter( 'obj_fortnox_sync_product_data_error', function($message, $product_id, $wc_product){
$message['message'] = __('This product is for retailers sales and can not be syncronized.', 'fortnox');
return $message;
}, 20, 3 );
return false;
}
}
add_filter('obj_fortnox_sync_product_data', 'check_sync_woocommerce_product', 10,2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment