Hello,
Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.
The method we use for the Schema markup is according to Google guidelines for the Product Schema: https://developers.google.com/search/docs/advanced/structured-data/product
However, if you would like to modify that to show each offer and its data individually you can add and modify this filter to your particular needs:
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' => $product->get_permalink(),
'sku' => $variation['sku'],
];
}
}
$entity['offers'] = $offers;
return $entity;
} );
You can change each property according to your needs and remove any properties that you don’t require for the offers.
The filter should be added to your active theme’s functions.php file. Here’s another way to apply the filter using the rankmath.php file:
https://rankmath.com/kb/filters-hooks-api-developer/#adding-filters-and-hooks-in-rank-math-php
Lastly, we also recommend that you read through this guide to learn more about the way Google tries to identify the price and the guidelines that you need to set for your prices on the website: https://support.google.com/merchants/answer/6324371
I hope that helps.
Thank you.
Hello
I added the code to functions.php file. The SKU got generated for individual variations.
Value in Google feed
[Item group ID] = Parent SKU
[Item ID] = Variation SKU
Structured data schema for Product generated by Rank Math
SKU of Parent product
SKU of Individual variation
Value in the feed matches with Structured data generated, so all products got approved.
This means that Rank Math should use the above code by default.
Regards
Salman.
Hello,
I am glad that this resolves your issue.
We are constantly improving our plugin and we appreciate your feedback. We have noted your input and thank you so much for sharing it.
Please do not hesitate to let us know if you need our assistance with anything else.