HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/anvil.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();