Displaying Two Promotional Messages
You can customize your code to show different promotional message on a product detail page, depending on whether the product is a qualifying or discounted product (or both) for a promotion for which a customer qualifies. This lets you communicate a different message on the qualifying product than on the participating products.
For example, if you wanted to offer a gift with a purchase, you might want to say something like Buy a Sawzall and get a FREE Sawzall Blade Set - $19.99 Value! on qualifying products, and Receive this Blade Set FREE with Purchase of Any Sawzall! on the discounted product. This lets you double the potential exposure for a particular promotion, and hopefully, increase product revenue.
This feature isn't implemented in SiteGenesis. To implement this feature, you must add a custom attribute to handle the message for a qualifying product, and you must change your storefront code to show different promotion messages using specific APIs. If you don't change your storefront code, Salesforce B2C Commerce behaves as before (see Case C in the table below).
How Do I Change My Storefront Code?
Use these methods to show different messages for a promotion on the product detail page, depending on the role the product plays in the promotion (qualifying or discounted).
Method | Description |
---|---|
PromotionPlan.getProductPromotionsForQualifyingProduct(Product) : Collection | Returns the product promotions for which the specified product is a qualifying, but not a discounted product. |
PromotionPlan.getProductPromotionsForDiscountedProduct(Product) : Collection | Returns the product promotions for which the specified product is a discounted (and possibly also a qualifying) product. It also returns promotions where the specified product is a bonus |
These methods provide an alternative to
PromotionPlan.getProductPromotions(Product) : Collection
.
See the API documentation for details.
To use the new API methods, you can do the following:
- Define a custom attribute on the Promotion object type, for
example, calloutMsg2, to hold the callout message relevant for
qualifying products. You can use the existing attribute
calloutMsg for discounted products.
- Select Administration > Site Development
> System Object Types > promotion >
Attribute Definitions tab, use the same parameters as for
calloutMsg.
Make sure you include your callout message attribute in an Attribute Grouping (click Attribute Grouping tab)
- Select Administration > Site Development
> System Object Types > promotion >
Attribute Definitions tab, use the same parameters as for
- Change all promotions to define two separate callout messages. If
you don't want different messages for the two cases, you can simply
duplicate the callout message to both attributes.
- Select site > Merchant Tools > Online Marketing > Promotions > promotion, enter information into the Qualifying Callout Message2 field that you just created.
- Change the storefront templates.
- SiteGenesis currently uses template code such as the following
to show information about the highest ranked promotion
associated with a product:
promotions.isml <isset name="promos" value="${dw.campaign.PromotionMgr.getActiveCustomerPromotions().getProductPromotions(pdict.Product)}" scope="page"/> <isloop items="${promos}" var="promo"> <!-- display calloutMsg for first returned promotion (omitted) --> <isbreak/> </isloop>
- Replace this method call with code such as the following,
which shows one of two different messages, depending on the
relation of the product to the promotion:
promotions.isml (new) <isset name="activeCustomerPromos" value="${dw.campaign.PromotionMgr.activeCustomerPromotions}" scope="page" /> <isset name="productPromos" value="${activeCustomerPromos.getProductPromotions(pdict.Product)}" scope="page" /> <isif condition="${! empty(productPromos)}"> <isloop items="${productPromos}" var="promo"> <isif condition="${activeCustomerPromos.getProductPromotionsForQualifyingProduct(pdict.Product).contains(promo)}"> <isprint value="${promo.custom.calloutMsg2}" encoding="off"/> <iselse> <isprint value="${promo.calloutMsg}" encoding="off"/> </isif> <isbreak/> </isloop> </isif>
- SiteGenesis currently uses template code such as the following
to show information about the highest ranked promotion
associated with a product:
Related Links
Infocenter Retirement: On June 30, 2023, the Infocenter was retired, and documentation currently hosted on the Infocenter will be published to Salesforce Help, Commerce Cloud Developer Center, and Salesforce B2C Commerce Developer Documentation Resources. For more information, see the release note.