createCart
Creates a customer's cart.
It receives data from the createCart endpoint exposed by the BigCommerce API
Signature
declare function createCart(
context: BigcommerceIntegrationContext,
params: CreateCartParameters
): Promise<CreateCartResponse>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | BigcommerceIntegrationContext | |
params | Required | CreateCartParameters |
Returns
Returns a response with the cart object used in storefront cart responses.
Referenced Types
Examples
Creating a cart for the guest user with an added cart item
import { sdk } from '~/sdk.config.ts';
const cart = await sdk.bigcommerce.createCart({ data: {
lineItems: [{
"quantity": 2,
"productId": 230,
"optionSelections": [
{
"optionId": 10,
"optionValue": "Some Text Value"
}
]
}
]}});