How to implement and apply Buy X And Get Y another product of same category free in the shopping cart price rules in magento.
There is no "Buy X get Y" rule for different X and Y in the Magento default package. The rule we have can only discount some qty of the SAME products. Like if we get 10 t-shirts we can receive 11-th for free. But there is NO WAY to receive a belt instead of t-shirt.
The options are either create a custom module or select some ready to use from the magento connect.
If you want to create your own, here some tips based on "Special Promotions" plugin:
- add a new field to be able to set "X" condition
- listen for
salesrule_validator_processevent and check if the current item is X
- if it is X then loop through $address->getAllItems() and find Y, set discount
I was able to simulate the desired behaviour by doing this: (For buy 3 of product X, get 1 product Y free)
Conditions: - Total quantity of SKU X is greater or equal to 3
Actions: - Apply: Discount (percentage of product price) - Percentage = 100 - Maximum Qty Discount is Applied To: 1 - Apply rule to has condition: SKU = Y
This would work for buy 2 X, get Y free
Unfortunately it does not work for 6 items, get 2 free. That could be done by an extra rule though with a higher prio that checks for 6 / 2
Edit: This does not work when you have variants of SKU Y. If customer buys 3 X and 2 variants of Y, he gets both of Y for free.
To remedy the last problem, I changed the rule to give a fixed amount (product Y price) on the whole shopping cart. That worked OK for us.