getBasket(basketId: string): Promise<Basket | null>¶
The getBasket
method allows to retrieve the contents of a basket with a given id.
Input parameters¶
basketId¶
basketId
is a mandatory parameter of the string
type that represents the id of the basket we want to get.
Returned value¶
A returned value has a type of Promise<Basket | null>
. If a basket exists then it returns a Basket model. If it doesn't then it returns null
.
Example¶
In this example we make a basketUpdaterApi
call to retrieve the contents of a basket with a given id.
useStorefront(async (storefront) => {
const basketUpdaterApi = storefront.getApiSync('basketUpdaterApi');
const basket = basketUpdaterApi.getBasket(12);
console.log('shipping address provided in a basket:', basket.shippingAddress);
});
Basket Updater API methods reference¶
- getCurrentBasket - Retrieve the current active basket
- refreshBasket - Refresh the contents of a basket
- addItem - Add an item to the basket
- emitUpdateBasketEvent - Emit an update basket event
- uploadVariantFile - Upload a file for a variant
- placeOrder - Place an order using the basket
- queueOrder - Queue an order for processing