Skip to content

Instantly share code, notes, and snippets.

@10h30
Last active May 20, 2019 12:41
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 10h30/50b1f964d77c0df4de2bb3c83acbc013 to your computer and use it in GitHub Desktop.
Save 10h30/50b1f964d77c0df4de2bb3c83acbc013 to your computer and use it in GitHub Desktop.
Woocommerce DYMO Print - Print custom field of variation products
//Tested on ycb.vn
function filter_wc_dymo_product($output,$object,$product,$variation,$labelID) {
if($labelID=='product') {
if(!empty($variation)) {
$barcode = get_post_meta( $variation->get_id(), '_barcode', true );
} else {
$barcode = get_post_meta( $product->get_id(), '_barcode', true );
}
$output[0]['BARCODE'] = $barcode;
}
return $output;
}
// add the filter
add_filter('wc_dymo_product','filter_wc_dymo_product',20,5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment