Skip to main content

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

PropertyTypeDescription
idstring (UUID)Unique identifier of the coupon in the database.
namestringInternal name of the promotion (e.g., "Welcome Discount").
targetstringDefines the scope of application (e.g., global, category, shipping).
codestringThe text code the user must enter (e.g., SUMMER2026).
positionnumberPriority order in case of multiple discounts.
discountTypestringCalculation type: percentage or fixed.
discountValuenumberThe value of the discount (e.g., 20 for 20% or 10 for $10).
limitUsageGlobalbooleanIf true, enables the maximum limit of total uses for the coupon.
limitUsageCustomerbooleanIf true, limits the number of times a single customer can use it.
maxUsesGlobalnumberMaximum number of total uses allowed in the system.
maxUsesPerCustomernumberMaximum number of uses allowed per single authenticated user.
minOrderAmountnumberMinimum spend threshold (gross total) required to activate the code.
exclusivebooleanIf true, the coupon cannot be combined with other promotional codes.
reservedbooleanIf true, the coupon is reserved for specific user segments or emails.
startsAtstring (ISO 8601)Start date and time of the promotion's validity.
endsAtstring (ISO 8601)Expiration date and time (the code will stop working after this date).
createdAtstring (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.