API Choice of Bonus Product
When implementing a choice of bonus product discount, you can use both scripting APIs and pipelets.
Salesforce B2C Commerce Script APIs
Use these B2C Commerce Script API classes to access the choice of bonus product discount feature:
-
dw.order.BonusDiscountLineItem
-
dw.order.LineItemCtnr (getBonusDiscountLineItems())
-
dw.campaign.BonusChoiceDiscount
Pipelets
The
AddBonusProductToBasket
pipelet adds a bonus product to
the basket associated with a specific bonus discount line item. This
pipelet doesn't set the price of the bonus product. Salesforce B2C Commerce sets the price of selected bonus products when applying
discounts.
Your code must use this pipelet instead of the standard
AddProductToBasket
pipelet to add bonus items to the
basket.
When the ProductLineItem
representing the
selected bonus product is created using this special pipelet, it acts like
a normal ProductLineItem. All normal methods can be called on it.
It is the responsibility of application logic to prevent the line items from being modified unexpectedly. For example, your application shouldn't let the customer change the quantity of the line item in the cart beyond the limits allowed by the discount, or change the product associated with the line item to a non-discounted product.
Related Links
Implementing a Choice of Bonus Products Discount
Choice of Bonus Products Discount
The B2C Commerce API documentation