Alejandro Troncoso
2021-05-10T20:18:07Z

add_group_of_coupons_from_one.liquid

|
| // Define all codes from many promotions
| const coupons = ["cupon1", "cupon2", "cupon3"]
|
| //Callback that returns all coupons in cart
| var callback_added = function(data) {
| console.log(data.coupons)
| }
|
| // Callback that searches intersections between the codes in cart and the promotional codes.
| // If they intersect, all coupons will be added.
|
| var callbackFunction = function(data) {
| cart_coupons = data.coupons
| cart_coupons = cart_coupons.split(',');
|
| if (cart_coupons.filter(x => coupons.includes(x))) {
| Jumpseller.addCouponToCart(coupons, {
| callback: callback_added
| })
| }
|
| };
| $(document).ready(function() {
| // Call the function on document load
| Jumpseller.getCart({
| callback: callbackFunction
| })
|
| });
|