Skip to content

Availability Notifier API

API used to sign users up for notifications about availability of given products.

classDiagram
direction LR
    AvailabilityNotifierApi --> subscribe
    AvailabilityNotifierApi --> unsubscribe

    class AvailabilityNotifierApi {
        subscribe(productVariantId: number, email?: string) Promise~boolean~
        unsubscribe(productVariantId: number, email?: string) Promise~boolean~
    }

    link subscribe "../methods/subscribe/"
    link unsubscribe "../methods/unsubscribe/"

Get API

To get the Availability Notifier API use its name AvailabilityNotifierApi with the getApi method.

This API is initialized asynchronously which means that if you use the getApiSync method to get it, it might not exist yet and you will get an error as a result.

useStorefront(async (storefront) => {
    const availabilityNotifierApi = await storefront.getApi('AvailabilityNotifierApi');
});

Methods

  • subscribe - subscribe to notifications about availability of a product
  • unsubscribe - unsubscribe from notification about availability of a product

Event Bus events

Methods of this API dispatch the following events with the Event Bus:

Example

In this example we make a AvailabilityNotifierApi call to enable notifications about availability of a product with a given id.

useStorefront(async (storefront) => {
    const availabilityNotifierApi = await storefront.getApi('AvailabilityNotifierApi');

    await availabilityNotifierApi.subscribe(12);
});

Example

In this example we make a AvailabilityNotifierApi call to disable notifications about availability of a product with a given id.

useStorefront(async (storefront) => {
    const availabilityNotifierApi = await storefront.getApi('AvailabilityNotifierApi');

    await availabilityNotifierApi.unsubscribe(12);
});