Hello,
Thank you for contacting Rank Math support.
Can you please share a screenshot of the error you’re getting? You can share images with us by uploading them to an image hosting site like Imgur, and then sharing the generated URL with us here.
We are looking forward to hearing back from you.
Please find a screenshot here: https://we.tl/t-Q23KxRS3yL
Woocommerce provide Rich snippets vor Variations with different prices as Aggregate Prices (see screenshot) and only one URL for the product overall. Google Merchant Console does not support Aggregate Prices, which leads to a price mismath error on the page, even if a default variation is set.
Is there any way that RankMath can configure the Rich snippets for each variations to contain a specific price per variation?
I guess the follow-up on that is if RankMath can change the URL structure for variation products as well to contain variation attributes e.g.
https://www.luxmediq.de/product?attribute_count=2
https://www.luxmediq.de/product?attribute_count=5
for 2 variations, where variation 1 has 2 units and variation 2 has 5 units.
Please note I have change the product in the image back to a single product, because I was losing a lot of traffic due to this error..
Hello,
You can use the following filter to add the details of each variation in the Product Schema:
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
if ( ! is_product() ) {
return $entity;
}
$product = wc_get_product( get_the_ID() );
if ( ! $product->is_type( 'variable' ) ) {
return $entity;
}
$variations = $product->get_available_variations();
if ( ! empty( $variations ) ) {
$offers = [];
foreach ( $variations as $variation ) {
$price_valid_until = get_post_meta( $variation['variation_id'], '_sale_price_dates_to', true );
$offers[] = [
'@type' => 'Offer',
'description' => strip_tags( $variation['variation_description'] ),
'price' => $variation['display_price'],
'priceCurrency' => get_woocommerce_currency(),
'availability' => $variation['is_in_stock'] ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',
'itemCondition' => 'NewCondition',
'priceValidUntil' => $price_valid_until ? date_i18n( 'Y-m-d', $price_valid_until ) : '2025-12-31',
'url' => get_permalink($variation['variation_id'])
];
}
}
$entity['offers'] = $offers;
return $entity;
} );
Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
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.