Hello,
I would like to know this too. I’ve tried:
// WooCommerce UPC under product title
add_action( 'woocommerce_single_product_summary', 'dev_designs_show_upc', 10 );
function dev_designs_show_upc(){
global $product;
echo 'UPC: ' . $product->wpm_gtin();
}
“wpm_gtin” isn’t the right one for sure, so, what to put here? Is it supported?
I’m on no way a programmer, just modding the theme for my website.
Thank you,
Ronald
Hi,
there’s the shortcode
[wpm_product_gtin]
You can find how to use it inside a FAQ here:
https://ww.wp.xz.cn/plugins/product-gtin-ean-upc-isbn-for-woocommerce
so you can show it simply with a
<?php echo do_shortcode('[wpm_product_gtin id="123"]'); ?>
Or it is possible get the meta for example inside the @ronald-van-arkel function:
add_action( 'woocommerce_single_product_summary', 'dev_designs_show_upc', 10 );
function dev_designs_show_upc(){
global $product;
echo 'UPC: ' . $product->get_meta( '_wpm_gtin_code' );
}
Hello Emanuela,
Thank you for the help. I didn’t know the meta “name” so to say, could not be found in the FAQ (sure looked trough it and also on the forum here).
This is my final code with with classes added to it:
// WooCommerce SKU and UPC under product title
add_action( 'woocommerce_single_product_summary', 'dev_designs_show_sku', 10 );
function dev_designs_show_sku(){
global $product;
echo '<div class="sku_under_title">SKU:' . $product->get_sku() . '</div>';
}
add_action( 'woocommerce_single_product_summary', 'dev_designs_show_upc', 10 );
function dev_designs_show_upc(){
global $product;
echo '<div class="upc_under_title">UPC:' . $product->get_meta( '_wpm_gtin_code' ) . '</div>';
}
Again, thank you so much for your help!
You are welcome!
I’ll add the custom meta name inside the FAQ!