Adding transitTime and handlingTime

#599378
  • Resolved Saidas Navikas
    Rank Math free

    I’m looking for a way to add those two keys mentioned in the title in my product Schema.
    After adding specific lines to the schema I get critical error while opening any product in WP. Can you guys explain me how can I add transitTime and handlingTime in the right way to my schema?

    Here’s my wrong approach:

    $entity[‘offers’][‘shippingDetails’][‘deliveryTime’][‘transitTime’][‘@type’] = ‘QuantitativeValue’;
    $entity[‘offers’][‘shippingDetails’][‘deliveryTime’][‘transitTime’][‘minValue’] = 0;
    $entity[‘offers’][‘shippingDetails’][‘deliveryTime’][‘transitTime’][‘unitCode’] = ‘DAY’;
    $entity[‘offers’][‘shippingDetails’][‘deliveryTime’][‘handlingTime’][‘@type’] = ‘QuantitativeValue’;
    $entity[‘offers’][‘shippingDetails’][‘deliveryTime’][‘handlingTime’][‘value’] = 1;
    $entity[‘offers’][‘shippingDetails’][‘deliveryTime’][‘handlingTime’][‘unitCode’] = ‘DAY’;

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

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

    It looks like your product schema became corrupted and that’s why you’re getting this critical error. To get around this issue, you may need to get rid of any entry that starts with rank_math_schema_ under the postmeta table in your database for the affected products.

    However, you can try to add the properties to your product schema by using the following filter:

    add_filter("rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
       $entity['offers']['shippingDetails']['@type'] = 'OfferShippingDetails';
       $entity['offers']['shippingDetails']['deliveryTime']['transitTime']['@type'] = 'QuantitativeValue';
       $entity['offers']['shippingDetails']['deliveryTime']['transitTime']['minValue'] = 0;
       $entity['offers']['shippingDetails']['deliveryTime']['transitTime']['unitCode'] = 'DAY';
       $entity['offers']['shippingDetails']['deliveryTime']['handlingTime']['@type'] = 'QuantitativeValue';
       $entity['offers']['shippingDetails']['deliveryTime']['handlingTime']['value'] = 1;
       $entity['offers']['shippingDetails']['deliveryTime']['handlingTime']['unitCode'] = 'DAY';
       return $entity;
    });
    

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how it goes. Looking forward to helping you.

    Thank you.

    Here’s how my code looked before this ticket:

    By the way, I’m having troubles to find at all any entries which starts the way that you said.

    add_filter("rank_math/snippet/rich_snippet_product_entity", function($entity) {		
        // Return policy
        $entity['offers']['hasMerchantReturnPolicy']['@type'] = 'MerchantReturnPolicy';
        $entity['offers']['hasMerchantReturnPolicy']['applicableCountry'] = 'LT';
        $entity['offers']['hasMerchantReturnPolicy']['returnPolicyCategory'] = 'https://devinera.com/pirkimo-taisykles';
    
        // Set the MerchantReturnPolicy properties directly
        $entity['offers']['hasMerchantReturnPolicy']['@type'] = 'MerchantReturnPolicy';
    	$entity['offers']['hasMerchantReturnPolicy']['merchantReturnDays'] = 14;
        $entity['offers']['hasMerchantReturnPolicy']['returnMethod'] = 'https://devinera.com/pirkimo-taisykles/';
        $entity['offers']['hasMerchantReturnPolicy']['returnFees'] = 'https://devinera.com/pirkimo-taisykles/';
    
        // Shipping details
        $entity['offers']['shippingDetails']['@type'] = 'OfferShippingDetails';
        $entity['offers']['shippingDetails']['shippingDestination'] = 'https://devinera.com/pirkimo-taisykles/';
        $entity['offers']['shippingDetails']['shippingRate'] = 'https://devinera.com/pirkimo-taisykles/';
        $entity['offers']['shippingDetails']['deliveryTime'] = 'https://devinera.com/pirkimo-taisykles/';
        $entity['offers']['shippingDetails']['shippingRate']['currency'] = 'EUR';
        $entity['offers']['shippingDetails']['shippingRate']['value'] = 0;
    	
    //     $entity['offers']['shippingDetails']['deliveryTime']['transitTime']['@type'] = 'QuantitativeValue';
    //     $entity['offers']['shippingDetails']['deliveryTime']['transitTime']['minValue'] = 0;
    //     $entity['offers']['shippingDetails']['deliveryTime']['transitTime']['unitCode'] = 'DAY';
    //     $entity['offers']['shippingDetails']['deliveryTime']['handlingTime']['@type'] = 'QuantitativeValue';
    //     $entity['offers']['shippingDetails']['deliveryTime']['handlingTime']['value'] = 1;
    //     $entity['offers']['shippingDetails']['deliveryTime']['handlingTime']['unitCode'] = 'DAY';
    
        return $entity;
    });
    

    Hello,

    Please access your database panel (PhpMyAdmin), open the database table wp_postmeta, and filter only the post_id column.

    Then, check the product ID in the URL while editing it like in this image

    Term

    The post id in the example above would be 27877.

    Once you have the product ID, filter the post_id column to reveal the schema meta from our plugin. You should see a meta_key like this: rank_math_schema_

    Let us know how this goes.

    Thank you.

    I don’t know how it’s possible but there are no records for any of our products which starts with rank_math_schema..

    Hello,

    That means that the Schema markup has not been added to the product pages. Can you please share one example URL that should have the Product Schema in the sensitive data section so we can check?

    Also, if possible include a screenshot of the Schema tab for that product page from our Rank Math SEO Metabox.

    Looking forward to hearing back from you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    I added a sensitive data for you

    Hello,

    It seems that you are sharing an SQL dump file. Can you please share a screenshot of the schema tab in the product page editor instead?

    We checked the product page in the Rich Result test and the product schema was added there without any issues.

    However, I don’t see any traces transitTime and handlingTime. Can you please confirm if you have removed the filter code?

    If you prefer, we can take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    I updated sensitive information and added login details, please check. I’m extending product schema with Code Snippets plugins and at that time when I posted my last reply transitTime and handlingTime was removed because they returned me a critical error to the website.

    Sorry for my late reply. I was on vacation.

    Hello,

    I have changed the code a bit because there are some invalid entries in your snippet and transitTime and handlingTime are now applied to your product: https://search.google.com/test/rich-results/result/r%2Fmerchant-listings?id=zTZdvZ4AzA6hQnuh3DDY2g

    Please follow the documentation here to know more about the valid structure of these properties.

    Hope that helps and please do not hesitate to let us know if you need my assistance with anything else.

    Huge thanks to all of you! You are amazing!

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

You must be logged in to reply to this ticket.