-
Hi,
Thanks for creating and supporting a great plugin, it’s quite impressive.I run a comparison site with offers in content egg so I’m trying to have my offers displayed as a type of AggregateOffer – see screenshot attached. So there might be 4 offers for the same product at different companies and I want google to display the range of prices.
I need to display the type, highprice, lowprice, count, and based on your excellent support KB I’ve gotten this far:
add_filter( ‘rank_math/snippet/rich_snippet_product_entity’, function( $entity ) {
$entity[‘gtin13’] = str_replace(‘-‘, ”,$entity[‘sku’]);
$entity[‘offers’][‘@type’] = ‘AggregateOffer’;
$entity[‘offers’][‘lowPrice’] = $entity[‘offers’][‘price’];
$entity[‘offers’][‘highPrice’] = $high_price ;
$entity[‘offers’][‘offerCount’] = $count;
unset($entity[‘offers’][‘price’]);
unset($entity[‘offers’][‘availability’]);… can you let me know :
a) is this the right way to go about this or is there a better way for RankMath to recognise Aggregate Offers?
b) If there’s no alternative, I’ve got some code which works out what the highest price and count of offers, but I need to pass in the product_id – how can I get the product id? I’ve tried setting global $product and using $product->get_id() but it doesn’t seem to like it in the functions.phpThank you very much in advance, I hope this isn’t out of scope of your support.
The ticket ‘AggregateOffers’ is closed to new replies.