Browse Source

[FIX] cart quantity

Gogs 7 năm trước cách đây
mục cha
commit
9da036084e
2 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 1 1
      src/components/common/CartItem.vue
  2. 4 0
      src/store/modules/cart.js

+ 1 - 1
src/components/common/CartItem.vue

@@ -1,7 +1,7 @@
 <template lang="pug">
     li.cart-item
         h3.item-name {{ item.displayName }}
-        input.item-quantity(type='number' min='1' :value='item.quantity')
+        input.item-quantity(type='number' min='1' :value='item.quantity' readonly)
         span.item-x x
         span.item-price {{ item.price | currency(...options) }}
         span.item-equals =

+ 4 - 0
src/store/modules/cart.js

@@ -85,6 +85,10 @@ const mutations = {
     [PULL_FROM_CART] (state, payload) {
         let productFoundIndex = state.cartItems.findIndex(item => item.id === payload.item.id)
 
+        if (state.cartItems[productFoundIndex].quantity === 1) {
+            payload.mode = 'full'
+        }
+
         if (payload.mode === 'partial') {
             state.cartItems[productFoundIndex].quantity = state.cartItems[productFoundIndex].quantity - 1
         } else {