Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter nailitstickers

    (@nailitstickers)

    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.

    Thread Starter nailitstickers

    (@nailitstickers)

    Hi Carol,

    Thanks for looking into my issue.

    I’ve tried from multiple connexions and not logged in as well :

    Have a nice day !

    Thread Starter nailitstickers

    (@nailitstickers)

    Hi 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

Viewing 3 replies - 1 through 3 (of 3 total)