Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.54 KB | None | 0 0
  1.         $('.add-to-cart').on('click', function () {
  2.             quanlity = $(this).siblings().find('#qty').val();
  3.             if (quanlity == undefined)
  4.                 quanlity = 1;
  5.             productid = $(this).data('productid');
  6.             $.ajax({
  7.                 url: '/cart/AddToCart/?productId=' + productid + '&quantity=' + quanlity,
  8.                 dataType: 'json',
  9.                 success: function (data) {
  10.                     GetFromCart();
  11.                     if (data.Code == 1)
  12.                         toastr.success(data.Msg + "<br/>Số lượng: " + data.Data.Quantity, { timeOut: 10, preventDuplicates: true });
  13.                     if (data.Error)
  14.                         toastr.error(data.Msg, { timeOut: 10, preventDuplicates: true });
  15.                 }
  16.             });
  17.             return false;
  18.         });
  19.  
  20.         var AddToCart = function (item) {
  21.             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>');
  22.             itemhtml.find('.digits').digits();
  23.             itemhtml.find('.close').on('click', function () {
  24.                 RemoveFromCart($(this).data('productid'));
  25.             });
  26.             $('.shop-badge li.subtotal').before(itemhtml);
  27.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement