DocumentationCartFunctions

Update Quantity

amerta


amerta / Cart / updateQuantity

Function: updateQuantity()

updateQuantity(itemId, quantity, locale): Promise<{ cart: CartWithCalculations; error?: null; } | { cart?: null; error: ApiError; }>

Defined in: amerta/theme/utilities/cart.client.ts:101

Updates the quantity of a cart item or removes it if quantity is less than or equal to zero.

Parameters

| Parameter | Type | Description | | ------ | ------ | ------ | | itemId | string | The ID of the item to update. | | quantity | number | The new quantity. | | locale | string | The locale string. |

Returns

Promise<{ cart: CartWithCalculations; error?: null; } | { cart?: null; error: ApiError; }>

The updated cart or an error object.

Example

const res = await updateQuantity("123", 3, "en-US");