mirror of
https://github.com/vercel/commerce.git
synced 2025-05-08 18:57:51 +00:00
Push it
This commit is contained in:
parent
d7caedd0a3
commit
a1de163406
@ -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 };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user