How to Add shippingDetails and hasMerchantReturnPolicy Fields in Rank Math Schem

#815783
  • Resolved Marek
    Rank Math free

    Hello Rank Math Support Team,

    I hope this message finds you well.

    I am currently using Rank Math on my WordPress site to manage my SEO and structured data. I have encountered a requirement to add two specific fields to my product schema: shippingDetails and hasMerchantReturnPolicy.

    Could you please provide guidance on how to correctly add these fields using Rank Math? Specifically, I need to ensure that the hasMerchantReturnPolicy field includes details such as the return policy category, return days, return method, and return fees. Similarly, I need to include comprehensive shipping details.

    Thank you very much for your assistance!

    Best regards,

    Marek

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

    Thank you for reaching out to us with your query about adding specific fields like shippingDetails and hasMerchantReturnPolicy to your product schema using Rank Math.

    To add these custom fields to your product schema in Rank Math, you can follow these steps:

    1. Shipping Details:

      • Unfortunately, Rank Math does not have a built-in feature to add custom fields like shippingDetails directly. However, you can utilize the "Custom Schema" feature available in Rank Math PRO to add custom JSON-LD code to include shipping details. Here is a guide on how to use the Custom Schema feature: Custom Schema in Rank Math.
    2. hasMerchantReturnPolicy:

      • To include the hasMerchantReturnPolicy field with details such as return policy category, return days, return method, and return fees, you can also use the Custom Schema feature. You will need to craft the JSON-LD code that includes these specific details and then add it using the Custom Schema feature.

    If you need further assistance or detailed guidance on creating the custom JSON-LD code for these fields, please let us know, and we will be happy to help you through the process.

    Best regards,

    Rank Math Support Team

    Sources:
    How to Customize Schema Markup for WooCommerce Products » Rank Math
    Product Schema Type » Rank Math
    How to Use Product Schema for WooCommerce Products » Rank Math

    Hello,

    To add those properties, you can edit the following filter with the appropriate data for these properties so it gets included in the Product Schema as well: https://rankmath.com/kb/filters-hooks-api-developer/#change-post-schema-data

    We have created an example filter that would help add this data and it assumes that the refund policy is only applicable to the USA and that it has a 30-day refund period.

    The shipping rate section also assumes a flat fee of 5$ to ship within the United States.

    This would need to be changed according to the website specifications but it should be a good starting point:

    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
        // Return policy
        $entity['offers']['hasMerchantReturnPolicy']['@type'] = 'MerchantReturnPolicy';
        $entity['offers']['hasMerchantReturnPolicy']['applicableCountry'] = 'US';
        $entity['offers']['hasMerchantReturnPolicy']['returnPolicyCategory'] = 'https://schema.org/MerchantReturnFiniteReturnWindow';
        $entity['offers']['hasMerchantReturnPolicy']['merchantReturnDays'] = 30;
        $entity['offers']['hasMerchantReturnPolicy']['returnMethod'] = 'https://schema.org/ReturnByMail';
        $entity['offers']['hasMerchantReturnPolicy']['returnFees'] = 'https://schema.org/FreeReturn';
    
        // Shipping details
        $entity['offers']['shippingDetails']['@type'] = 'OfferShippingDetails';
        $entity['offers']['shippingDetails']['shippingRate']['@type'] = 'MonetaryAmount';
        $entity['offers']['shippingDetails']['shippingRate']['value'] = 5;
        $entity['offers']['shippingDetails']['shippingRate']['currency'] = 'USD';
        $entity['offers']['shippingDetails']['shippingDestination']['@type'] = 'DefinedRegion';
        $entity['offers']['shippingDetails']['shippingDestination']['addressCountry'] = 'US';
    
        return $entity;
    });

    Here is a guide you can follow to add the filter:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Looking forward to helping you.

    Marek
    Rank Math free

    Thank you 🙂

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on
    https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post

    about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank 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 4 replies - 1 through 4 (of 4 total)

The ticket ‘How to Add shippingDetails and hasMerchantReturnPolicy Fields in Rank Math Schem’ is closed to new replies.