Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vtexjs.checkout.getOrderForm()
- .then(function(orderForm) {
- var index = minicart.getItemIndex(item.id, orderForm);
- if (index === -1) {
- return vtexjs.checkout.addToCart([item]);
- } else {
- item.index = index;
- var itemQuantity = orderForm.items[index].quantity;
- item.quantity += itemQuantity;
- return vtexjs.checkout.updateItems([item]);
- }
- })
- .done(function(orderForm) {
- // console.log(orderForm);
- minicart.updateCartQuantity(orderForm);
- minicart.mountCart(orderForm);
- $('.js-open-minicart').trigger('click');
- })
- .fail(function(xhr, textStatus, err) {
- alert('Houve um erro ao adicionar o produto na sacola. Tente novamente.');
- })
- .always(function() {
- btn.removeClass('is-loading');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement