Discount codes, groups, and combination
Discount codes let a buyer explicitly request a cart discount. Groups and ordering control how multiple eligible cart discounts are considered together.
Code lifecycle and limits
A code belongs to a cart discount and can carry total or customer usage constraints exposed by its input. Adding a code to a cart does not guarantee that it produces a reduction: the underlying discount, validity window, predicate, target, and combination rules must also allow it.
At completion Thor validates usage again before recording it. A code accepted earlier can therefore be rejected if another order consumes the remaining allowance. Handle the typed completion error and return the latest cart to the buyer.
Groups and combination
Cart discount groups have ordered members. Stacking mode and apply policy determine whether evaluation keeps one result or combines permitted results. Model mutually exclusive campaigns in the same controlled group and use stable ordering instead of relying on creation time.
An accepted example is an eligible code whose usage remains available and whose discount can combine under its configured group policy. A rejected example is a valid code whose customer limit has already been consumed at order placement. The code string can be syntactically valid while the application is not.
Client behavior
Show the code state and actual discount applications returned by the cart. Do not display a predicted saving before Thor returns it. On removal, re-render every affected line, shipping line, subtotal, tax, and total.