File: D:/HostingSpaces/SBogers10/werken-bij-stafa.komma.pro/wwwroot/js/shop/shop.js
var ShoppingCart = {
// Initialize click event
init: function () {
// init something
},
addProductToShoppingcart: function (id, type) {
console.log(type);
let amount = 10;
Ajax.post(
'/addProductToShoppingcart',
{productableId: id, itemType: type, amount: amount},
function(xhr) {
window.location = xhr.response;
}
);
},
removeItemFromShoppingcart: function (id, type) {
Ajax.post(
'/removeItemFromShoppingcart',
{productableId: id, itemType: type},
function(xhr) {
window.location = xhr.response;
}
);
},
setItemAmountInShoppingcart: function (id, amount) {
if (amount > 0) {
Ajax.post(
'/setItemAmountInShoppingcart',
{itemId: id, amount: amount},
function(xhr) {
window.location = xhr.response;
}
);
} else {
this.removeItemFromShoppingcart(id);
}
},
updateCartButtonCounter: function () {
var count = $(".shoppingcartItemList ul li").length;
$(".shoppingCartButton span.shoppingCartButtonCounter").html(count);
}
};
ShoppingCart.init();