Skip to content

Commit 67cc6a5

Browse files
committed
Fix bug with cart not clearing after purchase
1 parent 1a3d618 commit 67cc6a5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

public/js/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16724,7 +16724,8 @@ var mutations = {
1672416724
window.location.reload();
1672516725
},
1672616726
UPDATE_CART: function UPDATE_CART(state, cart) {
16727-
Object.assign(state.cart, cart);
16727+
var newState = state;
16728+
newState.cart = cart;
1672816729
},
1672916730
UPDATE_ORDER: function UPDATE_ORDER(state, order) {
1673016731
Object.assign(state.order, order);

resources/js/store/modules/mutations.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@ const mutations = {
44
window.location.reload();
55
},
66
UPDATE_CART(state, cart) {
7-
Object.assign(state.cart, cart);
7+
const newState = state;
8+
newState.cart = cart;
89
},
910
UPDATE_ORDER(state, order) {
1011
Object.assign(state.order, order);
1112
},
1213
ADD_PRODUCT_TO_CART({ cart }, payload) {
1314
// ESLint complains if we modify the state directly
1415
const cartCopy = cart;
15-
1616
const foundProductInCartIndex = cart.findIndex(
1717
(item) => item.slug === payload.slug,
1818
);
19-
2019
if (foundProductInCartIndex > -1) {
2120
cartCopy[foundProductInCartIndex].quantity += 1;
2221
return cartCopy;

0 commit comments

Comments
 (0)