Recommended GTIN plugin does not show GTIN

#53621
  • Resolved Sven Verleyen
    Rank Math free

    Hi,

    We were recommended by Bhanu to install the Product GTIN (EAN, UPC, ISBN) for WooCommerce plugin to add the GTIN to rich snippets. Unfortunately it is not being added to our rich snippets. We are using gtin13 as structured data product as we use the EAN barcode.

    We were told to add this filter to turn EAN into GTIN, which we did but it’s still not working.

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    
    $entity['gtin'] = str_replace('-', '',$entity['ean']);
    
    return $entity;
    });

    Example of product where gtin is filled in but not showing up on rich snippets: https://www.oaksncorks.com/product/dewars-12-year-old-1l/

    Regards,
    Sven

Viewing 9 replies - 1 through 9 (of 9 total)
  • Also we’ve noticed there is a redundancy in the rich snippets.

    This json script is loaded by both WooCommerce and the RankMath plugin:

    <script type="application/ld+json">{"@context":"https:\/\/schema.org\/","@graph":[{"@context":"https:\/\/schema.org\/","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"name":"Home","@id":"https:\/\/www.oaksncorks.com"}}]},{"@context":"https:\/\/schema.org\/","@type":"WebSite","name":"Oaks &amp; Corks","url":"https:\/\/www.oaksncorks.com","potentialAction":{"@type":"SearchAction","target":"https:\/\/www.oaksncorks.com\/?s={search_term_string}&post_type=product","query-input":"required name=search_term_string"}}]}</script>

    We’ve tested with our custom theme and StoreFront, disabling all other plugins.

    Regards,
    Sven

    Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    I’ve checked several products but the EAN value does not seem to be filled as shown below:
    null

    Do you have a particular product link will the global identifier entered that we can test with?

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Hello,

    We were told to add this filter to turn EAN into GTIN, which we did but it’s still not working.

    The $entity array will only have the Product schema values. To use custom value, please use following code to use custom meta value in Product schema:

    
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    
        $entity['gtin'] = get_post_meta( $post_id, '_meta_key', true ); // Change _meta_key & $post_id with EAN metakey and product id.
    
    return $entity;
    });
    

    This json script is loaded by both WooCommerce and the RankMath plugin:

    I don’t see WooCommerce schema on the product page you gave us in your previous reply. Are you seeing it on another page?

    Looking forward to helping you.

    -removed-

    • This reply was modified 3 years, 11 months ago by Sven Verleyen.
    • This reply was modified 3 years, 11 months ago by Sven Verleyen.

    Hi,

    Thanks, but it still doesn’t work properly it seems. It’s showing in the source code, but Google is not picking it. See screenshot: https://prnt.sc/skd8ve

    I’m using the following code:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    	
        $post_id=get_queried_object_id();
        $entity['gtin'] = get_post_meta( $post_id, '_wpm_gtin_code', true );
    	
    return $entity;
    });

    I don’t see WooCommerce schema on the product page you gave us in your previous reply. Are you seeing it on another page?

    The organization/website snippets are shown on the homepage.

    Regards,
    Sven

    • This reply was modified 3 years, 11 months ago by Sven Verleyen.
    • This reply was modified 3 years, 11 months ago by Sven Verleyen.
    • This reply was modified 3 years, 11 months ago by Sven Verleyen.

    Hello,

    Thank you for contacting Rank Math today.

    I’ve modified your code to the following since you have an EAN(13 digit) number:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    	
        $post_id = get_queried_object_id();
        $entity['gtin13'] = get_post_meta( $post_id, '_wpm_gtin_code', true );
    	
    return $entity;
    });

    This seems to do the trick.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Awesome, thanks Michael!

    What about the duplicate website snippet? Woocommerce seems to put one by default, and then rankmath generates one as well, see below.

    https://prnt.sc/sl9607

    Alberto
    Rank Math business

    Hello,

    About that search box in the sitelinks, are you sure it is added by Rank Math? Since it seems both of them are being added by Woocommerce. Anyway, I think it is fine and it won’t cause any problem since it passed the Google test.

    Looking forward to help you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)

The ticket ‘Recommended GTIN plugin does not show GTIN’ is closed to new replies.