๐ท๏ธ Coupons โ
Staff can create discount coupons that customers apply at checkout.

๐ซ Coupon Types โ
| Type | Behavior |
|---|---|
PERCENTAGE | ๐ Discount by percentage (e.g., 10% off) |
FIXED | ๐ต Discount by a fixed amount (e.g., $5 off) |
FREE_DELIVERY | ๐ Waive the delivery fee |
๐ Coupon Fields โ
| Field | Description |
|---|---|
code | Unique coupon code (e.g., WELCOME10) |
type | PERCENTAGE, FIXED, or FREE_DELIVERY |
value | Discount amount or percentage |
minOrder | Minimum order subtotal to qualify |
maxDiscount | Cap for percentage discounts |
usageLimit | Maximum total uses (null = unlimited) |
usageCount | Current number of uses |
perCustomer | Maximum uses per customer (default: 1) |
startsAt | Start date (optional) |
expiresAt | Expiration date (optional) |
isActive | Enable/disable the coupon |
โ Validation Rules โ
When a customer applies a coupon, the system checks:
- ๐ Code exists and is active
- ๐
Date range โ current time is between
startsAtandexpiresAt - ๐ข Usage limit โ
usageCount<usageLimit - ๐ค Per-customer limit โ customer hasn't exceeded
perCustomeruses - ๐ฐ Minimum order โ cart subtotal โฅ
minOrder
If validation fails, the API returns a descriptive error message.
๐ Applying at Checkout โ
POST /api/coupons/validate
{
"code": "WELCOME10",
"orderTotal": 25.00
}Returns the discount amount if valid. The coupon is linked to the order when it's created.
๐ Permissions โ
| Action | Who Can Do It |
|---|---|
| โ Validate coupon | Anyone |
| ๐ List coupons | Staff |
| โ๏ธ Create/update coupons | Staff |
| ๐๏ธ Delete coupons | Manager, Super Admin |
๐ก API โ
See Coupons API for the complete endpoint reference.