Rank Math overriding ItemCondition in product schema

#127599
  • Hello,
    I’ve bought the product condition extension from Woocommerce website because we sell both used and new product, the extension basically set the condition of a product in the schema (new, used, refurbished, damaged) and it also shown on the product page.
    The problem is that rank math overrides the value set in ‘itemCondition’ in the schema, as it always set as ‘NewCondition’.
    Can I prevent rank math from doing it?
    Thanks in advance.

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

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

    With WooCommerce, Rank Math takes the schema data from your product pages automatically and turns it into Schema-ready content. Does the extension update the condition directly into the products?

    Please record a video screencast using a tool like Loom showing how to replicte this and edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
    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/

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

    We really look forward to helping you.

    Hello,

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

    Thank you.

    In the video I modified the same product of the link provided, but as you can see in the screenshot the itemCondition is still set to newCondition but it is should be usedCondition.

    screenshot: https://snipboard.io/MrcVp4.jpg

    Hello,

    Thank you for contacting Rank Math again and sorry for the delay.

    I understand your issue. We want to debug your site but we afraid we can’t edit your code without using FTP. I hope you understand that if we edit your site using WordPress editor and we encounter an error. Your site will go down and the only way to get the site live back again is to use an FTP.

    Can add FTP logins in the designated Sensitive Data section?

    It is completely secure and only our support staff has access to that section.

    We look forward to helping you. Thank you.

    Hello,

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

    Thank you.

    Hello,

    Sorry for the delay.

    Please check the code below. This code will put your product condition into schema itemCondition. Please see the screenshot here – https://i.rankmath.com/sOIAK9

    
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    	global $product;
    	$product_condition = product_condition_return_selected_condition( $product->get_id() );
    	$product_options = product_condition_options();
    	if(is_singular('product') && in_array($product_options[$product_condition], $product_options)) {
    		$entity['offers']['itemCondition'] = $product_options[$product_condition];
    	}
    	return $entity;
    } );
    

    We already put the code on your site and it’s working fine now. Since the plugin is premium we don’t have any choice to test it on your site. You can check it now on your products.

    We hope this helps resolves your issue.

    Yes, it’s working but not as expected, at the moment you copy the value of the condition as it is but that type of value is not in the schema.org specification.
    As you can see in the in the documentation of the plugin ( https://docs.woocommerce.com/document/using-product-condition-for-woocommerce/#section-9 ) there are only 4 acceptable value for itemCondition, and the 20 values that the plugin provide are only used for the product page.
    Just to be clear, here is what the product condiiton should be, taken deactivating rank math: https://snipboard.io/MqV1on.jpg
    Thank you.

    Hello,

    I tweaked the provided code to the following, please check and let us know if it now works as expected:

    
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    	global $product;
    	$product_condition = product_condition_return_selected_condition( $product->get_id() );
    	$product_options = product_condition_options();	
    	$product_schem = product_condition_schema_OfferItemCondition($product_condition);
    	if(is_singular('product') && in_array($product_options[$product_condition], $product_options)) {
    		$entity['offers']['itemCondition'] = $product_schem;
    	}
    	return $entity;
    } );
    

    Hope this helps

    Yes, it’s working as expected.
    Thanks you so much and Happy new Year!

    Hello,

    Glad that helped.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

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

The ticket ‘Rank Math overriding ItemCondition in product schema’ is closed to new replies.