kiboky 5 лет назад
Родитель
Сommit
2e04f663de
2 измененных файлов с 7 добавлено и 1 удалено
  1. 1 1
      client/pages/cart.vue
  2. 6 0
      client/store/index.js

+ 1 - 1
client/pages/cart.vue

@@ -72,7 +72,7 @@
                              
                             <!-- Delete button -->
                             <span class="a-size-small">
-                              <a href="#">Delete</a>
+                              <a @click="$store.commit('removeProduct', product)" href="#">Delete</a>
                             </span>
                             &nbsp;
                             &nbsp;

+ 6 - 0
client/store/index.js

@@ -51,6 +51,12 @@ export const mutations = {
 
     let indexOfProduct = state.cart.indexOf(cartProduct)
     state.cart.splice(indexOfProduct, 1, cartProduct)
+  },
+
+  removeProduct (state, product) {
+    state.cartLength -= product.quantity
+    let indexOfProduct = state.cart.indexOf(product)
+    state.cart.splice(indexOfProduct, 1)
   }
 
 }