Search.../

createBackInStockNotificationRequest( )

Developer Preview

Creates a back in stock notification request.

Description

If a notification request already exists for the same catalogReference and email, then a new one isn't created and the existing request is returned.

Syntax

function createBackInStockNotificationRequest(request: BackInStockNotificationRequest, itemDetails: BackInStockItemDetails): Promise<BackInStockNotificationRequest>

createBackInStockNotificationRequest Parameters

NAME
TYPE
DESCRIPTION
request
BackInStockNotificationRequest

Notification request information.

Includes details for the out of stock item and the email address requesting to be notified when it's back in stock.

itemDetails
BackInStockItemDetails

Item details to include in the notification when the item is back in stock.

Returns

Created back in stock notification request.

Return Type:

Promise<
BackInStockNotificationRequest
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time the notification request was created.

_id
string

Request ID.

autoNotified
boolean

Whether a notification was sent automatically.

autoNotified is empty when the notification request is created and is not returned until the field has a value. autoNotified receives a value when a notification email is sent for this request object.

autoNotified sets to true if the notification is sent through the site, either automatically or with the reportItemsBackInStock() function. If the notification email is sent offline but the status is updated with the markAsNotificationSent() function, then autoNotified sets to false.

catalogReference
CatalogReference

Catalog and item reference that the notification request is for.

Includes IDs for the catalog and item it came from, as well as additional, optional information.

contactId
string

Contact ID for the contact with this email.

If a contact does not already exist with the email address submitted when creating this request, then a new contact is created. For more information about contacts, see the Contacts API.

email
string

Email address to send notification to about item being back in stock.

itemUrl
string

Item URL for this request.

status
string

Status of the notification.

status is set to RECEIVED when the notification request is created. The status changes once a notification email is sent for this request object:

  • When a notification email is sent through the site, either automatically or with the reportItemsBackInStock() function, then the status is briefly set to PROCESSING and then set to NOTIFICATION_SENT if the email is successul, and FAILED if it fails.
  • When a notification email is sent offline, use the markAsNotificationSent() function to set status to NOTIFICATION_SENT.

Was this helpful?

createBackInStockNotificationRequest example

Copy Code
1import { backInStockNotifications } from 'wix-ecom-backend';
2
3 async function createBackInStockNotificationRequest(request, itemDetails) {
4 try {
5 const result = await backInStockNotifications.createBackInStockNotificationRequest(request, itemDetails);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13