How to implement and apply Buy X And Get Y another product of same category free in the shopping cart price rules in magento.

  • I have tried to implement it by adding own code but that was not correct by logic somewhat then I have tried to add an extension from the website link but that too has limitation that we have to manually everytime add the rule for each product on whom we want to apply this offer.we can not directly apply the rule for the whole category in one attempt. Commented Mar 4, 2014 at 5:30
  • for assigning category follow, shaileshprajapati.com/magento/buy-x-get-y-free-magento
    – Helphin
    Commented Mar 4, 2014 at 12:17
  • i implemented according to the last post for applying the rule on whole category but it does not work if i buy 1(X product) product of same category and another 1 product of same category(y product) .so help me regarding this problem..... Commented Mar 5, 2014 at 5:17
  • Any body looking for Magento 2.1 solution plz chk it here magento.stackexchange.com/questions/209030/…
    – Ishak Ali
    Commented Jan 24, 2018 at 9:01
  • Anbody looking for Magento 2 please check answer here magento.stackexchange.com/questions/209030/…
    – Ishak Ali
    Commented Dec 19, 2018 at 7:26

3 Answers 3


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:

  1. add a new field to be able to set "X" condition
  2. listen for salesrule_validator_process event and check if the current item is X
  3. if it is X then loop through $address->getAllItems() and find Y, set discount
  • 1
    We tried the Special Promotions Pro from Amasty and it really works well for our needs and for this kind of instances. Thank you for the suggestion.
    – Ner
    Commented Nov 20, 2017 at 12:49

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.

  • Thank you for your answer. I used a similar approach to yours and applied 33.33% off when buying 2 or more items, this makes the third item free. Commented Jun 25, 2021 at 19:56
  • One year later, I'm visiting the same thread looking for the same answer. The issue is that having 33.33% is it gets applied for items over the discount quantity. Commented Mar 5, 2022 at 21:59

Does default Magento not support buy x and get y different size discounted?

  • So far based on my understanding, it appears to NOT support such discount. Commented Mar 5, 2022 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.