Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit 053c4d1

Browse files
author
Steph Dietz
committed
return totalCartQuantity with cart
1 parent f56187b commit 053c4d1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

backend/functions/assembly/crud.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,5 +374,9 @@ export function getCart(cartId: string): Cart {
374374
);
375375
items.push(cartItemObject);
376376
}
377-
return new Cart(cartId, items);
377+
const totalCartQuantity = items.reduce<f64>(
378+
(acc, item) => acc + item.quantity,
379+
0,
380+
);
381+
return new Cart(cartId, items, totalCartQuantity);
378382
}

backend/functions/assembly/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class Cart {
4141
constructor(
4242
public cartId: string,
4343
public items: CartItemObject[] = [],
44-
public totalQuantity: f64 = 0,
44+
public totalCartQuantity: f64 = 0,
4545
) {}
4646
}
4747

0 commit comments

Comments
 (0)