summaryrefslogtreecommitdiff
path: root/iridescence/src/store
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-12-03 18:18:57 -0500
committerAdam T. Carpenter <atc@53hor.net>2020-12-03 18:18:57 -0500
commit8280cf98c9a33613c7440442b73636e39dd297bc (patch)
tree9ed3494088585fe6309dac766eb91e5b4991c5e4 /iridescence/src/store
parent5751052a0df80260ea9e7c66ee222e95de4e35e3 (diff)
downloadtheglassyladies-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.js5
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