createBackInStockNotificationRequest( )
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
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.
Item details to include in the notification when the item is back in stock.
Returns
Created back in stock notification request.
Return Type:
NAME
TYPE
DESCRIPTION
Date and time the notification request was created.
Request ID.
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
.
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.
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 address to send notification to about item being back in stock.
Item URL for this request.
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 thestatus
is briefly set toPROCESSING
and then set toNOTIFICATION_SENT
if the email is successul, andFAILED
if it fails. - When a notification email is sent offline, use the
markAsNotificationSent()
function to setstatus
toNOTIFICATION_SENT
.
Was this helpful?
createBackInStockNotificationRequest example
1import { backInStockNotifications } from 'wix-ecom-backend';23 async function createBackInStockNotificationRequest(request, itemDetails) {4 try {5 const result = await backInStockNotifications.createBackInStockNotificationRequest(request, itemDetails);67 return result;8 } catch (error) {9 console.error(error);10 // Handle the error11 }12 }13