Alokai

getBasket

Gets a basket from Salesforce Commerce Cloud.

This method communicates with the getBasket endpoint of the Vue Storefront API Middleware. In turn, it receives data from the getCustomerBaskets or the Get basket endpoints exposed by SCAPI / OCAPI depending on the middleware configuration.

You can use this method to fetch information about the customer baskets assigned to the current site.

Signature

export declare function getBasket(
	props?: Partial<BasketGetParams>
): Promise<import("commerce-sdk/dist/checkout/checkout").ShopperBaskets.Basket>;

Parameters

NameRequiredTypeDescription
propsOptionalPartial<BasketGetParams>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 customer basket, if one is returned. If called with a basket ID parameter, a basket will be fetched by that ID. If called without a basket ID parameter, permanent basket of the customer identified by the authorization JWT will be returned.

Referenced Types

  • BasketGetParams
  • ShopperBaskets.Basket

Examples

Fetching the customer's current basket.

import { sdk } from '~/sdk.config.ts';

const category = await sdk.commerce.getBasket();

Fetching a basket by ID.

import { sdk } from '~/sdk.config.ts';

const category = await sdk.commerce.getBasket({ basketId });

On this page