Loading article…
Loading article…
Last updated on Aug 22, 2026
Liquid lets an email template do more than drop a value into a sentence. It can branch on the product a subscriber bought, reformat a number, or reshape a name. The snippets below are worked examples of the patterns that come up most often, ready to adapt for your own templates.
WARNING: These snippets are provided as a reference and as-is. Test any snippet you adopt across the subscription lifecycle before it reaches real subscribers. You're responsible for making the code work for your own subscriptions and for maintaining it afterward, including any modifications you make.
For the full list of variables you can use in these snippets, see the Customize Email Templates help article.
{{name}} returns the subscriber's first name only, so there's no need to include it separately in the body. This snippet normalizes the capitalization of whatever it returns.
{% assign nameparts = name | split: ' ' %}
{% capture titlecase %}{% for word in nameparts %}{{ word | downcase | capitalize }}{% endfor %}{% endcapture %}{{ titlecase }}Subtract the product price from the amount actually paid, then convert the result from cents to your currency's main unit.
{{payment.amount_in_cents | minus: product.price_in_cents | times: 0.01 }}{{payment.amount}} returns a formatted amount such as $1,234.56. This snippet replaces the comma with a period, giving $1.234.56, for locales that group thousands that way. It doesn't change the decimal separator.
{{ payment.amount | replace:',','.' }}{{payment_profile.masked_card_number}} returns the full mask, XXXX-XXXX-XXXX-1234. Removing the padding characters and the hyphens leaves just 1234.
{{ payment_profile.masked_card_number | remove: "X" | remove: "-" }}Important: Removing only the
Xcharacters leaves the hyphens in place, which renders as---1234. Both filters are needed.
Send different wording to automatic-pay subscribers than to invoiced ones. This works well in receipts.
Dear {{name}}
[Your email content here.]
{% if subscription.payment_collection_method == "automatic" %}
Text for automatic-based subscriber.
{% elsif subscription.payment_collection_method == "invoice" %}
Text for invoice-based subscriber.
{% endif %}
Cheers,
{{merchant_name}}payment_collection_method can also return remittance. Add a branch for it if your site uses remittance, or the else case will catch those subscribers.
Single out one product and give everyone else the same wording:
{% if product.handle =="REPLACE" %}
Your content based on the above product handle
{% else %}
[The content you would like to send other subscribers not purchasing the product handle specified above]
{% endif %}Give several products their own wording:
{% if product.handle =="REPLACE" %}
Your content based on the above product handle
{% elsif product.handle =="OTHER_HANDLE" %}
Your content based on the above product handle
{% elsif product.handle =="ANOTHER_HANDLE" %}
Your content based on the above product handle
{% else %}
[The content you would like to send other subscribers not purchasing the product handle specified above]
{% endif %}Give a group of products the same wording, by testing several handles in one condition:
{% if product.handle == "[REPLACE_WITH_product_handle]" or product.handle == "[REPLACE_WITH_product_handle]" or product.handle == "[REPLACE_WITH_product_handle]" %}
Here is the text your subscriber sees if they purchased any of the products above.
{% endif %}Surround the address with angle brackets to turn it into a link.
<https://example.com/my_page> or <{{subscription.billing_portal_management_url}}>To attach a link to specific words instead, use a Markdown reference link. Put the label in the sentence and the address on its own line:
To speak with one of our experts, [click here][1].
[1]: http://www.example.comFor a general introduction to the language, see Shopify's Liquid syntax introduction.
For the full list of filters, including the math operators used above, see Shopify's Liquid filter reference.
Still need help?
Reach out and our support team will take it from here.