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).
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:
calloutMsg.
Make sure you include your callout message
attribute in an Attribute Grouping (click Attribute
Grouping tab)
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>
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>