let live_template_html={"frontend_shopping_cart":"
\r\n \r\n <\/span>\r\n 0<\/span>\r\n <\/a>\r\n\r\n \r\n
\r\n
\r\n
\r\n
\r\n

cart (<\/b>)<\/h3>\r\n <\/div>\r\n
\r\n <\/i><\/a>\r\n <\/div>\r\n <\/div>\r\n
<\/div>\r\n <\/div>\r\n
\r\n
\r\n
\r\n Total:<\/span>\r\n 0.00<\/span>\r\n <\/div>\r\n <\/div>\r\n <\/div>\r\n
\r\n
\r\n <\/i> View cart<\/a>\r\n <\/div>\r\n \r\n\r\n <\/div>\r\n\r\n <\/div>\r\n \r\n<\/div>"}; function ltShoppingCart() { function getCartData($template) { //--Collect Cart Info $.post('/cart/info/json/', function (data) { let htmlTable = ""; let cartQuantity = data['productInfoAr'].length; let productImage = data['productInfo_ar']; let total=0; $.each(data['productInfoAr'], function (i, item) { total = total + item['quantity']; htmlTable += `
<\/a> <\/div>
${item['product_title']}<\/a>

${item['quantity']} x ${item['price']}<\/span><\/p> <\/div>

<\/i><\/a> <\/div> <\/div> `; }); $template.find('#cartTotal').html(total); $template.find('#cartQuantity').html(total); $template.find('#cartInfo').html(htmlTable); $template.find('#grandTotal').html(data['grandTotal']); $template.find('#viewCartLink').html("View cart"); $('#wishList').after($template); $template.find('#btnCart').on('click', function () { $('.mini_cart, .off_canvars_overlay').addClass('active') }); $template.find('.cart-update').on('click', function () { let id = $(this).attr('data-id'); $.post('/cart/remove/', {sl: id}, function (data) { if (data['error'] === 0) { //location.reload(); getCartData($template); } else { console.log("Cart Update Failed."); } }, "json"); return false; }); $template.find('#cartClose').on('click', function (data) { $('.mini_cart,.off_canvars_overlay').removeClass('active') }); }, 'json'); } $("
").liveTemplate('frontend_shopping_cart', function ($template) { getCartData($template); $('.addCart').on('click', function () { let id = $(this).attr('data-id'); let qty = $('#cartQty').val()?$('#cartQty').val():1; $.post('/cart/add/', {sl: id,qty:qty}, function (data) { if (data['error'] === 0) { getCartData($template); Lobibox.notify('success', { title: 'Message', continueDelayOnInactiveTab: true, msg: data.message, icon: "simple-icon-info", delay: 1000, position: 'center bottom' }); } else { Lobibox.notify('error', { title: 'Warning', continueDelayOnInactiveTab: true, msg: data.message, icon: "simple-icon-info", delay: 5000, position: 'center bottom' }); } }, "json"); return false; }); $(document).on('click', '.addCart', function () { let id = $(this).attr('data-id'); let qty = 1; $.post('/cart/add/', {sl: id,qty:qty}, function (data) { if (data['error'] === 0) { getCartData($template); Lobibox.notify('success', { title: 'Message', continueDelayOnInactiveTab: true, msg: data.message, icon: "simple-icon-info", delay: 1000, position: 'center bottom' }); } else { Lobibox.notify('error', { title: 'Warning', continueDelayOnInactiveTab: true, msg: data.message, icon: "simple-icon-info", delay: 5000, position: 'center bottom' }); } }, "json"); return false; }); }); }