This commit is contained in:
Lee Robinson 2024-07-27 20:42:42 -05:00
parent d7caedd0a3
commit a1de163406

View File

@ -51,7 +51,6 @@ function createOrUpdateCartItem(
const quantity = existingItem ? existingItem.quantity + 1 : 1; const quantity = existingItem ? existingItem.quantity + 1 : 1;
const totalAmount = calculateItemCost(quantity, variant.price.amount); const totalAmount = calculateItemCost(quantity, variant.price.amount);
console.log('quantity', quantity);
return { return {
id: existingItem?.id || `${variant.id}_${Date.now()}`, id: existingItem?.id || `${variant.id}_${Date.now()}`,
quantity, quantity,
@ -118,7 +117,7 @@ function cartReducer(state: Cart | undefined, action: CartAction): Cart | undefi
const updatedLines = existingItem const updatedLines = existingItem
? state.lines.map((item) => (item.merchandise.id === variant.id ? updatedItem : item)) ? state.lines.map((item) => (item.merchandise.id === variant.id ? updatedItem : item))
: [updatedItem, ...state.lines]; : [...state.lines, updatedItem];
return { ...state, ...updateCartTotals(updatedLines), lines: updatedLines }; return { ...state, ...updateCartTotals(updatedLines), lines: updatedLines };
} }