Giỏ hàng của bạn đang trống
”
);
jQuery.each(cart.items,function(i,item){
clone_item(item);
});
});
};
function clone_item(product){
var item_product = jQuery(‘#clone-item .item_2’);
item_product.find(‘img’).attr(‘src’,product.image);
item_product.find(‘a:not(.remove-cart)’).attr(‘href’, product.url);
item_product.find(‘.text_cart > h4 > a’).html(product.title);
var variant = ”;
jQuery.each(product.variant_options,function(i,v){
variant = variant + ‘ ‘ + v;
});
item_product.find(‘.remove-cart’).attr(‘data-id’,product.variant_id);
item_product.find(‘.variant’).html(variant);
item_product.find(‘.price-line .new-price’).html(Haravan.formatMoney(product.price,”{{amount}}₫”) + “ x ” + product.quantity + ““);
item_product.clone().removeClass(‘hidden’).prependTo(‘#view-cart’);
}
jQuery(document).on(“click”,”.remove-cart”,function(){
var index_view_cart = jQuery(this).parents(‘.item-cart’).index() – 1;
jQuery(this).parents(‘.item-cart’).remove();
var variant_id = jQuery(this).attr(‘data-id’);
var params = {
type: ‘POST’,
url: ‘/cart/change.js’,
data: ‘quantity=0&id=’+variant_id,
dataType: ‘json’,
success: function(cart) {
if ( cart.item_count > 0 ) {
jQuery(‘.ajax_cart_quantity’).html(cart.item_count);
if ( window.location.pathname == ‘/cart’ ){
jQuery(‘#total-carts’).html(Haravan.formatMoney(cart.total_price, “{{amount}}₫”));
jQuery(‘#cartformpage tr.list-carts’).eq(index_view_cart).remove();
};
jQuery(‘.price.cart_block_total’).html(Haravan.formatMoney(cart.total_price, “{{amount}}₫”));
} else {
if ( window.location.pathname == ‘/cart’ ){
jQuery(‘#cartformpage’).remove();
jQuery(‘#layout-page’).append(“
Không có sản phẩm nào trong giỏ hàng!
“);
}
jQuery(‘.ajax_cart_quantity’).html(cart.item_count);
jQuery(‘#view-cart > div:not(#clone-item)’).remove();
jQuery(‘#view-cart’).append(“
Giỏ hàng của bạn đang trống
“);
}
},
error: function(XMLHttpRequest, textStatus) {
Haravan.onError(XMLHttpRequest, textStatus);
}
};
jQuery.ajax(params);
});
Related posts
Naturalium: Chăm sóc sắc đẹp Thói quen chăm sóc sắc đẹp cho phép bạn tập trung hơn vào tình...
Giải đáp thắc mắc: “LM trong bóng đá là gì?” chi tiết nhất
LM trong bóng đá là gì chính là câu hỏi mà nhiều người hâm mộ bóng đá hiện nay...
Sữa tắm Naturalium Bath & Shower Gel chiết xuất Đào là một trong số những sản phẩm dưỡng nổi...