how set priceValidUntil

#37756
  • hi
    my question is for structure data .

    1) how set custom priceValidUntil for all wocommerce products ?
    2) how set custom review for all wocommerce products ? ( ratingValue ‘5’ )
    3) how set custom (e.g. isbn, mpn or gtin8) for all wocommerce products ?
    4) how set custom AggregateRating for all wocommerce products ?

Viewing 6 replies - 1 through 6 (of 6 total)
  • can you help me?

    Hello,

    Thank you for contacting Rank Math today.

    You can use the following snippet in your theme’s functions.php file to add these values:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    	
    	$entity['offers']['priceValidUntil'] = '2025-12-31';
    	$entity['offers']['availability'] = 'http://schema.org/InStock';
    	$entity['aggregateRating']['ratingValue'] = '4.5';
    	$entity['aggregateRating']['reviewCount'] = '';
    	$entity['gtin8'] = '26598751';
    	$entity['review']['reviewRating']['ratingValue'] = '4.5';
    	$entity['review']['reviewRating']['bestRating'] = '5';
    	$entity['review']['author']['name'] = '';
        return $entity;
    });
    

    Looking forward to helping you. Thank you.

    ​​​​​​

    you are the best …

    I add these values, Everything is good but after that it gets error for previous comments.
    I have attached the picture : https://imgur.com/x7x3MMp

    I think we should disable reading comments from Woocommerce
    Thank you for helping

    Hi there,

    Thanks for the follow up.

    Yes this should be disabled if they are causing issues.

    Please share a copy of the final code that you have added so that we can advise further.

    how can disable wocommerce comments (review) for schema ?
    I want to read only the review information schema from the code you provided .

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    	
    	$entity['offers']['priceValidUntil'] = '2020-12-29';
    	$entity['offers']['availability'] = 'http://schema.org/InStock';
    	$entity['aggregateRating']['ratingValue'] = '4.7';
    	$entity['aggregateRating']['reviewCount'] = '19';
    	$entity['gtin8'] = '26598751';
    	$entity['review']['reviewRating']['ratingValue'] = '4.8';
    	$entity['review']['reviewRating']['bestRating'] = '5';
    	$entity['review']['author']['name'] = 'وردپرس یار';
        return $entity;
    });

    Hi there,

    Thanks for the follow up.

    Please note that this code will show the same info for all products and you risk getting removed from the rich snippet program if you disable ratings and comments on your product pages.

    You can disable reviews and rating by heading over to WooCommerce > Settings > Products > General on your site.

    I hope this info helps.

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

The ticket ‘how set priceValidUntil’ is closed to new replies.