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:

PartAPI fieldWhat it does
TemplatetemplateHTML with Liquid placeholders.
ScriptscriptOptional 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, $.default is a string you parse yourself; here it's done for you.)
  • $.company: your company's name, logo, currency, time_zone, address, barcode_prefix, product_format and item_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

👍

Printing receipts

Receipts 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.

FieldAPI field
Namename
Subjectsubject
From namefrom_name
Reply-toreply_to
Bodytemplate

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.

  1. Script: Read the sale

    var sale = JSON.parse($.default);
    $.sale = sale;
    $.customer_id = sale.customer_id;
    $.has_customer = sale.customer_id > 0;
  2. If Condition: If there's a customer, Condition $.has_customer === true. Under THEN:

    1. API Request: Get a customer for customer {{ customer_id }}, Response variable customer_res.

    2. Script: Read the customer

      $.customer = JSON.parse($.customer_res.body);
      $.has_email = !!$.customer.email;
    3. If Condition: If the customer has an email, Condition $.has_email === true.

    4. 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

🚧

Send the whole template when you update

An 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.


Did this page help you?