Last active
May 10, 2021 20:42
-
-
Save aatronco/40a35805a5b2639e80df4a3e72ee5401 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// 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 | |
}) | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment