This page has been designed specifically for the printed screen. It may look different than the page you were viewing on the web.
Please recycle it when you're done reading.

The URI for this page is { http://blog.scrobbld.com }

Powerful new email features Posted on September 12th

[Update] If you like the idea of this but don’t fancy doing it yourself, I would be more than happy to craft an email for you! (Which you can then edit later). Just send me an email to: ian at scrobbld dot com

This is perhaps a post for our more programming oriented users as we’ve introduced some ‘programming’ functionality into our ‘order received’ emails, preempting the redesign of the notifiers page to support HTML emails, as well as a greater number of email types.

The new syntax comes in the form of commands, enumerators and modifiers; where the enumerators are a way of accessing the list of items, modifiers are a bunch of functions that are available to edit the text, and commands are a way of showing (or hiding) text dependent upon the things that are present in the data.

I’ll start with an example. If I want to see whether the first item ordered matched a certain item name, and then I could display some specific shipping information based upon that, e.g.;


Hello [first_name],

Thanks very much for buying things from our widget shop!

[shiny widget equals item_name:0]
The shiny widget will not ship until the 19th September, so please don’t contact us wondering where it is quite yet.
[/equals]

Kind regards

The Widget Shop.

So if the shiny widget was ordered then they will know not to email you about it too soon. You’ll also notice the [item_name:0] which references the first item name in the list of items (where the index is zero based). If they ordered more than one item, you could see the second item name by using the tag [item_name:1].

Commands

I’ve already introduced one command, ‘equals’. There are two others, ‘isset’ and ‘for’.

Isset looks like the following:


[isset option_name1:0]
Display this text
[/isset]

If option_name1 isn’t set, e.g. if the string value stored inside option_name1 has a length of 0, then ‘Display this text’ will be hidden.

The ‘for’ loop is a common concept with programmers, and makes it possible to look at each item in a list of items, because we’re not aware in advance how many items the customer has purchased. For example;


[for currentItem:items]
[quantity:currentItem] of ‘[item_name:currentItem]‘
[/for]

Where the string ‘currentItem’ is our index (e.g. 0, 1, 2, 3) which could be anything (e.g. i, j or currentItem will all work the same). This will print out the entire list of items that have been ordered, with the quantity for each item as well as the item name. We can expand this example to show you how easy it is to really do some nice customisation of the order list:


[for i:items]

[quantity:i] of ‘[item_name:i]‘
[isset option_name1:i] — [option_name1:i] – [option_selection1:i] [/isset]
[isset option_name2:i] — [option_name2:i] – [option_selection2:i] [/isset]

[shiny widget equals item_name:i]
The shiny widget will not be shipping quite yet… please be patient!
[/equals]

[0 equals stock:i]
(Unfortunately we don’t have any stock in for the ‘[item_name:i]‘ at the moment, but it will be arriving shortly!)
[/equals]

[/for]

This would look something like the following, assuming an order of three items:

1 of ‘My Shiny widget’
– Colour – Silver

(Unfortunately we don’t have any stock in for the ‘My Shiny Widget’ at the moment, but it will be arriving shortly!)

2 of ‘My Grey Widget’
– Size – Small

So with the small number of commands here we can give the customer quite a lot of information regarding their product purchase, which means less manual communication is required between yourself and your customer, because your customer is now aware of any shipping or stock issues.

Modifiers

Modifiers can be added to a tag to change the appearance of that tag. There are currently three modifiers; uppercase, lowercase and ucwords. Ucwords is perhaps the only one that isn’t obvious, and is used for capitalising the first letter from every word, and can be used like so;

(where first_name = ‘john’)

[first_name:ucwords]

(would output ‘John’).

You might also use this to make the equals more accurate, for example [john equals first_name:lowercase], because john is not the same as JOHN (e.g. the match is case sensitive).

Enumerators

We’ve already covered these as part of ‘Commands’, however, just to reiterate, enumerators are a way of accessing elements in a list, e.g. an item in a list of items, where the indexes start from 0 (the first item in the list).

You can also combine enumerators and modifiers, for example [first_name:0:ucwords] or [item_name:i:uppercase] and so forth.

If you’ve never done programming before this could be a bit of a stretch, but we will be adding a ‘preview’ function shortly to make it easier to mess around!

Trackback URL
Leave your own comments about this post: