From 70d6c23d47e6ce9c9f6c12c8e64bafe1b7a776f8 Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Thu, 23 Mar 2023 16:38:09 +0000 Subject: [PATCH] add remove product --- static/components/customer-stall/customer-stall.js | 4 ++-- static/components/shopping-cart/shopping-cart.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/static/components/customer-stall/customer-stall.js b/static/components/customer-stall/customer-stall.js index 34aef83..a9bac78 100644 --- a/static/components/customer-stall/customer-stall.js +++ b/static/components/customer-stall/customer-stall.js @@ -124,10 +124,10 @@ async function customerStall(path) { this.cart.products = prod this.updateCart(+item.price) }, - removeFromCart(item) { + removeFromCart(item, del = false) { let prod = this.cart.products let qty = prod.get(item.id).quantity - if (qty == 1) { + if (qty == 1 || del) { prod.delete(item.id) } else { prod.set(item.id, { diff --git a/static/components/shopping-cart/shopping-cart.js b/static/components/shopping-cart/shopping-cart.js index 2961fa3..15df126 100644 --- a/static/components/shopping-cart/shopping-cart.js +++ b/static/components/shopping-cart/shopping-cart.js @@ -29,6 +29,13 @@ async function shoppingCart(path) { 'remove-from-cart', this.products.find(p => p.id == id) ) + }, + removeProduct(id) { + this.$emit( + 'remove-from-cart', + this.products.find(p => p.id == id), + true + ) } }, created() {}