function updateVariantInCart(cartLineItem, quantity) {
    var variantId = cartLineItem.variant_id;
    var cartLength = cart.lineItems.length;
    cart.updateLineItem(cartLineItem.id, quantity).then(function(updatedCart) {
      var $cartItem = $('.cart').find('.cart-item[data-variant-id="' + variantId + '"]');
      if (updatedCart.lineItems.length >= cartLength) {
        $cartItem.find('.cart-item__quantity').val(cartLineItem.quantity);
        $cartItem.find('.cart-item__price').text(formatAsMoney(cartLineItem.line_price));
      } else {
        $cartItem.addClass('js-hidden').bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() {
           $cartItem.remove();
        });
      }

      updateCartTabButton();
      updateTotalCartPricing();
      if (updatedCart.lineItems.length < 1) {
        closeCart();
      }
    }).catch(function (errors) {
      console.log('Fail');
      console.error(errors);
    });
  }
/* Update details for item already in cart. Remove if necessary
  ============================================================ */
Update details for item already in cart. Remove if necessary
Update details for item already in cart . Remove if necessary
function updateVariantInCart(cartLineItem, quantity) {
    var variantId = cartLineItem.variant_id;
    var cartLength = cart.lineItems.length;
    cart.updateLineItem(cartLineItem.id, quantity).then(function(updatedCart) {
      var $cartItem = $('.cart').find('.cart-item[data-variant-id="' + variantId + '"]');
      if (updatedCart.lineItems.length >= cartLength) {
        $cartItem.find('.cart-item__quantity').val(cartLineItem.quantity);
        $cartItem.find('.cart-item__price').text(formatAsMoney(cartLineItem.line_price));
      } else {
        $cartItem.addClass('js-hidden').bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() {
           $cartItem.remove();
        });
      }
      updateCartTabButton();
      updateTotalCartPricing();
      if (updatedCart.lineItems.length < 1) {
        closeCart();
      }
    }).catch(function (errors) {
      console.log('Fail');
      console.error(errors);
    });
  }
function updateVariantInCart ( cartLineItem , quantity ) { var variantId = cartLineItem . variant_id ; var cartLength = cart . lineItems . length ; cart . updateLineItem ( cartLineItem . id , quantity ) . then ( function ( updatedCart ) { var $cartItem = $ ( '.cart' ) . find ( '.cart-item[data-variant-id="' + variantId + '"]' ) ; if ( updatedCart . lineItems . length >= cartLength ) { $cartItem . find ( '.cart-item__quantity' ) . val ( cartLineItem . quantity ) ; $cartItem . find ( '.cart-item__price' ) . text ( formatAsMoney ( cartLineItem . line_price ) ) ; } else { $cartItem . addClass ( 'js-hidden' ) . bind ( 'transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd' , function ( ) { $cartItem . remove ( ) ; } ) ; } updateCartTabButton ( ) ; updateTotalCartPricing ( ) ; if ( updatedCart . lineItems . length < 1 ) { closeCart ( ) ; } } ) . catch ( function ( errors ) { console . log ( 'Fail' ) ; console . error ( errors ) ; } ) ; }
Update details for item already in cart.
Update details for item already in cart .