Show "Email me when available" widget

This API shows the standard Swym Back In Stock Alerts Modal according to the optional topic.

swat.addToWatchList

Definition

swat.addToWatchList(event, product, onSuccess, onError, renderIntoNodeopt, topic)

Example

Render "Email me when available" widget on a product page or any other page.

let event = null // Can be null if this was not triggered via an event


// The DOM element into which the content will be rendered
let renderIntoNodeopt = null; // if null shows modal.


// Define the out-of-stock product data 
let product = {
    epi: 41254709264582, // Unique variant ID of the product.
    empi: 7096252727494, // Product ID or master product ID.
    du: "https://demo.swym.it/products/1-light-pendant", // Canonical product URL.
    iu: "https://a.com/b.jpeg", // Image URL for email.
    pr: 230, // Product price.
    et: 8 // Event type 8 signifies a "notify me" event registration.
}

// Callback function for successful popup opening
let onSuccess = function(response) {
    console.log("Popup successfully opened.", response);
}

// The topic for the alert
let topic = "comingsoon"; // optional if null reverts to back-in-stock

// API call to add product to watchlist
swat.addToWatchList(event, product, onSuccess, renderIntoNodeopt, topic);

API Parameters

ArgumentTypeDescription
eventobjectevent object of click listener event can be null if not events
productobject product
onSuccessfunctionA callback function which will be called on success
renderIntoNode (optional)DOM nodeA DOM node where you want to show addToWatchlist as popup/inline form
topic
(optional)
stringA topic for which you want to subscribe for an alert (currently supported topics are "comingsoon" and "back-in-stock"); default is "back-in-stock"

Response

📘

This API does not have a onError response.

This API opens a modal, so there is no need for a response when the modal is not opened. However you can perform any actions in onSuccess callback if there is a requirement.

Upon successful execution, the same product information will be returned as part of the onSuccess callback response.

Other References

product

This is a JavaScript object that contains the following keys. Each key is necessary for successfully subscribing to alerts on that product.

Property NameData TypeRequiredDescription
epiint/stringYesVariant id of the product to be added
empiint/stringYesProduct id of the product to be added
dustringYesCanonical URL of the product to be subscribed.
prnumberYesproduct price / variant price
iu stringYesimage url of the product without protocol ( "https:")
etnumberYesevent type 8 stands for registering a "notify me" event.

Default Form

You can see the current version of the on our demo store.

Search for the button labeled "Email Me When Available" and click on it to open the modal.

Default Swym Back In Stock Alert Form

swym default back in stock alert form

❗️

The default form view may change with our product updates.