Skip to content

Coupons container

The Coupons container manages the application of coupons to the shopping cart. It provides a text box for users to enter coupon codes. The container uses the applyCouponsToCart function to apply the coupon to the cart.

Coupons container

Coupons container

Configurations

The Coupons container provides the following configuration options:

OptionTypeReq?Description
couponCodeFieldVNodeNoCoupon code input field.
applyCouponsButtonVNodeNoThe button used to apply a coupon.
appliedCouponsVNodeNoList of applied coupon codes.
errorVNodeNoAn error message
onApplyCouponfunctionNoCallback when applying a coupon code.

Example configuration

The following example demonstrates how to render the Coupons container as part of the OrderSummary slot:

{
provider.render(OrderSummary, {
routeCheckout: () => '#checkout',
slots: {
Coupons: (ctx) => {
const coupons = document.createElement('div');
provider.render(Coupons)(coupons);
ctx.appendChild(coupons);
},
},
showTotalSaved: true,
})('.cart__order-summary'),