File: D:/HostingSpaces/SBogers10/edwingovers.komma.pro/wwwroot/js/shop/shop.js
var ShoppingCart = {
// Initialize click event
init: function () {
$('.userMenu').bind('click', function () {
console.log($(this).children('.dropdown').show());
});
},
addProductToShoppingcart: function () {
$.get("/addProductToShoppingcart", (function(self) {
return function (data) {
$(".shoppingCartContent").html(data);
self.updateCartButtonCounter();
}
}(this)));
},
removeItemFromShoppingcart: function (id) {
$.post("/removeItemFromShoppingcart", {itemID: id})
.done(function(self) {
return function (data) {
$(".shoppingCartContent").html(data);
self.updateCartButtonCounter();
}
})(this);
},
setItemAmountInShoppingcart: function (id, amount) {
if (amount > 0) {
$.post("/setItemAmountInShoppingcart", {itemID: id, amount: amount})
.done(function (data) {
$(".shoppingCartContent").html(data);
});
} else {
this.removeItemFromShoppingcart(id);
}
},
updateCartButtonCounter: function () {
var count = $(".shoppingcartItemList ul li").length;
$(".shoppingCartButton span.shoppingCartButtonCounter").html(count);
}
};
ShoppingCart.init();