Coupons, Gift Certificates, and Bonus Products
This topic covers less common use cases for working with baskets.
- Configure coupons using the information in Using Coupons as Promotion Qualifiers for B2C Commerce.
- Get a guest token.
- Create a basket.
- Add a coupon to the basket using the addCouponToBasket endpoint.
For additional code examples, see addCouponToBasket.
For gift certificate overview information and how to create a gift certificate, see Gift Certificates.
Use the Shopper Baskets addGiftCertificateItemToBasket endpoint to add a gift certificate to a basket, as shown in the following example:
- Configure the bonus product in Business Manager.
- Get a guest token.
- Create a basket.
- Add one or more products that are associated with a bonus product choice promotion using the createBasket or addItemToBasket endpoint.
- After a product is added to the basket, applicable bonus items become available. The basket response includes a property called
bonusDiscountLineItems
, which is a set of bonus products from which a customer can choose. - Copy the
productId
and thebonusDiscountLineItemId
from the response and use it to select the bonus product using the addItemToBasket endpoint. Quantity is a compulsory field and cannot exceed the number of bonus products allowed in the promotion. In this case, it is 1.
The previous script adds a product with bonus products to the basket. The first bonus product available in the bonusDiscountLineItems array is added to the basket.