Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
User experience
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Apr 2012 at 19:55 UTC
Updated:
5 May 2012 at 02:00 UTC
I have created a rule to give a customer a free item when they add a particular item to their cart.
If the user removes that trigger item from the cart, i also want to remove the free item.
Currently, the only rule I can find is the one that empties the entire cart.
How can I target reducing the quantity of just one line item?
Comments
Comment #1
rszrama commentedTo do this through Rules, you'll need a couple of Rules components. Have you used these before? If not, they're basically little subroutines that you can call from other Rules as either condition sets or action sets (or rule sets). In your case, you'd need to check when a product was removed from the cart if the other product existed in the cart and decrement its quantity or delete its line item. This would be done by looping over the order's line items field in an action loop, passing each individual line item to a custom component, and then checking in the component if the line item is the one you want to decrement. You'd probably then need another component that would determine if the line item needed its quantity decremented by 1 (i.e. because it's greater than 1) or another to simply delete the line item (i.e. because its quantity is only 1).
This isn't a trivial configuration, but it's not impossible... you just need a healthy dose of Rules knowledge. I recommend itanglio's Rules Mastery course on YouTube if you want to know more: http://bit.ly/rules-mastery