Subscribe to Triggered Emails
It's possible to subscribe to the Price drop and Back in stock specific triggered email notifications. The use-case is that a visitor would like to opt-in and subscribe to either a Price drop or Back in stock email notification for a specific product, by filling in their email address in a specific form constructed for the purpose.
You can use the following method to submit the visitor's subscriber details to the triggered emails feature:
ADDWISH_PARTNER_NS.api.triggered_email.subscribe(email, type, <calback>);
or
ADDWISH_PARTNER_NS.api.triggered_email.subscribe(email, type, url, <calback>);
Field | Type | Description |
---|---|---|
email |
String (required) | The email address of the visitor/user who wants to subscribe to a Price drop or Back in stock triggered email notification. |
type |
String (required) | Should be either the string "price_drop" or "back_in_stock". |
url |
String | This should be the URL for the product which to register the trigger. If omitted, the URL of the current page is used. If used, this could be: https://webshop.com/category/fancy-product.html |
callback |
function | The method which will be invoked after the status is returned from the Hello Retail server. The callback will return the status as shown on the next tab. |
Here is the list of status types that the callback
argument can return:
Status | Description |
---|---|
ok : |
The email is successfully registered. We will send an email when the selected event occurs for the specified product. This code is also returned if the same email was already registered for the same event on the same product. We will only send one email when the event occurs, even if the email is registered multiple times. |
invalid_email : |
The entered email is invalid. |
invalid_type : |
The type parameter did not have an accepted value. |
missing_product : |
We couldn't find a product with the url you specified. (Hint: Check it using our product lookup in the dashboard) |
not_enabled : |
You haven't enabled the Triggered Email feature, or you haven't enabled the trigger corresponding to the type . |
unknown_error : |
An unexpected error occurred. |
<form id="price_drop_form">
<label>
Type your email address to get a notification when this product drops in price:
<input type="email" id="price_drop_email">
</label>
<button id="subscribe">Notify me</button>
</form>
<span id="status"></span>
<script>
$("#price_drop_form").on("submit", function(e) {
ADDWISH_PARTNER_NS.api.triggered_email.subscribe($("#price_drop_email").val(), "price_drop", function(status) {
if (status === "ok") {
$("#price_drop_form").hide();
$("#status").text("Thank you! We'll let you know when this product drops in price.");
} else {
$("#status").text("Sorry, an error occured - " + status);
}
});
// Prevent the form from actually submitting:
e.preventDefault();
return false;
});
</script>