Request a Back In Stock Alert
Request an Back in Stock alert for an out of stock product.
swat.sendWatchlist
Subscribe to a product alert for an out-of-stock item using this API. Once the product becomes available again, meeting all relevant conditions, subscribers who have registered through this API will receive an alert email. This email will inform them that the product they're interested in is now back in stock.
Definition
swat.sendWatchlist(mediumValue, medium, product, onSuccess, onError, addToMailingListopt)
Example
Using the following information, this example demonstrates how to register a back-in-stock alert request on the Swym platform.
// Define the email address you want to subscribe to
let mediumValue = "[email protected]";
let medium = "email";
// Product data of the product
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, // price
et: 8 // event type 8 stands for registering a "notify me" event.
}
let onSuccess = function(response) {
console.log("Successfully Subscribed the email for the alert.", response);
}
let onError = function(error) {
console.log("There was an Error while subscribing the email for the alert.", error);
}
// Sample call..
swat.sendWatchlist(mediumValue, medium, product, onSuccess, onError, 1);
API Parameters
Argument | Type | Description |
---|---|---|
mediumValue | string | Value of the medium (currently supported ‘email’, hence email Id) |
medium | string | What id is collected (currently 'email' supported) |
product | object | product that is the content the out of stock alert |
callbackFn | function | Function that gets called after a successful HTTP API call |
errorCallback | function | The error callback function which will be called on unsuccessful response |
addToMailingList (optional) | int | Possible values: 1(opted in) or 0(opted out), to tell if user will be added to the mailing list (Note:- requires mailing list feature to be set up from Swym's end) |
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 Name | Data Type | Required | Description |
---|---|---|---|
epi | int/string | Yes | Variant id of the product to be added |
empi | int/string | Yes | Product id of the product to be added |
du | string | Yes | Canonical URL of the product to be subscribed. |
pr | number | Yes | product price / variant price |
iu | string | Yes | image url of the product without protocol ( "https:") |
Render Default form
Not Interested in Crafting My Own Form
If you're not interested in creating a custom form and prefer to display the default form under specific conditions, make use of the "Email Me When Available Widget API".
Updated over 1 year ago