Missing field "priceValidUntil"

#13313
  • Resolved Mark
    free

    I have the Missing field “priceValidUntil” problem. You advised other users to fill in the “Sale price dates” data on each individual page in the general settings. I have 6000+ products so this is not viable for me. I add 100-250 new products every week via an import tool that doesn’t bring in this data.

    Zero items in my store are on sale (the field above “Sale price ($)” is blank on every product) so I should not be needing to fill in this data at all. It seems to be a Rank Math issue because Yoast never displayed this error in the past.

    There should be something in the RM code thats says if “Sale price ($)” is blank then set end date to 01/01/2050 or something, or ideally ignore it entirely. IF this isn’t possible please explain how to access a global setting for this field, rather than per individual item.

    Thanks!

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

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

    As a workaround, you can add the following PHP code to your theme’s functions.php file to set a specific date for the sale price:

    /**
     * Filter to modify Rank Math product schema data
     * Replace $schema_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
    	$entity['offers']['priceValidUntil'] = '2050-01-01';
    	
    	return $entity;
    });

    Alternatively, you can also use the below code to remove the offers schema if you do not have any offers on your products:

    /**
     * Filter to modify Rank Math product schema data
     * Replace $schema_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
    	//remove offer data from the product schema
    	unset($entity['offers']);
    	return $entity;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Fantastic. I added the 2nd box of code you sent.

    Is there anything I can do to remove the similar “review” & “aggregate rating” error? I don’t want to clog up my site with reviews and I have too many products that currently are overwritten semi-regularly due to imports which means reviews are often wiped with them and therefore serve little purpose.

    Hi Mark,

    Thanks for the follow up.

    This is not recommended practice since Google expects this data to be available in your product snippet.
    Rank Math takes the schema data from your product pages automatically and turns it into Schema-ready content. Likewise, the aggregateRating and review fields are taken from your actual product reviews that your buyers/customers leave on your products.
    http://i.mythemeshop.com/cIBqH4
    If you would however wish to go down this path, you can add the following code to your theme’s functions.php file:

    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
    	//remove reiew & aggregateRating data from the product schema
    	unset($entity['review']);
    	unset($entity['aggregateRating']);
    	return $entity;
    });

    I hope this info helps. 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 3 replies - 1 through 3 (of 3 total)

The ticket ‘Missing field "priceValidUntil"’ is closed to new replies.