Skip to content
Open
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
8 changes: 4 additions & 4 deletions src/controllers/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export const addNewCart = ({ userId, products = [] }) => {
let totalQuantity = 0;

// get products in the relevant schema
const someProducts = productsByIds.map((p, idx) => {
// get quantity of the product
const quantity = productQty[idx];
const someProducts = productsByIds.map((p) => {
const originalIndex = productIds.indexOf(p.id); // match by id
const quantity = productQty[originalIndex];

// total price (price * quantity)
const priceWithQty = p.price * quantity;
Expand Down Expand Up @@ -219,4 +219,4 @@ export const deleteCartById = ({ id }) => {
cart.deletedOn = new Date().toISOString();

return cart;
};
};