Skip to content

Instantly share code, notes, and snippets.

@NiklasHogefjord
Last active April 19, 2016 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NiklasHogefjord/46ef02e7ac3685d69437 to your computer and use it in GitHub Desktop.
Save NiklasHogefjord/46ef02e7ac3685d69437 to your computer and use it in GitHub Desktop.
Add custom parameters to WooCommerce products exported to Specter
/**
* Filter hook wc_specter_send_custom_product_data
* Add custom parameters to products sent to Specter.
* The product data will be passed to Specter both on single product update (save_post)
* and on manually triggered product exports (from the Specter settings page).
* Contact Specter for detailed information on what parameters their system accepts.
**/
add_filter( 'wc_specter_send_custom_product_data', 'my_custom_product_data', 10, 2 );
function my_custom_product_data( $args, $product ) {
$args['barCode'] = utf8_decode( get_post_meta( $product->id, 'my_custom_meta_field_1', true ) );
$args['buyPrice'] = utf8_decode( get_post_meta( $product->id, 'my_custom_meta_field_2', true ) );
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment