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/topswtwmobile.komma.pro/wwwroot/js/temp/cart.js
(function($) {

    /*// Add cart button
    $('.cart .amount-btn').bind('click',function(event)
    {
        event.preventDefault();
        editProductAmount($(this).attr('href'), $(this).parent().attr('data-id'));
    });*/

    // Add cart button
    $('.cart .cart-row .delete').bind('click',function(event)
    {
        event.preventDefault();
        editProductQuantity($(this).attr('href'), $(this).attr('data-id'));
    });

    // On input change
    $('.cart input[name*="quantity"]').bind('change',function()
    {
        var quantity = parseInt($(this).val());
        var id = $(this).attr('data-id');

        editProductQuantity($('#cartRow'+id).parent().attr('data-base-url') + '/setQuantityProductById/' + id + '/' + quantity, id);
    });

    // Add or subtract products
    function editProductQuantity(url, id)
    {
        $.ajax({
            url: url + '?ajax=1'
        }).success(function(quantity) {

            // Update header cart
            $('#header .cart .quantity').html(quantity);

            // Update cart row
            var $cartRow = $('#cartRow'+id);
            var $input = $('#cartRow'+id+ ' input[name*="quantity"]');

            if(parseInt(quantity) > 0)
            {
                // Update input field
                $input.val(quantity + ' set(s)');
            }
            else
            {
                // Clear row
                $cartRow.remove();
            }
        });
    }

})(jQuery);