Skip to content

billingAddressModal.opened

billingAddressModal.opened is an event on the Event Bus that occurs whenever a modal containing a billing address in the basket is opened.

Event body

The billingAddressModal.opened body has a TBillingAddressModalOpenedBody 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 billingAddressModal.opened event and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    storefront.eventBus.on('billingAddressModal.opened', ({ body }) => {
        console.log('Some billing-address-modal webcomponent has been opened:', body);
    });
});

Example

In this example we use a Message Storage API to retrieve an array of past billingAddressModal.opened events.

useStorefront((storefront) => {
    const messageStorageApi = storefront.getApiSync('messageStorageSystemApi');

    const pastOpenedEvents = messageStorageApi.getChannelMessages('billingAddressModal.opened');

    if (pastOpenedEvents.length > 0) {
        pastOpenedEvents.forEach(({ body: eventBody }) => {
            console.log('perform action on every past event');
        });
    }
});

JS API reference