getBasketCount(): number¶
The getBasketCount
method allows to retrieve a number of items in the basket.
Returned value¶
A returned value has a type of number
representing the number of items in the basket.
Example¶
In this example we make a basketProductsApi
call to retrieve a number of items in the basket.
useStorefront(async ({ eventBus, getApi }) => {
eventBus.on('basket.initialized', async () => {
const basketProductsApi = await getApi('basketProductsApi');
const amountOfProductsInBasket = basketProductsApi.getBasketCount();
});
});