Skip to content

Instantly share code, notes, and snippets.

@anotherxx
Created October 24, 2018 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anotherxx/596ac8bd8afebc3fb47de429aa9b90e7 to your computer and use it in GitHub Desktop.
Save anotherxx/596ac8bd8afebc3fb47de429aa9b90e7 to your computer and use it in GitHub Desktop.
[cartActions.INCREMENT_CART_ITEM_QTY]({ commit, state }, cartItemId) {
let clonedCartItems = {...state.cartItems}
clonedCartItems[cartItemId].qty++
let actualCartItems = []
for (let key in clonedCartItems) {
let currentCartItem = clonedCartItems[key]
actualCartItems.push({
id: currentCartItem.id,
product_id: currentCartItem.product_id,
qty: currentCartItem.qty
})
}
CartService.updateCartState(state.cartId, actualCartItems)
.then(data => {
let cartDetails = data.result
commit(cartMutations.SET_CART_DETAILS, cartDetails)
})
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment