Customize Emails with Liquid Examples
Last updated on Sep 19, 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.
Capitalize a subscriber's name
{{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 }}Display tax on a receipt
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 }}Swap the thousands separator
{{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:',','.' }}Display only the last 4 digits of a card
{{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.
Vary text by payment method
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 or prepaid, though never alongside invoice on the same site. Sites using invoice-centric billing can see automatic, remittance, or prepaid; sites that don't use it can see automatic or invoice instead. Add a branch for whichever of these your site actually uses, or the else case will catch those subscribers.
Vary text by product
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 %}Link to a URL
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.comRelated information
For the full list of variables you can use in these snippets, see the Customize Email Templates help article.
For 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.
