Setting up Back-in-Stock notifications

With Back-in-Stock notifications on your solutions, customers who encounter a product in your shops which is out of stock will be able to sign up for a notification email, once the product is back in stock.

From a frontend perspective a very simple feature.

From a backend perspective, however, it is a little more complicated to set up:

  • You must modify your product details template to let customers sign up for notification emails
  • You must create an email-page using the Product Catalog in Product Context rendered mode
  • You must create a scheduled email using the back-in-stock recipient provider

On the plus side, you only have to do it once :)

Here’s a step by step how-to to help you with the process.

To let users sign up for notification emails:

  • Open the Product Catalogue app settings
  • Open the Product template (Figure 2.1)
  • In an appropriate location, create a check for whether or not a product is out of stock, followed by a way to submit the ProductID, VariantID, and LanguageID using the createnotificationforthisproduct cart command
Figure 2.1 The product details template

In the following example, I first check if the product is out of stock.  If it is, I check if a notification has already been registered. If it hasn’t, I render a simple link for logged in users and an input field for anonymous users. If it has, I render a simple ‘Notification created’ message:

@if (GetInteger("Ecom:Product.Stock") <= 0){ if (GetBoolean("Ecom:Product.NotificationRegistered") != true) { <span> @if (GetGlobalValue("Global:Extranet.UserName") != "") { <a href="/@if (GetInteger("Ecom:Product.Stock") <= 0){ if (GetBoolean("Ecom:Product.NotificationRegistered") != true) { <span> @if (GetGlobalValue("Global:Extranet.UserName") != "") { <a href="/default.aspx?id=@GetValue("Ecom:Product:Page.ID")&productid=@GetValue("Ecom:Product.ID")&VariantID=@GetValue("Ecom:Product.VariantID")&LanguageID=@GetValue("Ecom:Product.LanguageID")&cartcmd=createnotificationforthisproduct">@Translate("Create Notification", "Create notification")</a> } @if (GetGlobalValue("Global:Extranet.UserName") == "") { <form name="@GetValue("Ecom:Product.ID")" id="NotificationForm_@GetValue("Ecom:Product.ID")" method="post" action="/@if (GetInteger("Ecom:Product.Stock") <= 0){ if (GetBoolean("Ecom:Product.NotificationRegistered") != true) { <span> @if (GetGlobalValue("Global:Extranet.UserName") != "") { <a href="/default.aspx?id=@GetValue("Ecom:Product:Page.ID")&productid=@GetValue("Ecom:Product.ID")&VariantID=@GetValue("Ecom:Product.VariantID")&LanguageID=@GetValue("Ecom:Product.LanguageID")&cartcmd=createnotificationforthisproduct">@Translate("Create Notification", "Create notification")</a> } @if (GetGlobalValue("Global:Extranet.UserName") == "") { <form name="@GetValue("Ecom:Product.ID")" id="NotificationForm_@GetValue("Ecom:Product.ID")" method="post" action="/Default.aspx?ID=@GetValue("Ecom:Product:Page.ID")"> <input type="hidden" name="ProductID" id="ProductID" value="@GetValue("Ecom:Product.ID")" /> <input type="hidden" name="VariantID" id="VariantID" value="@GetValue("Ecom:Product.VariantID")" /> <input type="hidden" name="LanguageID" id="LanguageID" value="@GetValue("Ecom:Product.LanguageID")" /> <input type="hidden" name="CartCmd" id="CartCmd" value="createnotificationforthisproduct" /> <label for="NotificationEmail">@Translate("Email", "Email")</label> <input type="email" required="required" id="NotificationEmail" name="NotificationEmail" value=""> <input type="submit" value="<!--@Translate(createnotification, "Create notification")-->"/> </form> } </span> } else { <br /> <br /> <span> @Translate("Notification created", "Notification created") </span> } } @GetValue("Ecom:Product:Page.ID")"> <input type="hidden" name="ProductID" id="ProductID" value="@GetValue("Ecom:Product.ID")" /> <input type="hidden" name="VariantID" id="VariantID" value="@GetValue("Ecom:Product.VariantID")" /> <input type="hidden" name="LanguageID" id="LanguageID" value="@GetValue("Ecom:Product.LanguageID")" /> <input type="hidden" name="CartCmd" id="CartCmd" value="createnotificationforthisproduct" /> <label for="NotificationEmail">@Translate("Email", "Email")</label> <input type="email" required="required" id="NotificationEmail" name="NotificationEmail" value=""> <input type="submit" value="<!--@Translate(createnotification, "Create notification")-->"/> </form> } </span> } else { <br /> <br /> <span> @Translate("Notification created", "Notification created") </span> } } @GetValue("Ecom:Product:Page.ID")&productid=@GetValue("Ecom:Product.ID")&VariantID=@GetValue("Ecom:Product.VariantID")&LanguageID=@GetValue("Ecom:Product.LanguageID")&cartcmd=createnotificationforthisproduct">@Translate("Create Notification", "Create notification")</a> } @if (GetGlobalValue("Global:Extranet.UserName") == "") { <form name="@GetValue("Ecom:Product.ID")" id="NotificationForm_@GetValue("Ecom:Product.ID")" method="post" action="/@if (GetInteger("Ecom:Product.Stock") <= 0){ if (GetBoolean("Ecom:Product.NotificationRegistered") != true) { <span> @if (GetGlobalValue("Global:Extranet.UserName") != "") { <a href="/default.aspx?id=@GetValue("Ecom:Product:Page.ID")&productid=@GetValue("Ecom:Product.ID")&VariantID=@GetValue("Ecom:Product.VariantID")&LanguageID=@GetValue("Ecom:Product.LanguageID")&cartcmd=createnotificationforthisproduct">@Translate("Create Notification", "Create notification")</a> } @if (GetGlobalValue("Global:Extranet.UserName") == "") { <form name="@GetValue("Ecom:Product.ID")" id="NotificationForm_@GetValue("Ecom:Product.ID")" method="post" action="/Default.aspx?ID=@GetValue("Ecom:Product:Page.ID")"> <input type="hidden" name="ProductID" id="ProductID" value="@GetValue("Ecom:Product.ID")" /> <input type="hidden" name="VariantID" id="VariantID" value="@GetValue("Ecom:Product.VariantID")" /> <input type="hidden" name="LanguageID" id="LanguageID" value="@GetValue("Ecom:Product.LanguageID")" /> <input type="hidden" name="CartCmd" id="CartCmd" value="createnotificationforthisproduct" /> <label for="NotificationEmail">@Translate("Email", "Email")</label> <input type="email" required="required" id="NotificationEmail" name="NotificationEmail" value=""> <input type="submit" value="<!--@Translate(createnotification, "Create notification")-->"/> </form> } </span> } else { <br /> <br /> <span> @Translate("Notification created", "Notification created") </span> } } @GetValue("Ecom:Product:Page.ID")"> <input type="hidden" name="ProductID" id="ProductID" value="@GetValue("Ecom:Product.ID")" /> <input type="hidden" name="VariantID" id="VariantID" value="@GetValue("Ecom:Product.VariantID")" /> <input type="hidden" name="LanguageID" id="LanguageID" value="@GetValue("Ecom:Product.LanguageID")" /> <input type="hidden" name="CartCmd" id="CartCmd" value="createnotificationforthisproduct" /> <label for="NotificationEmail">@Translate("Email", "Email")</label> <input type="email" required="required" id="NotificationEmail" name="NotificationEmail" value=""> <input type="submit" value="<!--@Translate(createnotification, "Create notification")-->"/> </form> } </span> } else { <br /> <br /> <span> @Translate("Notification created", "Notification created") </span> } }

Paste this code into your product template (or create and use your own).

Your customers can now add themselves to the Notifications-list, which is accessible from the Notifications-node in your backend product catalog

Of course, they won’t receive any notifications before a notification email has been created.

Creating and sending out emails in Dynamicweb consists of two things:

  • Creating a page with email content
  • Creating an email which sends the page to users

Here’s how to do both.

A back-in-stock email can consist of anything you’d like, but it’s usually a good idea to show customers which product or products are back in stock.

To do so:

  • Add a Product Catalogue app to the email page
  • Select the Products (context) mode under show settings (Figure 4.1)
  • In the templates section, select or create a List and/or details template to render the product(s) in context.
Figure 4.1 Set the product catalogue app to render product contexts

Once you’ve added the rest of the content to your email, save it.

Next up is scheduling an email targeting recipients on your notifications list.

To create and schedule an email targeting the customers who add themselves to the notifications list:

  • Click Marketing > Email Marketing
  • Right click on an appropriate top folder and click Create new email
  • Name the email – you can use email placeholder tags to personalize the subject
  • Go to the Advanced tab, open the recipient provider settings and select the back in stock recipients provider and the website (Figure 5.1).
Figure 5.1 Selecting the back-in-stock recipient provider

Next, open the contents settings and check render content for each recipient to make sure the product(s) back in stock are correctly rendered for each recipient, and the recipient settings and uncheck Ensure unique recipients to allow users to receive more than one notification email from you (Figure 5.2). Don’t set a quarantine period.

Finally, fill out the rest of the details – from name and email, pre-header, etc. – and select the email page you just created as the page to send to your customers.

Save – you are now ready to schedule the email.

Figure 5.2 Make sure the content and recipient settings are correctly configured

To schedule the Back-in-Stock email, click Scheduled send in the email toolbar.

This opens the scheduling window, from which you can set a repetition interval, a start date, and so forth. Select an interval appropriate to your solution.

Figure 6.1 Scheduling the email

Once scheduled, the email will be located in the Scheduled folder under the top folder you selected. Here it will remain, even as it is periodically sent out (as is standard behavior).

It’s always a good idea to test if everything works as expected.

To test your back-in-stock notifications setup:

  • Locate a product which is out of stock and sign a test user up for a notification
  • Put the product back in stock
  • Go to Settings > System > Scheduled tasks and force the appropriate recurring email task.