Skip to content

addFilter

addFilter is a DOM event that occurs whenever the filter is added.

Event body

The addFilter body has a TFilterConstructorOptions type which represents the details of the added filter. It is optional so it might not exist.

Example

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

useStorefront(async (storefront) => {
    document.addEventListener('addFilter', (event) => {
        const filterDetails = event.detail;

        const { id, name } = filterDetails

        console.log('Added filter:', id, name);
    });
});