Hi there,
Thank you for sharing the details and your snippet. I understand that you want to display the GTIN (global_unique_id) for variable products on the shop/product page.
At this time, WooCommerce core does not provide a built-in method to automatically display the global_unique_id for individual variations on the shop or archive pages. The code snippet you shared works for simple products, but for variable products, each variation is treated as a separate product internally, so get_field("_global_unique_id") on the parent variable product will not automatically return the value of the selected variation.
To achieve this, you would need to implement a custom solution that:
- Detects the selected variation on the shop or product page.
- Retrieves the
global_unique_id for that specific variation.
- Outputs it dynamically.
Since this involves custom theme or plugin development, it falls outside the scope of standard WooCommerce support. If you need more in-depth support or want to consider professional assistance for customization, I can recommend WooExperts and Codeable.io as options for getting professional help. Alternatively, you can also ask your development questions in the WooCommerce Community Slack
Thanks for the response (albeit not what I would have preferred).
Hi there,
I completely understand I know this isn’t the answer you were hoping for. I appreciate your patience.
For displaying the GTIN (global_unique_id) on the product page, you may consider creating a ticket in the WooCommerce Community Slack, where developers and the community can often provide custom code snippets to achieve this.
It’s also worth noting that your theme usually controls which information appears on the product details page. You can reach out to your theme’s support team for guidance on how to show the GTIN for variations on the product page they may be able to provide a straightforward solution or custom template adjustment.
I hope this helps point you in the right direction!
Thanks. I have joined the Slack Community. Looks like a busy place.
I had not considered theme developers. I will try there too.
I’ll close this ticket now. Cheers.
Hi @alitchfield,
It is great to see your update, and I am glad we could help point you in the right direction with this. It sounds like you now have a clear next step with the Slack community and your theme developers, which is a solid path forward for this kind of customization.
Since everything is now on track and you have marked this topic as resolved, you are always welcome to return here if anything comes up related to this, or feel free to open a new topic if you need help with something else.
If you have a moment, we would really appreciate it if you could share your experience with WooCommerce here: https://wordpress.org/support/plugin/woocommerce/reviews/#new-post
Thanks again for reaching out and wishing you all the best with your project!