Hello,
Thank you for contacting Rank Math today.
I am not so sure if using URL Parameters will hep your issue. You can however add the following code to your theme functions.php file provide the schema entities for each of the variations. You can use it as it is or change to only assign price for your variations:
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' ) ) {
$entity['gtin13'] = get_post_meta( get_the_ID(), 'hwp_var_gtin', true );
return $entity;
}
$variations = $product->get_available_variations();
if ( ! empty( $variations ) ) {
$entity['offers'] = [];
foreach ( $variations as $variation ) {
$price_valid_until = get_post_meta( $variation['variation_id'], '_sale_price_dates_to', true );
$entity['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(),
'gtin13' => get_post_meta($variation['variation_id'],'hwp_var_gtin', true ),
];
}
}
return $entity;
} );
Hope this helps you. Please let us know if you have any further questions.
Perfect, thanks for this I’ll git it a go
Hi,
We are glad we could help.
Let us know if you need further assistance.
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.