Coupon & Codes
The Coupon object defines the promotional discount rules within webround.com. This data is used by the validation engine to determine if a code entered by the user can be applied to the current cart based on temporal, usage, or minimum value restrictions.
Coupon Definition
| Property | Type | Description |
|---|---|---|
| id | string (UUID) | Unique identifier of the coupon in the database. |
| name | string | Internal name of the promotion (e.g., "Welcome Discount"). |
| target | string | Defines the scope of application (e.g., global, category, shipping). |
| code | string | The text code the user must enter (e.g., SUMMER2026). |
| position | number | Priority order in case of multiple discounts. |
| discountType | string | Calculation type: percentage or fixed. |
| discountValue | number | The value of the discount (e.g., 20 for 20% or 10 for $10). |
| limitUsageGlobal | boolean | If true, enables the maximum limit of total uses for the coupon. |
| limitUsageCustomer | boolean | If true, limits the number of times a single customer can use it. |
| maxUsesGlobal | number | Maximum number of total uses allowed in the system. |
| maxUsesPerCustomer | number | Maximum number of uses allowed per single authenticated user. |
| minOrderAmount | number | Minimum spend threshold (gross total) required to activate the code. |
| exclusive | boolean | If true, the coupon cannot be combined with other promotional codes. |
| reserved | boolean | If true, the coupon is reserved for specific user segments or emails. |
| startsAt | string (ISO 8601) | Start date and time of the promotion's validity. |
| endsAt | string (ISO 8601) | Expiration date and time (the code will stop working after this date). |
| createdAt | string (ISO 8601) | Record creation date. |
Object Example
{
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"name": "Summer Promo",
"code": "SUMMER25",
"discountType": "percentage",
"discountValue": 15,
"minOrderAmount": 50,
"exclusive": true,
"limitUsageCustomer": true,
"maxUsesPerCustomer": 1,
"startsAt": "2026-06-01T00:00:00.000Z",
"endsAt": "2026-08-31T23:59:59.000Z"
}
Validation Logic
When the validatePromotionCodes method is invoked via the wr.customer Utilities, the system compares the cart parameters with the minOrderAmount, startsAt, endsAt properties and the usage limits defined in this structure. If any of these criteria are not met, the code is rejected with a localized error message.