Hi Adrian,
Thanks for getting in touch with us.
The code highlighted is correct and I do not see any issue with it.
Which feed file are you talking about? If you share a screenshot or more information, we will be able to help you better.
Hi,
to Google Shopping I have to deliver an Excel, which includes the price of the product. The price in excel is different from the one Google finds on our website because it reads the price of the first variant from the meta tag.
Hello,
Thank you for contacting Rank Math today.
Are you using the same price currency on the product excel sheet? Could you please share a link to the affected product so that we can investigate further?
Looking forward to helping you. Thank you.
​​​​​​
Here is a link to the product:
https://ejedrek.eu/worki-na-smieci-niebieskie-paclan-m-top-35l-240l/?attribute_pojemnosc=80L
The product has an attribute that is a variant. It should have a price of 10.20, in the code it has:
<meta property=”product:price:amount” content=”5.3″>
Hello,
Thank you for contacting Rank Math today.
I have submitted this issue to our dev team and we will be getting back to you in a short while.
Looking forward to helping you. Thank you.
​​​​​​
Hi Adrian,
In your structured data for the above URL, I see this data being printed in the structured data
lowPrice
5.30
highPrice
17.45
This is done after taking the details from your product page’s variations.
If you wish to customize that, you might want to use a filter for the same:
https://rankmath.com/kb/filters-hooks-api-developer/#change-post-schema-data
Where do you want that price to be taken from? Most importantly, have you seen it working like you intend on any other website with any other Schema plugin? We would like to believe that the method we are using for printing the price is correct and per the norms.
Do let us know with the help of an example so we can help you better.
And it’s almost good. However, the schema for a given variant should have only one price value.
Hello,
For Variable product, Rank Math plugin adds the value from the first variant in the product:price:amount
tag. We are still not sure how you are calculating the 10.20 price. Is it the average of all the variable products price?
You can use following filter code to change the price added in the produce:price:amout tag:
add_filter( "rank_math/opengraph/facebook/product_price_amount", function( $content ) {
return 121; // Change it with your price.
});
I hope that helps.
Thank you for the filter. The filter will cause one price for all products. I need such a filter for the variant id. Can you help me with that?
As far as pricing is concerned, the garbage bag has a different capacity, so its price is different.
Or whether there is a filter or a possibility to disable the schema for a given variant
Hello,
The filter will cause one price for all products. I need such a filter for the variant id. Can you help me with that?
The code I provided was a sample code. You will have to change it to modify the price on certain products. You can use the code with product ID to change the price.
Or whether there is a filter or a possibility to disable the schema for a given variant
Yes, please add following filter code in your theme’s functions.php file to remove product:price:amout meta tag:
add_filter( 'rank_math/woocommerce/og_price', '__return_false' );
I hope that helps. Thank you.
Okay, thanks, I’ll try it right away, but I have another question – how to limit the code to products with variants only?
Hello,
Thank you for contacting Rank Math today.
You can use the following code instead for this:
add_filter( 'rank_math/woocommerce/og_price', 'my_custom_og_tags' );
function my_custom_og_tags(){
global $product;
if($product->is_type('variable')){
return false;
}
}
Looking forward to helping you. 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.