Skip to content
Advertisement

Add the ean code (gtin) in the structured data of the product (Schema.org) in WooCommerce

I am using this snippet to display ean value for gtin in Woocommerce’s product schema:

JavaScript

This works but I need to set “identifier_exists” markup to products that don’t have the custom field ean set. How can I modify my snippet to show the ean value in the markup if it exists, and add the identifier_exists attribute = false to products that don’t have an ean?

Advertisement

Answer

Try the following:

JavaScript

Code goes in functions.php file of the active child theme (or active theme).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement