# Class Coupon

- [TopLevel.Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)
  - [dw.object.PersistentObject](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.PersistentObject.md)
    - [dw.campaign.Coupon](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md)

Represents a coupon in Commerce Cloud Digital.

## Constant Summary

| Constant                                                                                                                                           | Description                                         |
| -------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| [TYPE_MULTIPLE_CODES](#type_multiple_codes): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "MULTIPLE_CODES" | Constant representing coupon type *multiple-codes*. |
| [TYPE_SINGLE_CODE](#type_single_code): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "SINGLE_CODE"          | Constant representing coupon type *single-code*.    |
| [TYPE_SYSTEM_CODES](#type_system_codes): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "SYSTEM_CODES"       | Constant representing coupon type *system-codes*.   |

## Property Summary

| Property                                                                                                                                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [ID](#id): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`                                                   | Returns the ID of the coupon.                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [codePrefix](#codeprefix): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`                                   | Returns the prefix defined for coupons of type [TYPE_SYSTEM_CODES](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_system_codes)  If no prefix is defined, or coupon is of type [TYPE_SINGLE_CODE](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_single_code)  or [TYPE_MULTIPLE_CODES](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_multiple_codes), null is returned. |
| [enabled](#enabled): [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md) `(read-only)`                                       | Returns true if coupon is enabled, else false.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [nextCouponCode](#nextcouponcode): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`                           | Returns the next unissued code of this coupon.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [promotions](#promotions): [Collection](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md) `(read-only)`                            | Returns the coupon-based promotions directly or indirectly (through  campaigns) assigned to this coupon.                                                                                                                                                                                                                                                                                                                                                                        |
| [redemptionLimitPerCode](#redemptionlimitpercode): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`           | Returns the defined limit on redemption per coupon code.                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [redemptionLimitPerCustomer](#redemptionlimitpercustomer): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`   | Returns the defined limit on redemption of this coupon per customer.                                                                                                                                                                                                                                                                                                                                                                                                            |
| [redemptionLimitPerTimeFrame](#redemptionlimitpertimeframe): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)` | Returns the defined limit on redemption per customer per time-frame (see  [getRedemptionLimitTimeFrame()](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getredemptionlimittimeframe).                                                                                                                                                                                                                                                             |
| [redemptionLimitTimeFrame](#redemptionlimittimeframe): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`       | Returns the time-frame (in days) of the defined limit on redemption per  customer per time-frame.                                                                                                                                                                                                                                                                                                                                                                               |
| [type](#type): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`                                               | Returns the coupon type.                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

## Constructor Summary

This class does not have a constructor, so you cannot create it directly.

## Method Summary

| Method                                                                                                                                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [getCodePrefix](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getcodeprefix)()                                   | Returns the prefix defined for coupons of type [TYPE_SYSTEM_CODES](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_system_codes)  If no prefix is defined, or coupon is of type [TYPE_SINGLE_CODE](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_single_code)  or [TYPE_MULTIPLE_CODES](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_multiple_codes), null is returned. |
| [getID](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getid)()                                                   | Returns the ID of the coupon.                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [getNextCouponCode](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getnextcouponcode)()                           | Returns the next unissued code of this coupon.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [getPromotions](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getpromotions)()                                   | Returns the coupon-based promotions directly or indirectly (through  campaigns) assigned to this coupon.                                                                                                                                                                                                                                                                                                                                                                        |
| [getRedemptionLimitPerCode](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getredemptionlimitpercode)()           | Returns the defined limit on redemption per coupon code.                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [getRedemptionLimitPerCustomer](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getredemptionlimitpercustomer)()   | Returns the defined limit on redemption of this coupon per customer.                                                                                                                                                                                                                                                                                                                                                                                                            |
| [getRedemptionLimitPerTimeFrame](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getredemptionlimitpertimeframe)() | Returns the defined limit on redemption per customer per time-frame (see  [getRedemptionLimitTimeFrame()](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getredemptionlimittimeframe).                                                                                                                                                                                                                                                             |
| [getRedemptionLimitTimeFrame](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getredemptionlimittimeframe)()       | Returns the time-frame (in days) of the defined limit on redemption per  customer per time-frame.                                                                                                                                                                                                                                                                                                                                                                               |
| [getType](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#gettype)()                                               | Returns the coupon type.                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [isEnabled](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#isenabled)()                                           | Returns true if coupon is enabled, else false.                                                                                                                                                                                                                                                                                                                                                                                                                                  |

### Methods inherited from class PersistentObject

[getCreationDate](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.PersistentObject.md#getcreationdate), [getLastModified](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.PersistentObject.md#getlastmodified), [getUUID](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.PersistentObject.md#getuuid)

### Methods inherited from class Object

[assign](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#assignobject-object), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject-object), [defineProperties](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertiesobject-object), [defineProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertyobject-object-object), [entries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#entriesobject), [freeze](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#freezeobject), [fromEntries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#fromentriesiterable), [getOwnPropertyDescriptor](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertydescriptorobject-object), [getOwnPropertyNames](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertynamesobject), [getOwnPropertySymbols](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertysymbolsobject), [getPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getprototypeofobject), [hasOwnProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#hasownpropertystring), [is](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isobject-object), [isExtensible](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isextensibleobject), [isFrozen](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isfrozenobject), [isPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isprototypeofobject), [isSealed](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#issealedobject), [keys](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#keysobject), [preventExtensions](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#preventextensionsobject), [propertyIsEnumerable](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#propertyisenumerablestring), [seal](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#sealobject), [setPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#setprototypeofobject-object), [toLocaleString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tolocalestring), [toString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tostring), [valueOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valueof), [values](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valuesobject)

## Constant Details

### TYPE_MULTIPLE_CODES

- TYPE_MULTIPLE_CODES: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "MULTIPLE_CODES"
  - : Constant representing coupon type *multiple-codes*.

***

### TYPE_SINGLE_CODE

- TYPE_SINGLE_CODE: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "SINGLE_CODE"
  - : Constant representing coupon type *single-code*.

***

### TYPE_SYSTEM_CODES

- TYPE_SYSTEM_CODES: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "SYSTEM_CODES"
  - : Constant representing coupon type *system-codes*.

***

## Property Details

### ID

- ID: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Returns the ID of the coupon.

***

### codePrefix

- codePrefix: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Returns the prefix defined for coupons of type [TYPE_SYSTEM_CODES](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_system_codes)
    If no prefix is defined, or coupon is of type [TYPE_SINGLE_CODE](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_single_code)
    or [TYPE_MULTIPLE_CODES](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_multiple_codes), null is returned.

***

### enabled

- enabled: [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md) `(read-only)`
  - : Returns true if coupon is enabled, else false.

***

### nextCouponCode

- nextCouponCode: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Returns the next unissued code of this coupon.
    For single-code coupons, the single fixed coupon code is returned.
    For all multi-code coupons, the next available, unissued coupon code is returned.
    If all codes of the coupon have been issued, then there is no next code, and null is returned.

    A transaction is required when calling this method. This needs to be ensured by the calling script.

***

### promotions

- promotions: [Collection](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md) `(read-only)`
  - : Returns the coupon-based promotions directly or indirectly (through
    campaigns) assigned to this coupon.

***

### redemptionLimitPerCode

- redemptionLimitPerCode: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`
  - : Returns the defined limit on redemption per coupon code. Null is
    returned if no limit is defined, which means that each code can be
    redeemed an unlimited number of times.

***

### redemptionLimitPerCustomer

- redemptionLimitPerCustomer: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`
  - : Returns the defined limit on redemption of this coupon per customer.
    Null is returned if no limit is defined, which means that customers can
    redeem this coupon an unlimited number of times.

***

### redemptionLimitPerTimeFrame

- redemptionLimitPerTimeFrame: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`
  - : Returns the defined limit on redemption per customer per time-frame (see
    [getRedemptionLimitTimeFrame()](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getredemptionlimittimeframe). Null is returned if no limit is
    defined, which means that there is no time-specific redemption limit for
    customers.

    **See Also:**

    - [getRedemptionLimitTimeFrame()](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getredemptionlimittimeframe)

***

### redemptionLimitTimeFrame

- redemptionLimitTimeFrame: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`
  - : Returns the time-frame (in days) of the defined limit on redemption per
    customer per time-frame. Null is returned if no limit is defined, which
    means that there is no time-specific redemption limit for customers.

    **See Also:**

    - [getRedemptionLimitPerTimeFrame()](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getredemptionlimitpertimeframe)

***

### type

- type: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Returns the coupon type.
    Possible values are [TYPE_SINGLE_CODE](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_single_code), [TYPE_MULTIPLE_CODES](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_multiple_codes)
    and [TYPE_SYSTEM_CODES](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_system_codes).

***

## Method Details

### getCodePrefix()

- getCodePrefix(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Returns the prefix defined for coupons of type [TYPE_SYSTEM_CODES](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_system_codes)
    If no prefix is defined, or coupon is of type [TYPE_SINGLE_CODE](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_single_code)
    or [TYPE_MULTIPLE_CODES](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_multiple_codes), null is returned.

    **Returns:**

    - Coupon code prefix or null

***

### getID()

- getID(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Returns the ID of the coupon.

    **Returns:**

    - Coupon ID

***

### getNextCouponCode()

- getNextCouponCode(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Returns the next unissued code of this coupon.
    For single-code coupons, the single fixed coupon code is returned.
    For all multi-code coupons, the next available, unissued coupon code is returned.
    If all codes of the coupon have been issued, then there is no next code, and null is returned.

    A transaction is required when calling this method. This needs to be ensured by the calling script.

    **Returns:**

    - Next available code of this coupon, or null if there are no available codes.

***

### getPromotions()

- getPromotions(): [Collection](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md)
  - : Returns the coupon-based promotions directly or indirectly (through
    campaigns) assigned to this coupon.

    **Returns:**

    - Promotions assigned to the coupon in no particular order.

***

### getRedemptionLimitPerCode()

- getRedemptionLimitPerCode(): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md)
  - : Returns the defined limit on redemption per coupon code. Null is
    returned if no limit is defined, which means that each code can be
    redeemed an unlimited number of times.

    **Returns:**

    - The maximum number of redemption per coupon code

***

### getRedemptionLimitPerCustomer()

- getRedemptionLimitPerCustomer(): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md)
  - : Returns the defined limit on redemption of this coupon per customer.
    Null is returned if no limit is defined, which means that customers can
    redeem this coupon an unlimited number of times.

    **Returns:**

    - The maximum number of redemption per customer

***

### getRedemptionLimitPerTimeFrame()

- getRedemptionLimitPerTimeFrame(): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md)
  - : Returns the defined limit on redemption per customer per time-frame (see
    [getRedemptionLimitTimeFrame()](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getredemptionlimittimeframe). Null is returned if no limit is
    defined, which means that there is no time-specific redemption limit for
    customers.

    **Returns:**

    - The maximum number of redemption per customer within time-frame

    **See Also:**

    - [getRedemptionLimitTimeFrame()](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getredemptionlimittimeframe)

***

### getRedemptionLimitTimeFrame()

- getRedemptionLimitTimeFrame(): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md)
  - : Returns the time-frame (in days) of the defined limit on redemption per
    customer per time-frame. Null is returned if no limit is defined, which
    means that there is no time-specific redemption limit for customers.

    **Returns:**

    - Timeframe (days) of redemption per time

    **See Also:**

    - [getRedemptionLimitPerTimeFrame()](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#getredemptionlimitpertimeframe)

***

### getType()

- getType(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Returns the coupon type.
    Possible values are [TYPE_SINGLE_CODE](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_single_code), [TYPE_MULTIPLE_CODES](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_multiple_codes)
    and [TYPE_SYSTEM_CODES](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.campaign.Coupon.md#type_system_codes).

    **Returns:**

    - Coupon type

***

### isEnabled()

- isEnabled(): [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md)
  - : Returns true if coupon is enabled, else false.

    **Returns:**

    - true if coupon is enabled.

***
