diff options
author | Adam T. Carpenter <atc@53hor.net> | 2020-12-03 18:18:57 -0500 |
---|---|---|
committer | Adam T. Carpenter <atc@53hor.net> | 2020-12-03 18:18:57 -0500 |
commit | 8280cf98c9a33613c7440442b73636e39dd297bc (patch) | |
tree | 9ed3494088585fe6309dac766eb91e5b4991c5e4 /iridescence/src/store | |
parent | 5751052a0df80260ea9e7c66ee222e95de4e35e3 (diff) | |
download | theglassyladies-8280cf98c9a33613c7440442b73636e39dd297bc.tar.xz theglassyladies-8280cf98c9a33613c7440442b73636e39dd297bc.zip |
when item cart count is 0, item is removed from cart display
Diffstat (limited to 'iridescence/src/store')
-rw-r--r-- | iridescence/src/store/index.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/iridescence/src/store/index.js b/iridescence/src/store/index.js index 8208f35..48cae11 100644 --- a/iridescence/src/store/index.js +++ b/iridescence/src/store/index.js @@ -36,6 +36,11 @@ export default new Vuex.Store({ cartItem(state, { id, by }) { if (state.cart[id]) { let newCount = (state.cart[id] += by); + if (newCount <= 0) { + // remove from cart entirely + delete state.cart[id]; + return; + } state.cart = { ...state.cart, [id]: newCount |