addCouponToCart
Add coupon to the cart.
It receives data from the getCart endpoint exposed by the BigCommerce API
Signature
declare function addCouponToCart(
context: BigcommerceIntegrationContext,
params: AddCouponParameters
): Promise<AddCouponResponse>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | BigcommerceIntegrationContext | |
params | Required | AddCouponParameters |
Returns
Returns a response with the cart object used in storefront cart responses.
Referenced Types
Examples
Adding a coupon and fetching updated cart:
import { sdk } from '~/sdk.config.ts';
const cart = await sdk.bigcommerce.addCouponToCart({ checkoutId: "930a1424-e8e8-4757-b4f6-8de76c8106cb", "couponCode": "some-code" });