Class Promotion
This class represents a promotion in Commerce Cloud Digital. Examples of promotions include:
- "Get 20% off your order"
- "$15 off a given product"
- "free shipping for all orders over $50"
- Get a bonus product with purchase of another product
The Promotion class provides access to the basic attributes of the promotion such as name, callout message, and description, but the details of the promotion rules are not available in the API due to their complexity.
Commerce Cloud Digital allows merchants to create a single logical "promotion rule" (e.g. "Get 20% off your order") and then assign it to one or more "containers" where the supported container types are campaigns or AB-tests. A Promotion represents a specific instance of a promotion rule assigned to a container. Promotion rules themselves that are not assigned to any container are inaccessible through the API. Each instance (i.e. assignment) can have separate "qualifiers". Qualifiers are the customer groups, source code groups, or coupons that trigger a given promotion for a customer.
| Constant | Description |
|---|---|
| EXCLUSIVITY_CLASS: String = "CLASS" | Constant representing promotion exclusivity of type class. |
| EXCLUSIVITY_GLOBAL: String = "GLOBAL" | Constant representing promotion exclusivity of type global. |
| EXCLUSIVITY_NO: String = "NO" | Constant representing promotion exclusivity of type no. |
| PROMOTION_CLASS_ORDER: String = "ORDER" | Constant representing promotion class of type order. |
| PROMOTION_CLASS_PRODUCT: String = "PRODUCT" | Constant representing promotion class of type product. |
| PROMOTION_CLASS_SHIPPING: String = "SHIPPING" | Constant representing promotion class of type shipping. |
| QUALIFIER_MATCH_MODE_ALL: String = "all" | Constant indicating that that all qualifier conditions must be met in order for this promotion to apply for a given customer. |
| QUALIFIER_MATCH_MODE_ANY: String = "any" | Constant indicating that that at least one qualifier condition must be met in order for this promotion to apply for a given customer. |
| Property | Description |
|---|---|
ID: String (read-only) | Returns the unique ID of the promotion. |
active: Boolean (read-only) | Returns 'true' if promotion is active, otherwise 'false'. |
(read-only) | Returns 'true' if the promotion is triggered by a coupon, false otherwise. |
basedOnCoupons: Boolean (read-only) | Returns 'true' if the promotion is triggered by coupons, false otherwise. |
basedOnCustomerGroups: Boolean (read-only) | Returns 'true' if the promotion is triggered by customer groups, false otherwise. |
basedOnSourceCodes: Boolean (read-only) | Returns 'true' if the promotion is triggered by source codes, false otherwise. |
calloutMsg: MarkupText (read-only) | Returns the callout message of the promotion. |
campaign: Campaign (read-only) | Returns the campaign this particular instance of the promotion is defined in. |
combinablePromotions: String[] (read-only) | Returns the promotion's combinable promotions. |
(read-only) | Returns a description of the condition that must be met for this promotion to be applicable. |
coupons: Collection (read-only) | Returns the coupons directly assigned to the promotion or assigned to the campaign of the promotion. |
custom: CustomAttributes (read-only) | Returns the custom attributes for this extensible object. |
customerGroups: Collection (read-only) | Returns the customer groups directly assigned to the promotion or assigned to the campaign of the promotion. |
(read-only) | Returns the description of the promotion. |
details: MarkupText (read-only) | Returns the detailed description of the promotion. |
enabled: Boolean (read-only) | Returns true if promotion is enabled, otherwise false. |
endDate: Date (read-only) | Returns the effective end date of this instance of the promotion. |
exclusivity: String (read-only) | Returns the promotion's exclusivity specifying how the promotion can be combined with other promotions. |
image: MediaFile (read-only) | Returns the reference to the promotion image. |
lastModified: Date (read-only) | Returns the date that this object was last modified. |
mutuallyExclusivePromotions: String[] (read-only) | Returns the promotion's mutually exclusive Promotions. |
name: String (read-only) | Returns the name of the promotion. |
promotionClass: String (read-only) | Returns the promotion class indicating the general type of the promotion. |
qualifierMatchMode: String (read-only) | Returns the qualifier matching mode specified by this promotion. |
rank: Number (read-only) | Returns the promotion's rank. |
refinable: Boolean (read-only) | Returns true if promotion is refinable, otherwise false. |
sourceCodeGroups: Collection (read-only) | Returns the source code groups directly assigned to the promotion or assigned to the campaign of the promotion. |
startDate: Date (read-only) | Returns the effective start date of this instance of the promotion. |
tags: String[] (read-only) | Returns the promotion's tags. |
This class does not have a constructor, so you cannot create it directly.
| Method | Description |
|---|---|
| getCalloutMsg() | Returns the callout message of the promotion. |
| getCampaign() | Returns the campaign this particular instance of the promotion is defined in. |
| getCombinablePromotions() | Returns the promotion's combinable promotions. |
| Returns a description of the condition that must be met for this promotion to be applicable. | |
| getCoupons() | Returns the coupons directly assigned to the promotion or assigned to the campaign of the promotion. |
| getCustom() | Returns the custom attributes for this extensible object. |
| getCustomerGroups() | Returns the customer groups directly assigned to the promotion or assigned to the campaign of the promotion. |
| Returns the description of the promotion. | |
| getDetails() | Returns the detailed description of the promotion. |
| getEndDate() | Returns the effective end date of this instance of the promotion. |
| getExclusivity() | Returns the promotion's exclusivity specifying how the promotion can be combined with other promotions. |
| getID() | Returns the unique ID of the promotion. |
| getImage() | Returns the reference to the promotion image. |
| getLastModified() | Returns the date that this object was last modified. |
| getMutuallyExclusivePromotions() | Returns the promotion's mutually exclusive Promotions. |
| getName() | Returns the name of the promotion. |
| getPromotionClass() | Returns the promotion class indicating the general type of the promotion. |
| getPromotionalPrice(Product) | Returns the promotional price for the specified product. |
| getPromotionalPrice(Product, ProductOptionModel) | This method follows the same logic as getPromotionalPrice(Product) but prices are calculated based on the option values selected in the specified option model. |
| getQualifierMatchMode() | Returns the qualifier matching mode specified by this promotion. |
| getRank() | Returns the promotion's rank. |
| getSourceCodeGroups() | Returns the source code groups directly assigned to the promotion or assigned to the campaign of the promotion. |
| getStartDate() | Returns the effective start date of this instance of the promotion. |
| getTags() | Returns the promotion's tags. |
| isActive() | Returns 'true' if promotion is active, otherwise 'false'. |
| Returns 'true' if the promotion is triggered by a coupon, false otherwise. | |
| isBasedOnCoupons() | Returns 'true' if the promotion is triggered by coupons, false otherwise. |
| isBasedOnCustomerGroups() | Returns 'true' if the promotion is triggered by customer groups, false otherwise. |
| isBasedOnSourceCodes() | Returns 'true' if the promotion is triggered by source codes, false otherwise. |
| isEnabled() | Returns true if promotion is enabled, otherwise false. |
| isRefinable() | Returns true if promotion is refinable, otherwise false. |
getCreationDate, getLastModified, getUUID
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
- EXCLUSIVITY_CLASS: String = "CLASS"
Constant representing promotion exclusivity of type class.
- EXCLUSIVITY_GLOBAL: String = "GLOBAL"
Constant representing promotion exclusivity of type global.
- EXCLUSIVITY_NO: String = "NO"
Constant representing promotion exclusivity of type no.
- PROMOTION_CLASS_ORDER: String = "ORDER"
Constant representing promotion class of type order.
- PROMOTION_CLASS_PRODUCT: String = "PRODUCT"
Constant representing promotion class of type product.
- PROMOTION_CLASS_SHIPPING: String = "SHIPPING"
Constant representing promotion class of type shipping.
- QUALIFIER_MATCH_MODE_ALL: String = "all"
Constant indicating that that all qualifier conditions must be met in order for this promotion to apply for a given customer.
- QUALIFIER_MATCH_MODE_ANY: String = "any"
Constant indicating that that at least one qualifier condition must be met in order for this promotion to apply for a given customer.
- ID: String
(read-only) Returns the unique ID of the promotion.
- active: Boolean
(read-only) Returns 'true' if promotion is active, otherwise 'false'.
A promotion is active if its campaign is active, and the promotion is enabled, and it is scheduled for now.
basedOnCoupon: Boolean(read-only)Returns 'true' if the promotion is triggered by a coupon, false otherwise.
Deprecated:
- basedOnCoupons: Boolean
(read-only) Returns 'true' if the promotion is triggered by coupons, false otherwise.
- basedOnCustomerGroups: Boolean
(read-only) Returns 'true' if the promotion is triggered by customer groups, false otherwise.
- basedOnSourceCodes: Boolean
(read-only) Returns 'true' if the promotion is triggered by source codes, false otherwise.
- calloutMsg: MarkupText
(read-only) Returns the callout message of the promotion.
- campaign: Campaign
(read-only) Returns the campaign this particular instance of the promotion is defined in.
Note: If this promotion is defined as part of an AB-test, then a Campaign object will be returned, but it is a mock implementation, and not a true Campaign. This behavior is required for backwards compatibility and should not be relied upon as it may change in future releases.
- combinablePromotions: String[]
(read-only) Returns the promotion's combinable promotions. Combinable promotions is a set of promotions or groups this promotion can be combined with.
conditionalDescription: MarkupText(read-only)Returns a description of the condition that must be met for this promotion to be applicable.
The method and the related attribute have been deprecated. Use the getDetails() method instead.
Deprecated:
Use getDetails()
- coupons: Collection
(read-only) Returns the coupons directly assigned to the promotion or assigned to the campaign of the promotion.
If the promotion is not based on coupons (see isBasedOnCoupons()), or no coupons is assigned to the promotion or its campaign, an empty collection is returned.
- custom: CustomAttributes
(read-only) Returns the custom attributes for this extensible object.
- customerGroups: Collection
(read-only) Returns the customer groups directly assigned to the promotion or assigned to the campaign of the promotion.
If the promotion is not based on customer groups (see isBasedOnCustomerGroups()), or no customer group is assigned to the promotion or its campaign, an empty collection is returned.
description: MarkupText(read-only)Returns the description of the promotion.
Method is deprecated and returns the same value as getCalloutMsg().
Deprecated:
Use getCalloutMsg()
- details: MarkupText
(read-only) Returns the detailed description of the promotion.
- enabled: Boolean
(read-only) Returns true if promotion is enabled, otherwise false.
- endDate: Date
(read-only) Returns the effective end date of this instance of the promotion. If no explicit end date is defined for the promotion, the end date of the containing Campaign or AB-test is returned.
- exclusivity: String
(read-only) Returns the promotion's exclusivity specifying how the promotion can be combined with other promotions. Possible values are EXCLUSIVITY_NO, EXCLUSIVITY_CLASS and EXCLUSIVITY_GLOBAL.
- image: MediaFile
(read-only) Returns the reference to the promotion image.
- lastModified: Date
(read-only) Returns the date that this object was last modified.
- mutuallyExclusivePromotions: String[]
(read-only) Returns the promotion's mutually exclusive Promotions. Mutually exclusive Promotions is a set of promotions or groups this promotion cannot be combined with.
- name: String
(read-only) Returns the name of the promotion.
- promotionClass: String
(read-only) Returns the promotion class indicating the general type of the promotion. Possible values are PROMOTION_CLASS_PRODUCT, PROMOTION_CLASS_ORDER, and PROMOTION_CLASS_SHIPPING.
- qualifierMatchMode: String
(read-only) Returns the qualifier matching mode specified by this promotion. A promotion may have up to 3 qualifier conditions based on whether it is customer-group based, coupon based, and/or source-code based. A promotion may require for example that a customer belong to a certain customer group and also have a certain coupon in the cart in order for the promotion to apply. This method returns QUALIFIER_MATCH_MODE_ALL if it is necessary that all the qualifier conditions are satisfied in order for this promotion to apply for a given customer. Otherwise, this method returns QUALIFIER_MATCH_MODE_ANY indicating that at least of the qualifier conditions must be satisfied.
Note: currently QUALIFIER_MATCH_MODE_ALL is only supported for promotions assigned to campaigns, and not those assigned to AB-tests.
- rank: Number
(read-only) Returns the promotion's rank. Rank is a numeric attribute that you can specify. Promotions with a defined rank are calculated before promotions without a defined rank. If two promotions have a rank, the one with the lowest rank is calculated first. For example, a promotion with rank 10 is calculated before one with rank 30.
- refinable: Boolean
(read-only) Returns true if promotion is refinable, otherwise false.
- sourceCodeGroups: Collection
(read-only) Returns the source code groups directly assigned to the promotion or assigned to the campaign of the promotion.
If the promotion is not based on source code groups (see isBasedOnSourceCodes()), or no source code group is assigned to the promotion or its campaign, an empty collection is returned.
- startDate: Date
(read-only) Returns the effective start date of this instance of the promotion. If no explicit start date is defined for this instance, the start date of the containing Campaign or AB-test is returned.
- tags: String[]
(read-only) Returns the promotion's tags. Tags are a way of categorizing and organizing promotions. A promotion can have many tags. Tags will be returned in alphabetical order.
- getCalloutMsg(): MarkupText
Returns the callout message of the promotion.
Returns:
- Callout message of the promotion.
- getCampaign(): Campaign
Returns the campaign this particular instance of the promotion is defined in.
Note: If this promotion is defined as part of an AB-test, then a Campaign object will be returned, but it is a mock implementation, and not a true Campaign. This behavior is required for backwards compatibility and should not be relied upon as it may change in future releases.
Returns:
- Campaign of the promotion.
- getCombinablePromotions(): String[]
Returns the promotion's combinable promotions. Combinable promotions is a set of promotions or groups this promotion can be combined with.
Returns:
- The promotion's set of combinable promotions.
getConditionalDescription(): MarkupTextReturns a description of the condition that must be met for this promotion to be applicable.
The method and the related attribute have been deprecated. Use the getDetails() method instead.
Returns:
- Condition promotion description.
Deprecated:
Use getDetails()
- getCoupons(): Collection
Returns the coupons directly assigned to the promotion or assigned to the campaign of the promotion.
If the promotion is not based on coupons (see isBasedOnCoupons()), or no coupons is assigned to the promotion or its campaign, an empty collection is returned.
Returns:
- Coupons assigned to promotion in no particular order.
- getCustom(): CustomAttributes
Returns the custom attributes for this extensible object.
- getCustomerGroups(): Collection
Returns the customer groups directly assigned to the promotion or assigned to the campaign of the promotion.
If the promotion is not based on customer groups (see isBasedOnCustomerGroups()), or no customer group is assigned to the promotion or its campaign, an empty collection is returned.
Returns:
- Customer groups assigned to promotion in no particular order.
getDescription(): MarkupTextReturns the description of the promotion.
Method is deprecated and returns the same value as getCalloutMsg().
Returns:
- Description of the promotion.
Deprecated:
Use getCalloutMsg()
- getDetails(): MarkupText
Returns the detailed description of the promotion.
Returns:
- Detailed promotion description.
- getEndDate(): Date
Returns the effective end date of this instance of the promotion. If no explicit end date is defined for the promotion, the end date of the containing Campaign or AB-test is returned.
Returns:
- End date of the promotion, or null if no end date is defined.
- getExclusivity(): String
Returns the promotion's exclusivity specifying how the promotion can be combined with other promotions. Possible values are EXCLUSIVITY_NO, EXCLUSIVITY_CLASS and EXCLUSIVITY_GLOBAL.
Returns:
- Promotion exclusivity
- getID(): String
Returns the unique ID of the promotion.
Returns:
- ID of the promotion.
- getImage(): MediaFile
Returns the reference to the promotion image.
Returns:
- Image of the promotion.
- getLastModified(): Date
Returns the date that this object was last modified.
Returns:
- the date that this object was last modified.
- getMutuallyExclusivePromotions(): String[]
Returns the promotion's mutually exclusive Promotions. Mutually exclusive Promotions is a set of promotions or groups this promotion cannot be combined with.
Returns:
- The promotion's set of mutually exclusive Promotions.
- getName(): String
Returns the name of the promotion.
Returns:
- Name of the promotion.
- getPromotionClass(): String
Returns the promotion class indicating the general type of the promotion. Possible values are PROMOTION_CLASS_PRODUCT, PROMOTION_CLASS_ORDER, and PROMOTION_CLASS_SHIPPING.
Returns:
- Promotion class or null if the promotion rule has not been configured.
- getPromotionalPrice(product: Product): Money
Returns the promotional price for the specified product. The promotional price is only returned if the following conditions are met:
- this promotion is a product promotion without purchase conditions, i.e. is of type 'Without qualifying products'.
- this promotion's discount is Discount.TYPE_AMOUNT, Discount.TYPE_PERCENTAGE, Discount.TYPE_FIXED_PRICE, or Discount.TYPE_PRICEBOOK_PRICE.
- specified product is one of the discounted products of the promotion.
- the product has a valid sales price for quantity 1.0.
In all other cases, the method will return Money.NOT_AVAILABLE. It is not required that this promotion be an active customer promotion.
NOTE: the method might be extended in the future to support more promotion types.
To calculate the promotional price, the method uses the current sales price of the product for quantity 1.0, and applies the discount associated with the promotion to this price. For example, if the product price is $14.99, and the promotion discount is 10%, the method will return $13.49. If the discount is $2 off, the method will return $12.99. If the discount is $10.00 fixed price, the method will return $10.00.
Parameters:
- product - the product to calculate the discount for
Returns:
- the price of the passed product after promotional discount is applied, or Money.NOT_AVAILABLE if any of the restrictions on product or promotion are not met.
- getPromotionalPrice(product: Product, optionModel: ProductOptionModel): Money
This method follows the same logic as getPromotionalPrice(Product) but prices are calculated based on the option values selected in the specified option model.
Parameters:
- product - the product to calculate the discount for
- optionModel - the option model to use when calculating
Returns:
- the price of the passed product after promotional discount is applied, or Money.NOT_AVAILABLE if any of the restrictions on product or promotion are not met.
- getQualifierMatchMode(): String
Returns the qualifier matching mode specified by this promotion. A promotion may have up to 3 qualifier conditions based on whether it is customer-group based, coupon based, and/or source-code based. A promotion may require for example that a customer belong to a certain customer group and also have a certain coupon in the cart in order for the promotion to apply. This method returns QUALIFIER_MATCH_MODE_ALL if it is necessary that all the qualifier conditions are satisfied in order for this promotion to apply for a given customer. Otherwise, this method returns QUALIFIER_MATCH_MODE_ANY indicating that at least of the qualifier conditions must be satisfied.
Note: currently QUALIFIER_MATCH_MODE_ALL is only supported for promotions assigned to campaigns, and not those assigned to AB-tests.
Returns:
- the qualifier matching mode specified by this promotion, either QUALIFIER_MATCH_MODE_ALL or QUALIFIER_MATCH_MODE_ANY.
- getRank(): Number
Returns the promotion's rank. Rank is a numeric attribute that you can specify. Promotions with a defined rank are calculated before promotions without a defined rank. If two promotions have a rank, the one with the lowest rank is calculated first. For example, a promotion with rank 10 is calculated before one with rank 30.
Returns:
- The promotion's rank.
- getSourceCodeGroups(): Collection
Returns the source code groups directly assigned to the promotion or assigned to the campaign of the promotion.
If the promotion is not based on source code groups (see isBasedOnSourceCodes()), or no source code group is assigned to the promotion or its campaign, an empty collection is returned.
Returns:
- Source code groups assigned to promotion in no particular order.
- getStartDate(): Date
Returns the effective start date of this instance of the promotion. If no explicit start date is defined for this instance, the start date of the containing Campaign or AB-test is returned.
Returns:
- Start date of the promotion, or null if no start date is defined.
- getTags(): String[]
Returns the promotion's tags. Tags are a way of categorizing and organizing promotions. A promotion can have many tags. Tags will be returned in alphabetical order.
Returns:
- The promotion's set of tags.
- isActive(): Boolean
Returns 'true' if promotion is active, otherwise 'false'.
A promotion is active if its campaign is active, and the promotion is enabled, and it is scheduled for now.
Returns:
- true if promotion is active, otherwise false.
isBasedOnCoupon(): BooleanReturns 'true' if the promotion is triggered by a coupon, false otherwise.
Returns:
- true if promotion is triggered by coupon, otherwise false.
Deprecated:
- isBasedOnCoupons(): Boolean
Returns 'true' if the promotion is triggered by coupons, false otherwise.
Returns:
- true if promotion is triggered by coupons, otherwise false.
- isBasedOnCustomerGroups(): Boolean
Returns 'true' if the promotion is triggered by customer groups, false otherwise.
Returns:
- true if promotion is triggered by customer groups, otherwise false.
- isBasedOnSourceCodes(): Boolean
Returns 'true' if the promotion is triggered by source codes, false otherwise.
Returns:
- true if promotion is triggered by source codes, otherwise false.
- isEnabled(): Boolean
Returns true if promotion is enabled, otherwise false.
Returns:
- true if promotion is enabled, otherwise false.
- isRefinable(): Boolean
Returns true if promotion is refinable, otherwise false.
Returns:
- true if promotion is refinable, otherwise false.