New Native Gtin Field In Woocommerce

Woocommerce has finally implemented the field for the GTIN code natively. How can I output this for simple and variations in the template?

Also looking for this. Have you found an answer Claudio?

Unfortunately, only single products are still rendered. I haven’t found a solution for the variations yet, but I haven’t looked any further because the customer changed his mind and didn’t want to display the gtin field in frontend.
I have created a future request for this and hope that bricks will then integrate this feature:

I used this:

// Shortcode voor GTIN, UPC, EAN of ISBN
function display_wc_product_gtin() {
global $product;

if (!$product instanceof WC_Product) {
    return '';
}

// Haal GTIN uit het veld _global_unique_id
$gtin = get_post_meta($product->get_id(), '_global_unique_id', true);

return !empty($gtin) ? esc_html($gtin) : '';

}
add_shortcode(‘wc_product_gtin’, ‘display_wc_product_gtin’);

Works good

1 Like