mirror of
https://github.com/gosticks/vue-webshop.git
synced 2025-10-16 12:05:40 +00:00
Work in progress on the store commits design.
This commit is contained in:
parent
8c86a8a6cc
commit
58a174eae1
@ -46,6 +46,10 @@ const mutations = {
|
||||
[types.REMOVE_FROM_CART] (state, { id }) {
|
||||
const record = state.added.find(p => p.id === id)
|
||||
if (record) {
|
||||
let productObj = state.all.find(p => p.id === id)
|
||||
if (productObj) {
|
||||
productObj.inventory += record.quantity
|
||||
}
|
||||
state.added.splice(state.added.indexOf(record), 1)
|
||||
}
|
||||
},
|
||||
@ -54,6 +58,10 @@ const mutations = {
|
||||
const record = state.added.find(p => p.id === id)
|
||||
if (record) {
|
||||
if (record.quantity === 1) {
|
||||
let productObj = state.all.find(p => p.id === id)
|
||||
if (productObj) {
|
||||
productObj.inventory += record.quantity
|
||||
}
|
||||
state.added.splice(state.added.indexOf(record), 1)
|
||||
} else {
|
||||
record.quantity--
|
||||
|
||||
Loading…
Reference in New Issue
Block a user