Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery.getJSON('/cart.js', function(cart) {
- items = cart.items;
- var results = items.filter(x => x.id === 6223106801703);
- if ((results.length == 0) && (items.length > 0)) {
- jQuery.post('/cart/add.js', {
- quantity: 1,
- id: 6223106801703
- });
- location.reload();
- }
- if (results.length > 0 ) {
- if ((results.length == 1) && (items.length == 1)) {
- // remove free gift if there are no other products in cart
- jQuery.post('/cart/update.js', {updates: {6223106801703: 0}});
- } else {
- // update free gift gift to quantity = 1, for customers adding multiple free gifts
- jQuery.post('/cart/update.js', {updates: {6223106801703: 1}});
- }
- }
- });
Add Comment
Please, Sign In to add comment