Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16546,25 +16546,20 @@ var debug = "development" !== 'production'; // TODO Move state into modules when
mutations: {
ADD_PRODUCT_TO_CART: function ADD_PRODUCT_TO_CART(_ref, payload) {
var cart = _ref.cart;
console.log('Find index: ');
var increasedQuantity = cart;
var foundProductInCartIndex = cart.findIndex(function (item) {
return item.slug === payload.slug;
});
console.log('foundProductInCartIndex: ');
console.log(foundProductInCartIndex);

if (foundProductInCartIndex !== -1) {
console.log('Found item!'); // cart[foundProductInCartIndex].quantity += 1;

var increasedQuantity = cart;
increasedQuantity[foundProductInCartIndex].quantity += 1;
return increasedQuantity;
}

var newPayload = payload;
newPayload.quantity = 1;
cart.push(newPayload);
return false;
return null;
}
},
strict: "development" !== 'production',
Expand Down
12 changes: 2 additions & 10 deletions resources/js/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,21 @@ export default createStore({
},
mutations: {
ADD_PRODUCT_TO_CART({ cart }, payload) {
console.log('Find index: ');
const increasedQuantity = cart;
const foundProductInCartIndex = cart.findIndex(
(item) => item.slug === payload.slug,
);

console.log('foundProductInCartIndex: ');
console.log(foundProductInCartIndex);

if (foundProductInCartIndex !== -1) {
console.log('Found item!');
// cart[foundProductInCartIndex].quantity += 1;

const increasedQuantity = cart;
increasedQuantity[foundProductInCartIndex].quantity += 1;

return increasedQuantity;
}

const newPayload = payload;

newPayload.quantity = 1;
cart.push(newPayload);
return false;
return null;
},
},
strict: process.env.NODE_ENV !== 'production',
Expand Down