You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x
getUserCarts
Get all customer carts from SAP Commerce Cloud.
This method exchanges data with the getCarts endpoint exposed by the SAP OCC API Carts Controller.
The method fetches customer carts based on the vsf-sap-token cookie (which is assigned to that customer). The cookie must be present in the request for the method to work properly.
Signature
export declare function getUserCarts(
context: SapccIntegrationContext,
props?: GetAllCartsProps
): Promise<CartList>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | SapccIntegrationContext | |
props | Optional | GetAllCartsProps | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
Returns
Returns a representation of a Cart List.
Referenced Types
Examples
Fetching a list of all customer carts.
import { sdk } from '~/sdk';
const { carts } = await sdk.commerce.getUserCarts();Fetching a list of customer carts and selecting response fields.
import { sdk } from '~/sdk';
const { carts } = await sdk.commerce.getUserCarts({ fields: 'carts(code)' });Fetching a list of saved customer carts.
import { sdk } from '~/sdk';
const { carts } = await sdk.commerce.getUserCarts({ savedCartsOnly: true });Fetching a paginated list of customer carts. The currentPage and pageSize properties have effect only when savedCartsOnly is true. Their default values are 0 and 20 respectively.
import { sdk } from '~/sdk';
const { carts } = await sdk.commerce.getUserCarts({
savedCartsOnly: true,
pageSize: 3,
currentPage: 2
});