//Remove items from cart $("#shopping_cart_items").on('click', 'button.remove-item', function(e) { e.preventDefault(); var pcode = $(this).attr("data-code"); $(this).parent().parent().parent().fadeOut(); $.getJSON( "/php/cart-process.php", {"remove_product":pcode} , function(data){ $(".total_price").html(data.total); $(".est_balance").html(data.balance); if (data.total=="0.00") { location.reload(); } }); }); $("#shopping_cart_items").on('click', 'a.remove-item', function(e) { e.preventDefault(); var pcode = $(this).attr("data-code"); $(this).parent().parent().fadeOut(); $.getJSON( "/php/cart-process.php", {"remove_product":pcode} , function(data){ $(".total_price").html(data.total); $(".est_balance").html(data.balance); if (data.total=="0.00") { location.reload(); } }); }); // Increment/Decrease Quantity $( ".qty-button").click(function(e) { e.preventDefault(); var todo = $(this).attr("data-direction"); var pcode = $(this).attr("data-code"); var pqty = $("#prod_qty"+pcode).val(); var pprice = $("#prod_price"+pcode).val(); if (todo=="plus") { pqty++; } if (todo=="minus") { if (pqty > 0) {pqty--;} } $("#prod_qty"+pcode).val(pqty); $.getJSON( "/php/cart-process.php", {"edit_product":pcode,"edit_qty":pqty,"edit_price":pprice} , function(data){ $(".subtotal_"+pcode).html("$"+data.subtotal); $(".total_price").html(data.total); $(".est_balance").html(data.balance); if (data.error=="Exceeds balance") { Wolmart.popup({items:{src:".notice-popup"},type:"inline",tLoading:"",mainClass:"mfp-newsletter mfp-fadein-popup"}); $("#prod_qty"+pcode).val(data.oqty); } }); });