Skip to content

isProductNotificationPossible(productVariantId: number): boolean

The isProductNotificationPossible method allows to get the information about the possibility to send a notification about a given product to the authenticated user.

Returned value

A returned value has a type of boolean indicating whether or not it is possible to send a product notification.

Example

In this example we make a UserApi call to get the information about the possibility to send a notification about a given product to the authenticated user.

Note that for the sake of example simplicity we wrote an id of some product variant by hand, however in real world this data usually gets passed to webcomponents within a product context with the help of Twig and ObjectApi.

    useStorefront(async (storefront) => {
        const userApi = await storefront.getApi('UserApi');

        const exampleProductVariantId = 1;

        const isNotificationPossible = userApi.isProductNotificationPossible(exampleProductVariantId);

        if (isNotificationPossible) {
            console.log(`it is possible to send a notification about product variant with id ${exampleProductVariantId} to the user`);
        }
    });

User API methods reference