GTIN Field in “General” and “Inventory” Tab in Woocommerce

#632560
  • Resolved Anonymous
    Rank Math free

    Hi there,

    I saw that Rankmath adds another GTIN field in the Inventory tab in Woocommerce, but my warehouse management program only uses the field in general tab.
    Would it be possible to automatically add the GTIN in the inventory tab as well via a snippet for example?

    Best regards,
    Andreas

Viewing 13 replies - 1 through 13 (of 13 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    If you are looking to change this in the Schema markup you can add the following filter on the website to switch to the GTIN already implemented by your warehouse management program:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        $gtin = get_post_meta(get_queried_object_id(), 'custom-field-name', true);
        $entity['gtin'] = $gtin;
        return $entity;
    });

    And here’s a guide on how you can add a filter to your website:
    https://rankmath.com/kb/filters-hooks-api-developer/

    You would need to change the custom field name (if they save the data using a custom field) to match the name where it is saving the data in the database.

    Hope that helps.

    Thank you.

    Anonymous
    Rank Math free

    Hey Reinelle, sorry for the late reply!

    Thank you for the snippet!
    Just to clarify: Will this snippet take the already existing GTIN and add it into the rankmath GTIN field as well?

    Best regards,
    Andreas

    Hello,

    Thank you for your patience.

    Yes, the filter will get the GTIN value from your site, but the code needs to be updated to get that data programatically.

    You can forward that code to the plugin/software you’re using so they can use it to get the data.

    Once done, the GTIN will be added to Rank Math’s product schema.

    Hope that helps.

    Anonymous
    Rank Math free

    I just need to get the GTIN in the rankmath field which is currently empty.
    Only the standard woocommerce field is filled out.
    There is no other software that is being used.
    Will the snippet achieve that goal?

    Hello,

    Since you already have specified a GTIN in your Global Settings, our plugin automatically uses it in our schema structure if the GTIN field in your product’s inventory tab is empty.

    That code will only force you to use the GTIN field in the schema, it will not fill the GTIN field in the product editor page.

    If you wish to update the field, you would need to update the meta key _rank_math_gtin_code, which requires another way of coding.

    Looking forward to helping you.

    Anonymous
    Rank Math free

    Sorry I dont understand, what do you mean with schema?
    Also what do you mean with “force you to use”?

    Hello,

    A schema is a set of rules that tells search engines how to understand and organize information on websites, helping them display relevant search results to users.

    We mostly utilize the GTIN for your website’s schema. The code that my colleague shared is for the product schema.

    It will not actually update the GTIN field on your product but on your schema.

    Don’t hesitate to get in touch with us if you have any other questions.

    Anonymous
    Rank Math free

    Oh ok so the search engine will pick the other gtin field instead?

    Hello,

    Yes, we are essentially bringing the data from the other GTIN field to the Schema markup generated from our plugin with that filter.

    Please note that the filter needs to be modified to include the actual field name where the GTIN is in the database by changing custom-field-name to the field name.

    If you have trouble finding this you can get in touch with your developer to look up the field name in the database.

    Don’t hesitate to get in touch if you have any other questions.

    Anonymous
    Rank Math free

    Ok I think I found the corrrect custom field ‘_gtin’ and edited the script, how can I check if this works?

    Hello,

    You can test this by using the Google Rich Result Test

    Thank you for your patience and cooperation. Looking forward to hearing back from you.

    Anonymous
    Rank Math free

    Did you even read my message? I tested it and there is not gtin value there, the script is not working as of yet

    Hello,

    We apologize for the confusion. Can you please share the full code you added to your site and where you added it to? You can use a site like pastebin.com to share the code with us.

    Thank you for your patience and cooperation. Looking forward to hearing back from 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 13 replies - 1 through 13 (of 13 total)

The ticket ‘GTIN Field in “General” and “Inventory” Tab in Woocommerce’ is closed to new replies.