shippingAddressModal.opened¶
shippingAddressModal.opened
is an event on the Event Bus that occurs whenever a modal containing a shipping address in the basket is opened.
Event body¶
The shippingAddressModal.opened
body has a TShippingAddressModalOpenedBody type which represents the details of a modal that is currently being opened. It is optional so it might not exist.
Example¶
In this example we listen to shippingAddressModal.opened
event and perform an action whenever it's emitted.
useStorefront(async (storefront) => {
storefront.eventBus.on('shippingAddressModal.opened', ({ body }) => {
console.log('Some shipping-address-modal webcomponent has been opened:', body);
});
});
Example¶
In this example we use a Message Storage API to retrieve an array of past shippingAddressModal.opened
events.
useStorefront((storefront) => {
const messageStorageApi = storefront.getApiSync('messageStorageSystemApi');
const pastOpenedEvents = messageStorageApi.getChannelMessages('shippingAddressModal.opened');
if (pastOpenedEvents.length > 0) {
pastOpenedEvents.forEach(({ body: eventBody }) => {
console.log('perform action on every past event');
});
}
});