[lightMode]
Add Coupon
A coupon is a code that consists of a special series of characters, or string, used by customers to get a discounted price or limited offer on the cart's items. This add endpoint is used for this purpose.
Payload
Response
Usage
To perform the action of applying a coupon to the cart's items, the developer may call the add()
as shown below.
salla.cart.addCoupon({ coupon: "Free_Shipping") }).then((response) => {
/* add your code here */
});
// TIP: short version
salla.cart.addCoupon('Free_Shipping').then((response) => {
/* add your code here */
});
Events
This endpoint may trigger two events, the onCouponAdded and onCouponAdditionFailed events.
onCouponAdded
This event is triggered when applying a new coupon by the customer is done without having any errors coming back from the backend.
cart.event.cart.onCouponAdded((response) => {
console.log(response)
});
onCouponAdditionFailed
This event is triggered when applying a new coupon by the customer is not completed and an error has occurred.
salla.event.cart.onCouponAdditionFailed((errorMessage) => {
console.log(errorMessage)
});
[updatedIn] 10 months ago
Payload
Response
Usage
Events
onCouponAdded
onCouponAdditionFailed