This event is triggered when a redemption is made by a customer (or programmatically via SDK). This is often helpful if you are implementing a custom redemption interface. The event is passed a single object representing the redemption made. It will include the following attributes:
$(document).on("swell:redemption", function(redemption) {
if (redemption.discountType === "product") {
// add the free product to cart
cartJS.add(redemption.appliesToId);
} else {
// control the display of the coupon code to your customers
myCoolUI.showCouponCode(redemption.couponCode);
// save the code for later (to display it on future page loads?)
sessionStorage.setItem("most-recent-coupon", redemption.couponCode);
}
});