Discount code / coupon
A code shoppers type at checkout to knock money off, plus the rules for who can use it, on what, and until when.
See it
What it is
A discount code is a short string bolted onto a rule. The string is the fun part ('SAVE20'), the rule is the real product: what it takes off (percent, fixed amount, free shipping, buy X get Y), what it applies to (whole order, one collection, one variant), and who may use it (minimum spend, first-time buyers only, one redemption per customer, a total usage cap, a start and end date).
Reach for a code when the offer needs to be targeted or traceable: an influencer's code, a win-back email, an apology to one angry customer. When the offer applies to everyone anyway, use an automatic discount instead, because an empty code box invites shoppers to leave checkout and go hunting.
Gotcha: codes leak. Anything you send to one 'private' list ends up in coupon-scraper browser extensions and voucher sites within days, so a VIP code quietly becomes a permanent site-wide price cut. Set expiry dates and usage caps on every code you generate, not just the risky ones.
Ask AI for it
Build a discount code system for my store. Data model: code string (case-insensitive, unique), type (percentage, fixed amount, free shipping, buy X get Y), value, scope (entire order, specific collections, specific variants), minimum subtotal, eligible-customer rule, total usage cap, per-customer cap, starts-at and ends-at timestamps, and active flag. Add a code field to the cart and checkout summary that validates server-side on apply, shows the exact reason on failure ('expired', 'minimum spend of $50 not met', 'already used'), shows the discount as its own line item on success, and re-validates at order submission so an expired code cannot slip through.