Script: Class dw.campaign.Promotion
Class Promotion
- Object
- dw.object.PersistentObject
- dw.object.ExtensibleObject
- dw.campaign.Promotion
- dw.object.ExtensibleObject
- dw.object.PersistentObject
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.
Constants
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.
Properties
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
The callout message of the promotion.
campaign : Campaign Read Only
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
The promotion's combinable promotions. Combinable promotions is a set of promotions or groups this promotion can be combined with.
conditionalDescription : MarkupText Read Only
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
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
The custom attributes for this extensible object.
customerGroups : Collection Read Only
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
The description of the promotion.
Method is deprecated and returns the same value as getCalloutMsg().
Deprecated:
Use getCalloutMsg()
details : MarkupText Read Only
The detailed description of the promotion.
enabled : boolean Read Only
Returns true if promotion is enabled, otherwise false.
endDate : Date Read Only
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
The promotion's exclusivity specifying how the promotion can be combined with other promotions. Possible values are EXCLUSIVITY_NO, EXCLUSIVITY_CLASS and EXCLUSIVITY_GLOBAL.
ID : String Read Only
The unique ID of the promotion.
image : MediaFile Read Only
The reference to the promotion image.
lastModified : Date Read Only
The date that this object was last modified.
mutuallyExclusivePromotions : String[] Read Only
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
The name of the promotion.
promotionClass : String Read Only
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
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
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
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
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
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.
Constructor Summary
This class does not have a constructor, so you cannot create it directly.
Method Summary
Returns the callout message of the promotion.
getCampaign() : Campaign
Returns the campaign this particular instance of the promotion is defined in.
getCombinablePromotions() : String[]
Returns the promotion's combinable promotions.
getConditionalDescription() : MarkupText
Returns a description of the condition that must be met for this promotion to be applicable.
getCoupons() : Collection
Returns the coupons directly assigned to the promotion or assigned to the campaign of the promotion.
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.
Returns the description of the promotion.
getDetails() : MarkupText
Returns the detailed description of the promotion.
getEndDate() : Date
Returns the effective end date of this instance of the promotion.
getExclusivity() : String
Returns the promotion's exclusivity specifying how the promotion can be combined with other promotions.
Returns the unique ID of the promotion.
Returns the reference to the promotion image.
getLastModified() : Date
Returns the date that this object was last modified.
getMutuallyExclusivePromotions() : String[]
Returns the promotion's mutually exclusive Promotions.
Returns the name of the promotion.
getPromotionalPrice(product : Product) : Money
Returns the promotional price for the specified product.
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.
Returns the promotion class indicating the general type of the promotion.
getQualifierMatchMode() : String
Returns the qualifier matching mode specified by this promotion.
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.
getStartDate() : Date
Returns the effective start date of this instance of the promotion.
Returns the promotion's tags.
isActive() : boolean
Returns 'true' if promotion is active, otherwise 'false'.
isBasedOnCoupon() : boolean
Returns 'true' if the promotion is triggered by a coupon, false otherwise.
isBasedOnCoupons() : boolean
Returns 'true' if the promotion is triggered by coupons, false otherwise.
isBasedOnCustomerGroups() : boolean
Returns 'true' if the promotion is triggered by customer groups, false otherwise.
isBasedOnSourceCodes() : boolean
Returns 'true' if the promotion is triggered by source codes, false otherwise.
isEnabled() : boolean
Returns true if promotion is enabled, otherwise false.
isRefinable() : boolean
Returns true if promotion is refinable, otherwise false.
Methods inherited from class ExtensibleObject
Methods inherited from class PersistentObject
getCreationDate, getLastModified, getUUID
Methods inherited from class Object
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
Method Detail
getCalloutMsg
getCalloutMsg() : MarkupText
Returns the callout message of the promotion.
Returns:
Callout message of the promotion.
getCampaign
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
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
getConditionalDescription() : MarkupText
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()
Returns:
Condition promotion description.
getCoupons
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
getCustom() : CustomAttributes
Returns the custom attributes for this extensible object.
getCustomerGroups
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
getDescription() : MarkupText
Returns the description of the promotion.
Method is deprecated and returns the same value as getCalloutMsg().
Deprecated:
Use getCalloutMsg()
Returns:
Description of the promotion.
getDetails
getDetails() : MarkupText
Returns the detailed description of the promotion.
Returns:
Detailed promotion description.
getEndDate
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
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
getID() : String
Returns the unique ID of the promotion.
Returns:
ID of the promotion.
getImage
getImage() : MediaFile
Returns the reference to the promotion image.
Returns:
Image of the promotion.
getLastModified
getLastModified() : Date
Returns the date that this object was last modified.
Returns:
the date that this object was last modified.
getMutuallyExclusivePromotions
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
getName() : String
Returns the name of the promotion.
Returns:
Name of the promotion.
getPromotionalPrice
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
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.
getPromotionClass
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.
getQualifierMatchMode
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
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
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
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
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
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
isBasedOnCoupon() : boolean
Returns 'true' if the promotion is triggered by a coupon, false otherwise.
Deprecated:
Returns:
true if promotion is triggered by coupon, otherwise false.
isBasedOnCoupons
isBasedOnCoupons() : boolean
Returns 'true' if the promotion is triggered by coupons, false otherwise.
Returns:
true if promotion is triggered by coupons, otherwise false.
isBasedOnCustomerGroups
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
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
isEnabled() : boolean
Returns true if promotion is enabled, otherwise false.
Returns:
true if promotion is enabled, otherwise false.
isRefinable
isRefinable() : boolean
Returns true if promotion is refinable, otherwise false.
Returns:
true if promotion is refinable, otherwise false.