emitUpdateBasketEvent(basketResponse: TBasketResponse): void¶
The emitUpdateBasketEvent
method allows to emit an event about the updated basket.
Input parameters¶
basketResponse¶
basketResponse
is a mandatory parameter of the TBasketResponse type that represents a basket object that should be emitted in the event.
Returned value¶
A returned value has a type of void
as this method returns nothing.
Example¶
In this example we make a basketUpdaterApi
call to emit an update basket event with the value of a current basket if it exists. To retrieve a basket object we use the getCurrentBasket method
useStorefront(async (storefront) => {
const basketUpdaterApi = storefront.getApiSync('basketUpdaterApi');
const currentBasket = basketUpdaterApi.getCurrentBasket(12);
if (currentBasket) {
basketUpdaterApi.emitUpdateBasketEvent({
basket,
flashMessages: []
});
}
});
Basket Updater API methods reference¶
- getBasket - Retrieve the contents of a basket
- getCurrentBasket - Retrieve the current active basket
- refreshBasket - Refresh the contents of a basket
- addItem - Add an item to the basket
- uploadVariantFile - Upload a file for a variant
- placeOrder - Place an order using the basket
- queueOrder - Queue an order for processing