Created
May 29, 2018 20:54
-
-
Save j7u7l7s/c5a0e271b8e5386448a889bad7c2b9a8 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
$(document).on('click','.productId', function(e){ | |
var qty = 1; | |
var id = $(this).data('variant'); | |
addItem=function(qty,id,callback) { | |
var params = {quantity:qty,id:id}; | |
$.ajax({ | |
type: 'POST', | |
url: '/cart/add.js', | |
dataType: 'json', | |
data: params, | |
success: function(){ | |
$.getJSON('/cart.js', function(cart) { | |
var new_count = cart.item_count ; | |
$('.site-header-cart--count ').attr('data-header-cart-count', new_count); | |
}); | |
}, | |
error: function(){} | |
}); | |
} | |
addItem(qty,id,function(){ | |
console.log('done'); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment