Hi, thank you for this post, as it helped me create what I needed.
However, I have a small problem, I have created an automatic "BUY X GET Y" coupon that gives a product worth € 9.95 upon reaching € 39.90.
At first check everything seems to work correctly but some customers have already found a small bug (I don't know if it is a bug) and have already exploited it.
In practice, if in the cart I reach the total of € 39.90 the system "correctly" inserts the FREE PRODUCT (price € 9.95) in the cart and applies the coupon of the same value, that is € 9.95.
The problem arises if a product costing no more than € 9 is removed from the cart. The system continues to apply the discount coupon of € 9.95, I believe, counting the free product that has been inserted into the total amount.
I hope I have made you understand what the problem is.
Products in the cart:
PRODUCT A (price € 35)
PRODUCT B (price € 10)
The system adds:
FREE PRODUCT (price € 9.95)
FREE COUPON - € 9.95
Then I delete PRODUCT B from the cart
This is the final situation of my cart:
PRODUCT A (price € 35)
FREE PRODUCT (price € 9.95)
FREE COUPON - € 9.95
So in the end the customer only entered a € 35 product but received a free product.
I apologize for the long post but I wanted to make sure I explain the problem well.
Regards.