Implementing a Choice of Bonus Product Discount

There are two types of choice of bonus products in the Salesforce B2C Commerce application: rule-based and list-based. Both are configurable and require application customization.

Rule-Based Discount

The rule-based discount doesn't work out of the box for customers who currently use the list-based discount. With bonus choice discounts, the storefront must render a user interface that shows the bonus products and lets shoppers select the products products they want. With a short, static list of SKUs, such as with the list-based discount, it's possible to render a simple popup. However, with the rule-based discount, the bonus product list might be very large.

To use the new discount, you must:

The ProductSearchModel API supports searching for bonus products so that you can build a user interface for this new discount type.

Important: The API method BonusChoiceDiscount.getBonusProducts() doesn't work for this discount.
Note: A future version of SiteGenesis will demonstrate this feature.

List-Based Discount

For the list-based discount, you can implement storefront template or pipeline logic in your application or merge this functionality in from Site Genesis. SiteGenesis demonstrates the type of pipeline and template changes that are required to use this discount. SiteGenesis visualizes the placeholders in the cart that indicate the shopper's entitlement, and provides a Select Bonus Products button. When a shopper clicks the button, a window opens, letting them select bonus products to add to the cart.

The Choice of Bonus Products discount placeholder distinguishes the promotion from other product promotions that could grant, for example, a 100% discount. For other discount types, the merchant code calls PromotionMgr.applyDiscounts(basket) from within a calculate-cart script.

When this method is invoked, B2C Commerce applies all applicable discounts by creating PriceAdjustments for regular discounts and ProductLineItems for bonus product discounts. With these other promotion discounts, no message appears in the cart notifying the shopper that they are entitled to a free product. Typically, the shopper adds the product and automatically receives the price adjustment, or they don’t add the product and aren’t shown any entitlement.

Example of Choice of Bonus Product Discount (List) with Prices

For example, a merchant configured these promotions:

The shopper's cart looks like the following before discounts are applied:

Product Quantity Base price Total price
A 1 $95.00 $95.00
    Total $95.00

The shopper’s basket is now eligible for the Gift Promo. The merchant has programmed the storefront to open a window when the shopper is eligible for a choice of bonus product discount. The window lets the shopper choose product P1 or P2, ordinarily $49.99, for a bonus price of $9.99. This adds the selected product to the cart for $9.99. Because the bonus product has a price, it's eligible for other product discounts. In this case, the price of the bonus product adds enough to the merchandise total of the basket to make it eligible for Order Promo.

The shopper opens the window and selects product P2 into their basket. The shopper’s cart looks like the following when the two promotions are applied:

Product Quantity Base price Total price
A 1 $95.00 $ 95.00
P2 1 $49.99 $ 49.99
Gift promo:   Total -$ 40.00
    Subtotal: $104.99
    Order promo: -$ 10.50
    Total: $ 94.49

List-Based Discount Application

  1. The shopper qualifies for a Choice of Bonus Product promotion in the storefront. For example, they add by a coupon to the cart or reach a configured merchandise total.
  2. The API method PromotionMgr.applyDiscounts(LineItemCtnr) is called.
  3. B2C Commerce creates a BonusDiscountLineItem in the basket indicating that the discount applies.
  4. A message appears in the storefront, indicating that the shopper can now select bonus products. The message includes a link to a bonus selection window.
  5. The shopper selects a bonus product from the bonus selection window.
  6. The AddBonusProductToBasket pipelet is invoked, resulting in a ProductLineItem added to the basket that is associated with the previously created BonusDiscountLineItem. The line item has price of 0.00 (or a configured value, for a defined price choice of products discount).
    • For a free bonus product discount, B2C Commerce creates a price adjustment of 0.00 for all bonus product line items. The default SiteGenesis CalculateCart.ds script sets the price of bonus product line items to the original price, as determined by price book lookup. It then adjusts the price to reflect the difference between this original price and the discount price. You can customize this logic.
    • For the defined price choice of products discount, bonus products are set to the configured value. Not only are these bonus products potentially eligible for other product discounts, the price of bonus products is considered when calculating the basis for other promotions.
  7. The API method PromotionMgr.applyDiscounts(LineItemCtnr) is called again.
  8. B2C Commerce detects that there is a BonusDiscountLineItem in the cart with an associated ProductLineItem. It ensures that the ProductLineItem has a price of 0.00 (or a configured value, for a Defined Price Choice of Products discount) and creates a child PriceAdjustment that carries the promotion info. This PriceAdjustment has the price of 0.00 (or a configured value).
Note: A BonusDiscountLineItem always has a quantity of one. For example, you run a promotion, Buy three pairs of pants and get a choice of one bonus shirt. When the shopper buys 12 pants, the shopper receives four BonusDiscountLineItem instances in the cart, instead of one BonusDiscountLineItem instance with a quantity of four.

B2C Commerce doesn't let the bonus product quantity exceed the maximum permitted by the discount. B2C Commerce lets storefront applications call the API method LineItem.setQuantityValue() to set the quantity to an arbitrary value. However, the next time a discount applies, it adjusts the value. For Choice of Bonus Product discounts, B2C Commerce removes all bonus product line items from the basket.

X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.