If you are using WooCommerce Product Add-Ons (https://woocommerce.com/products/product-add-ons/), you will need any one of the following snippet based on your scenario.

Snippet 1 : 

If you do not want the add-on prices to be considered in the discount rule  AND you want the discount apply only on the main product's price.
You can do it easily using the compatibility plugin.
Install compatibility plugin :

Once installed and activated, you can see the plugin under Woocommerce Section and all the plugins that has compatibility will be listed.

  • All you need to do is click (enable) on the necessary checkbox and click on Save. 
  • That's is all, the discount rules is now compatible for providing discount on the main product's price.

Snippet 2 : 

Use this snippet, if you want the discounts to be applied, both on the base price and add on price.
Click the button below to see the snippet :


Snippet 3:
 

Use the following snippet if you see the prices of add-ons displaying as 0 in the cart page or it does not display at all.

if(!function_exists('woo_discount_rules_has_price_override_method')){
    function woo_discount_rules_has_price_override_method($hprice, $product){
        return true;
    }
}
add_filter('woo_discount_rules_has_price_override', 'woo_discount_rules_has_price_override_method', 10, 2);


How to Add the Code Snippet:

Method 1: Easier (Recommended)

Using the Code Snippet plugin.

Method 2:

Insert in your theme's functions.php file.

Note: 

  • You need to follow any one of the above methods (DO NOT follow Method 2 if you already followed Method 1)

I have more questions

Just leave your question and email by clicking the Live Chat button below or submit your support request to [email protected]

We are always happy to assist you :)

Did this answer your question?