I am using Magento 2 with the Amasty_Promo
module. And this module allow to add some promo/free gifts in the cart against some cart rules.Test case is like this
If my cart have some free/promo items in the cart and then if i apply the coupon or any wrong coupon code then it remove the previous rules related free items / promo items from the cart. So no free gifts are there.
Can you please help me and let me know why it is happening? Thank you very much
I have found it's reason and it is a very solid reason.
In Magento 2 by default there are four types of rules
So if we see above four rules we will draw a conclusion
The above conclusion make sense if we have only discount based promotion. But if we add new rules or if we add any 3rd party module such as Amasty Promo module. The we also got some options to add a free gifts related rules.
So now in the above scenario where our site will provide discount and free gifts. And in case when customer cart have both discount against coupon based rule and free gift then Magento will only apply the coupon based rules and ignore all other rules.
Solution:
We can achieve our requirement by override the \Magento\SalesRule\Model\Validator
etc/di.xml will be like this
YourPackage\YourModule\Rewrite\SalesRule\Model\Validator.php