Last active
May 20, 2019 12:41
-
-
Save 10h30/50b1f964d77c0df4de2bb3c83acbc013 to your computer and use it in GitHub Desktop.
Woocommerce DYMO Print - Print custom field of variation products
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
//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