shopping cart add and remove products quantity
This commit is contained in:
parent
a28cae039c
commit
83f25f7972
5 changed files with 45 additions and 9 deletions
|
|
@ -10,6 +10,7 @@ async function customerStall(path) {
|
|||
'login-dialog',
|
||||
'stall',
|
||||
'products',
|
||||
'stallproducts',
|
||||
'product-detail',
|
||||
'change-page',
|
||||
'relays',
|
||||
|
|
@ -124,7 +125,17 @@ async function customerStall(path) {
|
|||
this.updateCart(+item.price)
|
||||
},
|
||||
removeFromCart(item) {
|
||||
this.cart.products.delete(item.id)
|
||||
let prod = this.cart.products
|
||||
let qty = prod.get(item.id).quantity
|
||||
if (qty == 1) {
|
||||
prod.delete(item.id)
|
||||
} else {
|
||||
prod.set(item.id, {
|
||||
...prod.get(item.id),
|
||||
quantity: qty - 1
|
||||
})
|
||||
}
|
||||
this.cart.products = prod
|
||||
this.updateCart(+item.price, true)
|
||||
},
|
||||
updateCart(price, del = false) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue