Each block of a transactional email can be shown always, or only when rules about the email’s data hold: for example a note about paying in cash only on cash on delivery orders, or opening hours only on pickup orders. The rules are checked for each email when it is sent. A customer receives only the blocks whose rules match their order: the other blocks are left out of the email, not hidden inside it.
Add rules to a block
Open the template in the email editor and select the block.
In the block’s properties, find Visibility and set Show this block to Only when….
Choose a rule. The list starts with the ready-made rules for this email; choose Custom rule to test a field yourself.
To add another rule, select Add rule. With more than one rule, choose under Show when whether All rules match or Any rule matches.
Read the summary under the rules, which says in plain words when the block is shown, then save the template.
To show the block in every email again, set Show this block to Always. A block can have up to 5 rules. Rules on a container or a column layout apply to everything inside it: when it is hidden, so are its blocks. The email as a whole and the Tax details block have no Visibility setting, because an email that shows tax details must always show them.
Ready-made rules
Each ready-made rule is offered only in the emails whose data has what it checks.
Rule |
Shown when |
Offered in |
|---|---|---|
Paid by cash on delivery |
The customer pays for the order in cash on delivery. |
Every email about an order |
Paid in advance |
The order is not paid by cash on delivery. |
Every email about an order |
Order has a discount |
At least one discount applies to the order. |
Every email about an order |
Customer left a note |
The order has a note from the customer. |
Every email about an order |
Order has a shipping address |
The order has a shipping address. |
Every email about an order |
Order is picked up in store |
The customer collects the order from one of your locations. |
Every email about an order |
Has a tracking link |
The shipment has a tracking link. |
Shipment Sent, Out for Delivery, Shipment Delivered, Delivery Attempt Failed, Ready for Pickup and Picked Up |
Order needs shipping |
The order is not made up only of digital items or gift cards. |
Every email about an order |
Partial refund |
The refund gives back only part of the order. |
Order Cancelled and Refunded, Order Cancelled and Partially Refunded, Payment Refunded and Payment Partially Refunded |
A balance is due |
After the change, the customer has an amount left to pay. |
Order Updated |
Gift card has a message |
The sender wrote a message for the gift card. |
Gift Card Delivery and Gift Card Cancelled |
Customer has an account |
The customer has an account in your store. |
Every email with the customer’s details |
Your own rules
Custom rule tests one field of the email’s data. The fields are the ones this email has, the same as under Message values, grouped by what they belong to, such as the order or the customer. Fields of the single items of a list, dates, and links or codes that give access, such as a payment link or a gift card code, can’t be used. What you can compare depends on the field:
Field |
Comparisons |
Compare with |
|---|---|---|
Text and links |
is, is not, contains, is empty, is filled in |
Text you type, up to 500 characters. is, is not and contains match capital letters exactly. |
Numbers |
is more than, is less than, equals |
A number. |
Amounts |
is more than, is less than, equals, is empty, is filled in |
A number in the email’s currency, such as 50 or 49.99. The amount is compared as it is, without converting currencies. |
Yes or no |
Yes, No |
Nothing: Yes shows the block when the field is yes. |
Lists |
has none, has at least one |
Nothing. |
Groups of details, such as an address |
is empty, is filled in |
Nothing. |
A value the email doesn’t have counts as empty: is empty and is not match it, while contains, is more than, is less than and equals don’t. For a yes-or-no field, a missing value counts as No.
For example, to show a note on import duties only to customers who may owe them on delivery, choose Custom rule, the field Who pays import duties, the comparison is and the value pay_on_delivery. The other values are collect_at_checkout (the customer paid duties at checkout) and included_in_price (your prices include them).
All rules or any rule
With All rules match, the block is shown only when every rule holds. With Any rule matches, one is enough: Paid by cash on delivery or Order is picked up in store shows the block on cash on delivery orders and on pickup orders.
The eye icon on the canvas
On the editing canvas, a block with rules shows a crossed-out eye in its top-right corner. Point to it, or move to it with the Tab key, to read when the block is shown, for example Shown only when: Paid by cash on delivery. The canvas always shows every block so you can edit it; the preview shows which blocks a customer gets.
Check your rules
The preview shows the email as a customer gets it. Under Preview with, choose the sample data, such as All details, Minimal details, Cash on delivery, Paid in advance, Without a discount or Pickup in store, depending on the email, and switch between them to see blocks appear and disappear. A test email uses the All details sample: a delivery order paid by cash on delivery.
Rules are checked when you preview and when you save. A rule this email can’t check, such as one on a field it doesn’t have, is listed with the block’s issues: fix or remove it to save the template.
Rules in code
Converting a design to code keeps each block’s rules as a {% if %} … {% endif %} around the block. In code you write conditions yourself: see Write an email in code.