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

Commit 4ee11cf

Browse files
author
Steph Dietz
committed
fix error when adding to cart after removing all items
1 parent f75f41d commit 4ee11cf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

backend/functions/assembly/crud.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ export function addToCart(cartId: string, productId: string): string {
297297
return upsertQuantityResult.error;
298298
}
299299
} else {
300-
const upsertResult = upsertCart(cartId, cart + "," + productId);
300+
const updatedCart = cart.length > 0 ? cart + "," + productId : productId;
301+
const upsertResult = upsertCart(cartId, updatedCart);
301302
if (upsertResult !== cartId) {
302303
console.log("Failed to update cart with new product:");
303304
return upsertResult;

0 commit comments

Comments
 (0)