Coupons
Validate coupon
POST /access/api/v1/coupons
Validates one or more coupon codes against the current cart and returns the discount amount.
Request body:
{
"coupons": ["SAVE10"],
"cart": [
{
"productId": "69ac75f878a9512e92b56fb5",
"quantity": 1,
"type": "product",
"variationKey": ""
}
]
}
Response:
{
"status": "success",
"data": {
"_id": "69e89e523ffcea9688dcf375",
"code": "SAVE10",
"amount": 10
}
}
Use amount as the discount value to subtract from the order total.
Possible errors:
| Code | HTTP | What to show |
|---|---|---|
COUPON_CODE_REQUIRED | 400 | Prompt the user to enter a code |
COUPONS_DISABLED | 403 | Hide the coupon input entirely |
INVALID_COUPON | 400 | "This coupon code is not valid or conditions not met" |
COUPON_ZERO_TOTAL | 400 | "Coupons cannot be applied to a zero-total order" |