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

This 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 enables customers to select the 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. With the rule-based discount, however, 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/pipeline logic in your application or merge this functionality in from SiteGenesis. SiteGenesis demonstrates the type of pipeline and template changes that are required to use this discount. SiteGenesis visualizes the placeholders in the cart indicating the customer's entitlement, and provides a Select Bonus Products button. When a customer clicks the button, a window opens, enabling them to select bonus products to add to the cart.

The choice of bonus products discount placeholder is what distinguishes it from other product promotions that might grant, for example, a 100% discount or a fixed-price of $0.00 on a set of discounted products. 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 customer that they are entitled to a free product. Typically, the customer has already added the product to the cart and received a price adjustment reflecting the 100% off, or the customer did not add the product, and there is no hint in the cart that they are entitled to it.

Example of choice of bonus product discount (list) with prices

For example, a merchant configured these promotions:

The customer'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 customer basket is now eligible for the Gift Promo. The merchant has programmed the storefront to open a window when the customer is eligible for a choice of bonus product discount. The window enables the customer to 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 customer opens the window and selects product P2 into their basket. The customer 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

How the List-Based Discount Is Applied

This is how a choice of bonus product (list) discount is applied:

  1. The customer qualifies for a promotion with a choice of bonus product discount in the storefront, for example, by adding a coupon to the cart, adding a certain number of qualifying products, or reaching 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 customer can now select bonus products. The message includes a link to a bonus selection window.
  5. The customer 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), and adjusts the price to reflect the difference between this original price and the discount price. This is customizable 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 it a child PriceAdjustment that carries the promotion info, with the price of 0.00 (or a configured value).
Note: A BonusDiscountLineItem always has a quantity of one. In the example Buy 3 pairs of pants and get a choice of 1 bonus shirt, when the customer buys 12 widgets, the customer ends up with four BonusDiscountLineItem instances in the cart, as opposed to one BonusDiscountLineItem instance with a quantity of four.

B2C Commerce doesn't let the bonus product quantity exceed the maximum permitted by the discount. Though B2C Commerce allows storefront applications to call the API method LineItem.setQuantityValue() to set the quantity to an arbitrary value, the next time B2C Commerce applies discounts, 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.