Workflow: Update Cart Items

Change quantities, remove items, and update your shopping cart.

1
Update Quantity
2
Remove Items
3
Review Cart
1

Step 1: Update Item Quantities

Adjust the quantity of items in your cart

Classic Band Tee

Classic Band Tee

M / Black

2

€ 29,99

€ 59,98

Embroidered Dad Hat

Embroidered Dad Hat

One Size / Black

1

€ 24,99

€ 24,99

Update cart quantitytsx
1import { useCart } from '@fanbace/sdk';
2
3function CartItem({ item }: Props) {
4 const { updateQuantity } = useCart();
5
6 const handleQuantityChange = async (newQuantity: number) => {
7 if (newQuantity < 1) return;
8
9 await updateQuantity({
10 itemId: item.id,
11 quantity: newQuantity,
12 });
13 };
14
15 return (
16 <div>
17 <Button onClick={() => handleQuantityChange(item.quantity - 1)}>
18 <Minus />
19 </Button>
20 <span>{item.quantity}</span>
21 <Button onClick={() => handleQuantityChange(item.quantity + 1)}>
22 <Plus />
23 </Button>
24 </div>
25 );
26}