Hi Rajesh,
It seems that I have just happened to resolve the issue.
It is half Google and half Woocommerce bug. Here is the explanation and how to fix it, if someone else faces that issue too.
Google seems to get the price from the tag <script type=”application/ld+json”> built by Woocommerce. The problem is that instead of sending “price” : “5.9”, Wocommerce was sending “5.9000” and that was confusing Google.
I have added a script to my functions.php child’s theme to remove the extra ‘0’ from the Json.
add_filter(‘woocommerce_structured_data_product’, ‘modify_woocommerce_structured_data_product’, 10, 2);
function modify_woocommerce_structured_data_product($markup, $product) {
if (isset($markup[‘offers’][0][‘price’])) {
$markup[‘offers’][0][‘price’] = format_price($markup[‘offers’][0][‘price’]);
}
if (isset($markup['offers'][0]['priceSpecification']['price'])) {
$markup['offers'][0]['priceSpecification']['price'] = format_price($markup['offers'][0]['priceSpecification']['price']);
}
return $markup;
}
function format_price($price) {
$price = (float)$price; // Convert to float to remove trailing zeros
return rtrim(rtrim(number_format($price, 2, ‘.’, ”), ‘0’), ‘.’);
}
I hope that helps,
Have a good day.