DocumentationCartFunctions

Apply Coupon

amerta


amerta / Cart / applyCoupon

Function: applyCoupon()

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

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

Applies a coupon code to the cart.

Parameters

| Parameter | Type | Description | | ------ | ------ | ------ | | code | string | The coupon code to apply. | | locale | string | - |

Returns

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

The updated cart or an error object.

Example

const res = await applyCoupon("SUMMER2024", "en-US");