DocumentationCartFunctions

Fetch Cart

amerta


amerta / Cart / fetchCart

Function: fetchCart()

fetchCart(locale): Promise<{ cart: CartWithCalculations | null; error?: null; } | { cart?: null; error: ApiError; }>

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

Fetches the current cart from the server (uses cartId cookie automatically).

Parameters

| Parameter | Type | | ------ | ------ | | locale | string |

Returns

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

The current cart or an error object.

Example

const res = await fetchCart();