Skip to content

basket.orderPlaced

basket.orderPlaced is an event on the Event Bus that occurs whenever an order is placed.

Event body

none

Example

In this example we listen to basket.orderPlaced event and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    storefront.eventBus.on('basket.orderPlaced', () => {
        console.log('An order has been placed');
    });
});

Example

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

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

    const pastOrderPlacedEvents = messageStorageApi.getChannelMessages('basket.orderPlaced');

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

JS API reference