unsubscribe(productVariantId: number, email?: string): Promise<boolean>¶
The unsubscribe
is an asynchronous method that allows to unsubscribe from notifications about availability of a product with a given id.
Input parameters¶
productVariantId¶
productVariantId
is a mandatory parameter of the string
type that represents the id of a product for which we want to disable the availability notifications for.
email¶
email
is an optional field of the string
type which represents an email of a user who will be unsubscribed from these notifications.
Returned value¶
A returned value has a type of Promise<boolean>
indicating whether the user was successfully unsubscribed or not.
Event Bus events¶
This API method dispatches the following events with the Event Bus:
- availabilityNotifierEvents.unsubscribed - when the user unsubscribes from product availability notifications
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.unsubscribe(12);
});