createCart
Creates a customer's cart.
This method sends a POST request to the createCart endpoint of the Vue Storefront API Middleware. In turn, it receives data from the createCart endpoint exposed by the BigCommerce API
Signature
declare function createCart$1(
props: CreateCartParameters,
options?: MethodOptions
): Promise<CreateCartResponse>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Required | CreateCartParameters | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
options | Optional | MethodOptions |
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"
}
]
}
]}});