nailitstickers
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Organic Google search has misplaced commaHi 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.
Forum: Plugins
In reply to: [WooCommerce] Organic Google search has misplaced commaHi Carol,
Thanks for looking into my issue.
I’ve tried from multiple connexions and not logged in as well :
- From my phone connection
- From my home wifi, not connected to my google account (https://snipboard.io/7AuvoF.jpg)
- I’ve also asked a friend to check on his phone (his connection and his own Google account) and it’s the same (https://snipboard.io/m9paZS.jpg)
Have a nice day !
Forum: Plugins
In reply to: [WooCommerce] Organic Google search has misplaced commaHi Rajesh,
Thank you very much for your response.
I don’t have the same search result even when I type “Stickers pour ongles – Léo” like you did.
https://snipboard.io/BuATmr.jpg
https://snipboard.io/RdoFyN.jpg
I have tried Google Chrome and Mozilla, both has the issue.
I have tried multiples devices including 2 mobile phones and 2 desktop computers.
I have tried to use a VPN to get the search results from a different country (USA) but the results I have remain the same, I think it’s due to my Google account being located in France.
Thank you for your assistance,
Kind regards
- This reply was modified 4 months, 3 weeks ago by nailitstickers.
- This reply was modified 4 months, 3 weeks ago by nailitstickers.