add remove product

This commit is contained in:
Tiago Vasconcelos 2023-03-23 16:38:09 +00:00
parent 83f25f7972
commit 70d6c23d47
2 changed files with 9 additions and 2 deletions

View file

@ -124,10 +124,10 @@ async function customerStall(path) {
this.cart.products = prod this.cart.products = prod
this.updateCart(+item.price) this.updateCart(+item.price)
}, },
removeFromCart(item) { removeFromCart(item, del = false) {
let prod = this.cart.products let prod = this.cart.products
let qty = prod.get(item.id).quantity let qty = prod.get(item.id).quantity
if (qty == 1) { if (qty == 1 || del) {
prod.delete(item.id) prod.delete(item.id)
} else { } else {
prod.set(item.id, { prod.set(item.id, {

View file

@ -29,6 +29,13 @@ async function shoppingCart(path) {
'remove-from-cart', 'remove-from-cart',
this.products.find(p => p.id == id) this.products.find(p => p.id == id)
) )
},
removeProduct(id) {
this.$emit(
'remove-from-cart',
this.products.find(p => p.id == id),
true
)
} }
}, },
created() {} created() {}