Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('.add-to-cart').on('click', function () {
- quanlity = $(this).siblings().find('#qty').val();
- if (quanlity == undefined)
- quanlity = 1;
- productid = $(this).data('productid');
- $.ajax({
- url: '/cart/AddToCart/?productId=' + productid + '&quantity=' + quanlity,
- dataType: 'json',
- success: function (data) {
- GetFromCart();
- if (data.Code == 1)
- toastr.success(data.Msg + "<br/>Số lượng: " + data.Data.Quantity, { timeOut: 10, preventDuplicates: true });
- if (data.Error)
- toastr.error(data.Msg, { timeOut: 10, preventDuplicates: true });
- }
- });
- return false;
- });
- var AddToCart = function (item) {
- itemhtml = $('<li id="product-' + item.item.id + '"><a href="' + item.item.url + '"><img src="' + item.item.imageUrl + '" alt=""></a><button data-productid="' + item.item.id + '" type="button" class="close">×</button><div class="overflow-h"><span>' + item.item.name + '</span><small>' + item.quantity + ' x <span class="digits" style="display:inline">' + item.item.displayPrice + '</span></small></div></li>');
- itemhtml.find('.digits').digits();
- itemhtml.find('.close').on('click', function () {
- RemoveFromCart($(this).data('productid'));
- });
- $('.shop-badge li.subtotal').before(itemhtml);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement