Coupons combined the way a checkout would
The engine tries only the combinations the coupons themselves allow — one on the product and one on delivery at most, and together only when both say they stack — and keeps whichever leaves the least to pay. Each one's validity window, minimum spend, ceiling and payment method are honoured, and a discount the shop has already applied is kept apart from the coupon so nothing comes off twice. Adding up every code that exists produces a total nobody can pay.

Let's talk