Template variables and if queries for emails
Learn how to use template variables and if queries to customise information displayed in your emails.
Welcome, everybody! Are you all excited about taking a tour of the magical worlds of plentywood studios?
Fantastic! While we’re at it, why don’t we check out the live filming of Amaranth Street?!? A big plenty hello to you all!
Today I am here with my friend Plelmo to talk about something that may appear slightly difficult at first.
Last week we took a trip to the theatre and watched some great productions about creating an email account and email templates.
Yes, that was fun!
So we learned all about the basics of setting up emails in your plentymarkets system. That’s right!
And we know how to set up emails in plentymarkets using templates.
Yes, that’s easy!
Absolutely… well, for the most part. Today we will be talking about template variables and if queries to even further tailor information that is displayed in your emails. So first off, Plelmo. What are template variables?
Hahaha. Close. Well template variables are used to make data available so that that content can be displayed in your email. It’s like a placeholder that reserves a spot for a specific type of information.
So let’s open our system and select an email template. The "Text in HTML format" tab already includes an email in HTML code. I’ve got my salutation, the text body and my closing statement. You’ve probably already noticed these strange bits here with the dollar sign in front. Those are template variables.
Aaaaah! Template variables!
That’s right, Plelmo. If you look at the salutation you’ll see the template variable "dollar sign customer full name". So when this email is sent to your customer, this code right here will transform into your customer’s first and last name.
The same applies to the order ID template variable. The code is automatically replaced by the relevant information, so in this case, your customer’s order ID.
To access the list of template variables, just click on this icon up here. Simply copy the variable you need and paste it where you want the corresponding information to appear in your email.
Hmm, that looks easy as pie, easy as pizza pie. But what is an if query?
Well, Plelmo, if constructs allow you to display content IF specific conditions are met.
Right, not quite so simple anymore. But still easy enough to learn. So as a very basic example, IF your customer orders, let’s say, pizza -
I like pizza.
Yes, I know you do. So for example, if your customer orders a big pizza pie, they’ll automatically get a big stack of paper table napkins as well.
The if condition I’ve just pasted in this email text is quite basic and displays bank account information, but only if your customer wants to pay for the order with a bank transfer - aka payment in advance.
Up here we have the actual if condition which expresses that the following information will appear IF the payment method with ID zero, so cash in advance, applies. As you can see, the text itself also includes a few template variables, like OrderID and CustomerID. So that info will automatically be inserted if the condition is met.
And since this is a single-line code block, the if condition must end with the expression endif. Are you still with me, Plelmo?
Oh yes, it’s like a conditional that includes an implication and a direct consequence.
Uh … yessss. Right, so now we still need to talk about ELSE. It’s often necessary to do one thing if a certain condition is met and to do a different thing if that condition is not met.
So in our first "if" example we said our customer gets a stack of table napkins if they order pizza. But if our customer orders a big plate of spaghetti, they’ll get the special spaghetti protection suit instead.
ELSE comes into play in this case because it extends if statements to include a different outcome when the expression within the if statement does not apply.
Okay, now we’ll add our ELSE first. So let’s just say our customer chose to pay with Paypal. That would mean our if clause, so payment in advance, does not apply. The text with the bank details would not be shown. Instead, your email would display this text down here.
Well, sort of. More the logic behind code. Now let’s just open an order and take a look at the email preview in the email tab.
Up top, you can see the full name of this particular customer and their corresponding order ID.
I see. And this customer wants to pay in advance so the bank details we entered as text in our if query are displayed further below.
Wow, Plelmo! That’s exactly right. Easy as pizza pie!
Oh yes! I like template variable and if query pizza.
Hahaha. Plelmo. So do I. So do I.