Product Schema Product Variable Woocommerce Price missing but not

#43483
Viewing 5 replies - 1 through 5 (of 5 total)
  • Todd
    Rank Math free

    Hi Pol,

    Thanks for getting in touch with us.

    You are getting that error for the offer field.

    It looks like you have added an offer but haven’t added the price yet. Please add that to get rid of the issue.

    Here’s a screenshot for reference:
    null

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

    Hi, thank you for your quick answer, there isn’t any offers on those products highlighted by google console. All the products highlighted are variable.

    I’ve done a bit more of investigation, and it looks like:

    – I’ve added “$entity[‘offers’][‘priceValidUntil’] = ‘2050-01-01’;” to get rid of that warning.
    – This works fine for simple products where there is only 1 offer.
    – In variable products it sets the ‘priceValidUntil’ for the ‘offers’ instead to each individual ‘offer’.
    – I’ve temporarily added a check if the product is simple to add that ‘priveValidUntil’ (function below)
    – I’ve looked at your schema generating code and you create an array for all the variations but I didn’t seem to be able to access it with $entity[‘offers’][‘offer][‘priceValidUntil’], would you be able to help here?

    Kindest Regards

    Pol

    add_filter( ‘rank_math/frontend/robots’, ‘rank_math_robots_adjustment’ , 90 );
    // Product Schema fix warnings
    add_filter( “rank_math/snippet/rich_snippet_product_entity”, function( $entity ) {
    global $product;
    if ( $product->is_type( ‘simple’ ) ) {
    $entity[‘offers’][‘priceValidUntil’] = ‘2050-01-01’;
    }
    $entity[‘sku’] = $entity[‘name’];
    $entity[‘mpn’] = “The GPBox ” . $entity[‘name’] . $entity[‘brand’];
    return $entity;
    });

    Hello,

    Thank you for contacting Rank Math today.

    Could you please test the following snippet for variable products:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    	global $product;
    	if ( $product->is_type( 'variable' ) ) {
    		$variations = $product->get_available_variations();
    		foreach ( $variations as $key => $variation ) {
    			$entity['offers'][ $key ]['priceValidUntil'] = '2050-01-01';
    		}
    	} else {
    		$entity['offers']['priceValidUntil'] = '2050-01-01';
    	}
    
    	return $entity;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

    Sorted! thanks a lot!

    Todd
    Rank Math free

    Hello Pol,

    We are so glad to be of help. We are always here if you need us in the future.

    Hey, if it isn’t too much to ask for – would you mind leaving us a review here?

    https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post

    It only takes a couple of minutes but helps us tremendously.

    It would mean so much to us.

    Thank you.

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

The ticket ‘Product Schema Product Variable Woocommerce Price missing but not’ is closed to new replies.