Advertisement
Guest User

Untitled

a guest
Mar 30th, 2016
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. vtexjs.checkout.getOrderForm()
  2.   .then(function(orderForm) {
  3.     var index = minicart.getItemIndex(item.id, orderForm);
  4.     if (index === -1) {
  5.       return vtexjs.checkout.addToCart([item]);
  6.     } else {
  7.       item.index = index;
  8.       var itemQuantity = orderForm.items[index].quantity;
  9.       item.quantity += itemQuantity;
  10.       return vtexjs.checkout.updateItems([item]);
  11.     }
  12.   })
  13.   .done(function(orderForm) {
  14.     // console.log(orderForm);
  15.     minicart.updateCartQuantity(orderForm);
  16.     minicart.mountCart(orderForm);
  17.     $('.js-open-minicart').trigger('click');
  18.   })
  19.   .fail(function(xhr, textStatus, err) {
  20.     alert('Houve um erro ao adicionar o produto na sacola. Tente novamente.');
  21.   })
  22.   .always(function() {
  23.     btn.removeClass('is-loading');
  24.   });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement