Print and email templates
Customise receipts, printouts and emails with HTML, Liquid and scripts.
Templates control what Smooth POS prints and emails. Print templates lay out receipts, labels and other printouts. Email templates hold the subject and body of emails you send, for example from a Glue job. Both are HTML with Liquid placeholders like {{ sale.receipt_number }}.
System templates and your own
- System templates are the ones Smooth POS gives you, like your receipt. They have a
system_type. You can edit them, and reset them to the default if you want to start again, but you can't delete them. - Your own templates have no
system_type. Create as many as you like and delete them when you're done.
Print templates
Find them under Admin → Print Templates.
A print template has two parts:
| Part | API field | What it does |
|---|---|---|
| Template | template | HTML with Liquid placeholders. |
| Script | script | Optional JavaScript that runs first and prepares the data, so the template can stay simple. |
What the template can use
When a template is rendered, the script and the template both see $ with:
$.default: the data being printed, already parsed into an object. (In a Glue job,$.defaultis a string you parse yourself; here it's done for you.)$.company: your company'sname,logo,currency,time_zone,address,barcode_prefix,product_formatanditem_format.
Anything the script sets on $ is available to the template. For example:
$.sale = $.default;
$.item_count = $.sale.lines.reduce(function (n, l) { return n + l.quantity; }, 0);<h1>{{ company.name }}</h1>
<p>Receipt {{ sale.receipt_number }}</p>
<p>{{ item_count }} items</p>
{% for line in sale.lines %}
<div>{{ line.quantity }} x {{ line.barcode }}: {{ line.item_price }}</div>
{% endfor %}Set values on $ in the script rather than returning something.
Test a template
Render a print template with POST /printtemplate/{id}/render.json. Send the data to print as the body (it becomes $.default) and you get the finished HTML back:
{"html": "<h1>Smooth Retail</h1><p>Receipt 10023</p>..."}If something's wrong you get script error or template error, with the details in err.
Manage print templates through the API
- List print templates and Get a print template
- Create a print template and Update a print template
- Reset a print template puts a system template back to the default. It changes data even though it's a
GET.
Printing receiptsReceipts print on Epson receipt printers on your network. We recommend the Epson TM-m30III. See Hardware requirements and Epson TM-m30 Printer.
Email templates
Find them under Admin → Email Templates.
| Field | API field |
|---|---|
| Name | name |
| Subject | subject |
| From name | from_name |
| Reply-to | reply_to |
| Body | template |
Use an email template from Glue
In a Glue job's Email step, choose the template under Template instead of Custom. The step takes the subject, body, from name and reply-to from the template, and renders them with Liquid against the job's variables. So if an earlier Script step sets $.customer, the template can use {{ customer.first_name }}. The step's To field still decides who gets it.
That keeps the wording in one place the team can edit, and the Glue job only has to gather the data.
Example: Email a receipt with your own template
Trigger: System Hook, sale_create.
-
Script: Read the sale
var sale = JSON.parse($.default); $.sale = sale; $.customer_id = sale.customer_id; $.has_customer = sale.customer_id > 0; -
If Condition: If there's a customer, Condition
$.has_customer === true. Under THEN:-
API Request: Get a customer for customer
{{ customer_id }}, Response variablecustomer_res. -
Script: Read the customer
$.customer = JSON.parse($.customer_res.body); $.has_email = !!$.customer.email; -
If Condition: If the customer has an email, Condition
$.has_email === true. -
Email: Send the receipt, nested under that THEN: To
{{ customer.email }}, Template: your receipt email template.
-
The template itself might say:
<p>Hi {{ customer.first_name }},</p>
<p>Thanks for shopping with us. Your receipt number is {{ sale.receipt_number }}.</p>Manage email templates through the API
- List email templates and Get an email template
- Create an email template and Update an email template
- Reset an email template puts a system template back to the default.
Send the whole template when you updateAn update saves every field from the body, so anything you leave out is blanked. For email templates that includes
system_type. Start from Get an email template (or Get a print template), change what you need, and send it all back.
Updated about 22 hours ago
