• Resolved Avinash Patel

    (@avinashdigitl)


    Hello, we are using your plugin into our woocommerce store, and we want to reduce each product price by 20% in google shopping listing, is there any hook (action / filter) is available with this plugin?

    Thanks in advance

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support ckadenge (woo-hc)

    (@ckadenge)

    Hi there @avinashdigitl,

    Thanks for reaching out.

    The Google Listings & Ads plugin does not have a specific hook (action / filter) that allows you to reduce product prices by a certain percentage.

    However, you can achieve this by manually adjusting the prices in your WooCommerce product settings or by using coupons and promotions that can apply discounts.

    You can find more information here and here.

    I hope this information is helpful.

    Thread Starter Avinash Patel

    (@avinashdigitl)

    Hello, we have try to search on AI tool, and they have provided this code snippet, i am not sure this will work, can you confirm it?

    function apply_google_shopping_discount($price, $product)
    {
    if (is_google_shopping_feed()) {
    $discount = 0.20; // 20% discount
    $discounted_price = $price * (1 - $discount);
    return $discounted_price;
    }

    return $price;
    }
    add_filter('woocommerce_product_get_price', 'apply_google_shopping_discount', 10, 2);
    add_filter('woocommerce_product_get_regular_price', 'apply_google_shopping_discount', 10, 2);
    add_filter('woocommerce_product_get_sale_price', 'apply_google_shopping_discount', 10, 2);

    function is_google_shopping_feed()
    {
    // Check if the current request is for the Google Shopping feed
    if (isset($_GET['feed']) && $_GET['feed'] == 'google_shopping') {
    return true;
    }
    return false;
    }
    Thread Starter Avinash Patel

    (@avinashdigitl)

    Or can we send price to google shopping without VAT?

    Thread Starter Avinash Patel

    (@avinashdigitl)

    Hi, i have found one code snippet which will reduce product price by 20% and send to Google Shopping, can you confirm will this works? also how much time it will take to affect product price in Google Shopping?

    function custom_discount_price_for_gla($price)
    {
    // Create 20% dicount from product base price
    $discount = $price * .20;

    // Reduce dicount price from product base price
    $return_price = $price - $discount;

    // Return the value
    return $return_price;
    }
    add_filter('woocommerce_gla_product_attribute_value_price', 'custom_discount_price_for_gla');
    • This reply was modified 5 months, 2 weeks ago by Avinash Patel.

    Hi there @avinashdigitl

    The requirements to sync your WooCommerce store with Google and begin showcasing your products online are listed here. Assisting with custom code (AI-generated, or otherwise) is outside the scope of support, I’m afraid.

    Moreover, I’d recommend taking a look at the FAQ section, linked here, and make sure that Google’s guidelines are followed to avoid consequences.

    I trust that points you in the right direction, but if you have more questions, let us know.

    We’re happy to help.

    Thread Starter Avinash Patel

    (@avinashdigitl)

    Hi, thanks for above, but can you just let me know, that will below code snippet allow us to reduce product price by 20%?

    function custom_discount_price_for_gla($price)
    {
    // Create 20% dicount from product base price
    $discount = $price * .20;

    // Reduce dicount price from product base price
    $return_price = $price - $discount;

    // Return the value
    return $return_price;
    }
    add_filter('woocommerce_gla_product_attribute_value_price', 'custom_discount_price_for_gla');
    Plugin Support omarfpg a11n

    (@omarfpg)

    Hi @avinashdigitl,

    The price that is sent to the Google Merchant Center is run through a filter named woocommerce_gla_product_attribute_value_price that you can see in code here: https://github.com/woocommerce/google-listings-and-ads/blob/1.4.2/src/Product/WCProductAdapter.php#L523

    So, you could hook into that and your callback function could return the price – 20%. Something like this might work:?https://gist.github.com/WillBrubaker/d7727179e7c083aed1bb78a63ec4adde (make sure to change this example to 0.8).

    Taken from a similar reply from a while ago here.

    Kindly note that we’re not responsible for third-party code or customization. It’s advised you take a complete backup of your site before trying any custom code.

    Cheers!
    -OP

    Thread Starter Avinash Patel

    (@avinashdigitl)

    Ok, thanks, i am going to place this piece of code in my site. Do you have idea ow much time it will take to change prices in google shopping after placing this code in functions.php?

    function custom_discount_price_for_gla($price)
    {
    // Reduce product price by 20% in google shopping listing //
    return ($price * .8);
    }
    add_filter('woocommerce_gla_product_attribute_value_price', 'custom_discount_price_for_gla');
    Plugin Support ckadenge (woo-hc)

    (@ckadenge)

    Hi @avinashdigitl,

    Thank you for reaching out to WooCommerce.com support.

    Once you’ve placed the code in your functions.php file, it typically takes around 1-2days for the changes to reflect on Google Shopping. However, this can vary. It’s best to monitor the changes over a few days.

    Please don’t hesitate to reach out if you have any other questions or concerns.

    Thread Starter Avinash Patel

    (@avinashdigitl)

    Ok, thanks for your support, you can close this ticket now.

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.