Coupons
Coupons are an effective way to incentivize purchases, reward loyal customers, and clear out inventory. This guide will show you how to add to and remove coupons from a cart using the Afosto Storefront Client.
Adding a Coupon to a Cart
To add a coupon to a cart, use the addCouponToCart
function. This function requires the coupon code as an argument. Here's an example:
1const cart = await client.addCouponToCart('my-coupon-code');
In the example above, a coupon with the code 'my-coupon-code' is added to the cart. The addCouponToCart
function returns the updated cart, now with the applied coupon.
Removing a Coupon from a Cart
To remove a coupon from a cart, use the removeCouponFromCart
function. This function also requires the coupon code as an argument. Here's an example:
1const cart = await client.removeCouponFromCart('my-coupon-code');
In the example above, the coupon with the code 'my-coupon-code' is removed from the cart. The removeCouponFromCart
function returns the updated cart, now without the removed coupon.
Using these methods, you can effectively apply and remove coupons from your customer's cart, allowing you to drive sales and customer engagement with targeted promotions and discounts.