Skip to content

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