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.
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.
BonusChoiceDiscount.getBonusProducts()
doesn't work for this
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.
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 |
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.