Personalization & Formatting of Push Notifications

Overview

Our campaigns module can personalize notifications to your customers. Variables can be used for the name, for example. But what if this message is also sent to guest customers whose names the system doesn't know? Or if data should be output in a specific format? This article shows the options for formatting messages.

Template Language: Handlebars

Shopgate uses Handlebars as a template language for notifications. In addition, we have added some functions for easier use. This article provides an overview of the most essential functions. Therefore, it is optional to know handlebars in detail. However, if you would like to learn more ways to customize messages, we recommend the Handlebars Guide:https://handlebarsjs.com/guide/

Variables

You can use variables, for example, to use the customer's name or an order number in the message. Variables may vary depending on the events used. Unless an event is used, only customer data is available.

The easiest way to use variables is to use the "wildcard" function in admin. You can also create variables manually if you know the name. The format is always, for example.

 

Formatting

Depending on the variable type, these can also be formatted further. For example, for dates or times, it is possible to define how exactly they should be displayed. In addition, numbers can be formatted as currency, for example.

Here are some examples:

Description Usage/Example Result
Format is automatically based on user's country/region
 {{date event.fulfillmentOrder.heldUntil }} 

 

10/05/2019

or

05.10.2019

Manual formatting of a date.

clickhere for details.

 {{date event.fulfillmentOrder.heldUntil "MM/DD/YYYY HH:mm" }} 

 

10/05/2019 11:57
Manual formatting of a date.
 {{date event.fulfillmentOrder.heldUntil "D.M.YY"}} 

 

 

5.10.19

Formatting time

Format is automatically based on user's country/region

 {{time event.fulfillmentOrder.heldUntil}} 

 

8:02 PM
Manual time formatting.
 {{time event.fulfillmentOrder.heldUntil "HH:mm"}} 

 

 

20:02

Currency formatting.

Format is automatically based on user's country/region

 {{currency event.fulfillmentOrder.total event.fulfillmentOrder.currencyCode}} 

 

$119.48

or

119,00 €

Formatting a number. Second parameter defines the number of decimal places.

Separator is automatically selected according to the customer's country/region.

 {{number event.fulfillmentOrder.total 1}} 

 

119.4

Control Structure

You can use control structures such as "if" conditions:

Description Usage/Example
Show first name if available
 {{#if customer}}

 {{customer.firstName}}

{{/if}} 

 

Show first name if available, alternatively “customer”
 {{#if customer}}

 {{customer.firstName}}

{{else}}

 Could

{{/if}} 

 

Show store phone number if available, otherwise show general phone number
 {{#if event.location.primaryAddress.phoneNumber}}

 {{event.location.primaryAddress.phoneNumber}}

{{else}}

 (177) 555-1234

{{/if}} 

 

Same
 {{#eq 10 10}}

 This is displayed

{{else}}

 But not this

{{/eq}} 

 

Not equal
{{#neq 10 10}}

 But not this

{{else}}

 This is displayed

{{/neq}} 

 

Greater than
 {{#gt 100 10}}

 This is displayed

{{else}}

 But not this

{{/gt}} 

 

Greater or equal
 {{#gte 100 100}}

 This is displayed

{{else}}

 But not this

{{/gte}} 

 

Less than
  {{#lt 100 10}}

 But not this

{{else}}

 This is displayed

{{/lt}} 

 

Smaller the same
 {{#lte 100 100}}

 This is displayed

{{else}}

 But not this

{{/lte}} 

 

Or (works with any number of arguments, only one must be true)
 {{#or 0 0 1 0}}

 This is displayed

{{else}}

 But not this

{{/or}} 

 

And (works with any number of arguments, all must be true)
 {{#and 0 0 1 0}}

 But not this

{{else}}

 This is displayed

{{/and}}