Tags/topics: 
1
Answers
Vote up!
1
Vote down!

How to apply discount in cart

Hi everyone I hope you could assist me with my discount problem. Here is the scenario/conditions:

I need to apply a $20 discount on a product type (X), only when product type (Y) is also in the cart. The $20 discount is applied only once on every instance of product X in the cart. For example:

product                    price   quantity      total

Product X- large           50           3            130
Product Y                  10           1             10
Product X- small           50           1           30

Thanks in advance.

Asked by: drupalNuB
on December 13, 2013

1 Answer

Vote up!
0
Vote down!

Unfortunately, discounts like this are hard to produce in Rules (the recommended way to do it).

1) What I would recommend is use the commerce_discount module which provides an "order level" discount type.

2) Then I would create a function in a custom module that looks at the cart contents and returns a number for the discount. Possibly another that provides a true/false if the discount should apply.

3) Finally, I would use rules to apply the order level discount based on your custom true/false condition and applies the amount of discount provided by your custom calculation function.

Josh Miller
Answer by: Josh Miller
Posted: Dec 18, 2013