Alert on Approaching Discounts

Salesforce B2C Commerce can calculate discounts for which a basket almost qualifies. These discounts are called approaching discounts or upsell discounts. The API retrieves the collection of discounts that almost qualify and shows a message for one or more of them in the storefront.

These promotion types have an Alert flag in Business Manager that controls whether customers are notified of the promotion before they fully meet the merchandise conditions:

  • Order: with amount of order merchandise total
  • Shipping: with amount of shipment merchandise total

If the Alert flag is set, you can specify a monetary value threshold that determines how close the customer must be in order to be notified of the discount. If the value is omitted, the customer is alerted as long as their basket is under the discount threshold. For tiered promotions, the alert only triggers for the lowest tier.

Examples

Suppose a merchant has three active promotions:

Promotion Description Enable upsells Upsell threshold
1 10% off orders over $150 true 50
2 20% off orders over $200 true 75
3 Free ground shipping for orders over $200 true 60

Case 1

A customer has $140 worth of merchandise in their cart, but doesn't qualify for any of the promotions. The API returns all three approaching discounts because the cart is within the thresholds defined by all three promotions.

Case 2

A customer has $150 worth of merchandise in their cart and receives 10% off their order due to Promotion 1. The merchandise total is now $135. The basket is within the threshold for Promotion 2 (here the $150 is used to determine the threshold, not the $135), and so the customer sees the upsell message for Promotion 2:

"Buy $50 more worth of merchandise and receive '20% off orders over $200.00'"

The upsell message says "$50 more worth of merchandise" instead of "$65 more." This is because the merchandise total that is used is after product promotions but before order promotions are considered. Merchants typically don't stack order promotions, so when the customer reaches the threshold for the second promotion, the first no longer applies.

The customer doesn't see upsell message for Promotion 3 because the merchandise total after order discounts is $135, which is less than $140 and therefore not within the threshold range defined by that promotion.

Note: B2C Commerce doesn't consider the exclusivity or rank of promotions in the PromotionPlan during this process. The reason is that the rank of two promotions that are based on the amount of merchandise total is irrelevant if the cart satisfies one condition threshold but not the other. In this case, the cart receives the discount for the promotions whose condition is satisfied, regardless of rank. Only when the cart satisfies the thresholds for both, can rank make a difference.

Adding Approaching Discounts to Your Application

Additional support is needed for this feature to your storefront application. To help you, we’ve provided this feature in the SiteGenesis application as follows:

  • In the SiteGenesis demo data, all order promotions of type With amount of qualifying products and shipping promotions or With amount of shipment qualifying products have Enable Upsells set to true with thresholds defined.
  • The cart page shows order and shipping promotions for which customers almost qualify.
  • The shipping page shows shipping promotions for which the customer almost qualifies.

Use These APIs

Use these APIs to implement approaching discount in your application.

ApproachingDiscount

The API class ApproachingDiscount, which represents a discount that a customer almost qualifies for based on the merchandise in their cart has these methods:

Method Description
Discount getDiscount() The discount the customer receives if they add more merchandise to the cart.
Money getConditionThreshold() The amount of merchandise required in the cart in order to receive the discount.
Money getMerchandiseValue() The amount of merchandise in the cart contributing towards the condition threshold (is always less than the condition threshold).
Money getDistanceFromConditionThreshold() The amount of additional money needed in the order or shipment to receive the discount.

DiscountPlan

The API class DiscountPlan, which retrieves the collection of discounts the cart almost qualifies for has these methods:

Method Description
Collection getApproachingOrderDiscounts() Gets the collection of order discounts that the LineItemCtnr almost qualifies for based on the merchandise total in the cart. Here almost is controlled by thresholds configured at the promotion level.

Collection getApproachingShippingDiscounts(Shipment shipment, Collection shippingMethods)

Gets the collection of shipping discounts that the passed shipment almost qualifies for based on the merchandise total in the shipment. Here almost is controlled by thresholds configured at the promotion level. This method only returns discounts for shipping promotions that apply to one of the passed shipping methods.
Collection getApproachingShippingDiscounts(Shipment shipment, ShippingMethod shippingMethod) Same as before, but filters by only a single shipping method.

B2C Commerce calculates approaching promotions based on DiscountPlan and not the cart directly. DiscountPlan is a formal description of discounts to be applied on a line item. B2C Commerce calculates the discounts themselves based on a specific set of promotions, that is, the PromotionPlan. It only selects approaching discounts from promotions in the original PromotionPlan. Removing discounts from the DiscountPlan has no effect on the approaching discounts returned by the API, and isn't supported.

How the APIs Work

Order promotions - The API retrieves the approaching order discounts of an order. An order can have approaching discounts even if it has actual applied discounts. To determine the approaching discounts, B2C Commerce:

  1. Reviews each non-applied order promotion in the original PromotionPlan with the enable upsells flag on.
  2. Determines if the order is within the condition threshold for the promotion rule by comparing the merchandise total of the DiscountPlan before other order discounts (and after considering any product discounts) against the condition threshold.
  3. If the merchandise total is within the range, includes the promotion in the returned collection. This collection can include multiple order promotions.
  4. Sorts the returned collection by the condition threshold ascending. Merchants typically want to show one promotion that represents the smallest amount of merchandise the customer must add to the cart to get a discount. Some merchants, however, want to show multiple messages. For example: "10% off orders over $200. 20% off orders over $300".

Shipping promotions - Approaching shipping discounts are calculated in a similar way. The API retrieves the approaching shipping discounts for each shipment in an order based on a set of shipping methods. A shipment can have approaching shipping discounts even if it has actual applied shipping discounts. When determining the approaching discounts, B2C Commerce:

  1. Reviews each non-applied shipping promotion in the original PromotionPlan with the enable upsells flag on.
  2. Filters promotions that don't apply to any of the included shipping methods.
  3. For each remaining promotion, determines if the shipment is within the condition threshold for the promotion rule. It determines this by considering the merchandise total of the shipment before other shipping discounts (and after product and prorated order discounts).
  4. Sorts the returned collection by the condition threshold ascending. This collection can include multiple shipping promotions.

Example

Using the API, you can retrieve the list of approaching promotions from within a template and show the appropriate messages, as shown in this example:

<!--- Approaching order promotions --->
 <isset name="DiscountPlan" value="${dw.campaign.PromotionMgr.getDiscounts(pdict.Basket)}" />
 <isloop items="${DiscountPlan.getApproachingOrderDiscounts()}" var="orderDiscount">
  Buy <isprint value="${orderDiscount.getDistanceFromConditionThreshold()}" />
  more worth of merchandise and receive:
  ${orderDiscount.getDiscount().getPromotion().getCalloutMsg()}<br/>
 </isloop>
<!--- Approaching shipping promotions (for default shipment) --->
 <isset name="Shipment" value="${pdict.Basket.getDefaultShipment()}" />
 <isset name="ShippingMethods" value=
 "${dw.order.ShippingMgr.getShipmentShippingModel(Shipment)
 .getApplicableShippingMethods()}" />
 <isloop items="${DiscountPlan.getApproachingShippingDiscounts(Shipment, ShippingMethods)}" var="shippingDiscount">
  Buy <isprint value="${shippingDiscount.getDistanceFromConditionThreshold()}" />
  more worth of merchandise and receive:
  ${shippingDiscount.getDiscount().getPromotion().getCalloutMsg()}<br/>
 </isloop>