Liquid Examples

The following collection of liquid syntax is provided as a reference, and is provided as-is. We encourage you to test the liquid syntax throughout the subscription lifecycle. You are responsible for ensuring the code works for your subscriptions, as well as maintaining this syntax code for the future. Any modifications you make to this code, or modifications you make to code in similar sections, are your responsibility.

Capitilization of names

In the following snippet, there is no need to include {{name}} in the body of the email. The snippet below will pull in the first name only of the subscriber.

{% assign nameparts = name | split: ' ' %}
{% capture titlecase %}{% for word in nameparts %}{{ word | downcase | capitalize }}{% endfor %}{% endcapture %}{{ titlecase }}

Display tax in receipt

Display tax in your receipts by subtracting the product price from the payment amount in an email.

{{payment.amount_in_cents | minus: product.price_in_cents | times: 0.001 }}

Replace commas in currency

Swap out commas for periods when needed in international currency usage/

{{ payment.amount | replace:',','.' }}

Display last 4 digits of a credit card

This syntax will display just the last 4 digits of a card, 1234, versus the full masked number, XXXX-XXXX-XXXX-1234

{{ payment_profile.masked_card_number | remove: "X"}}

Specify text based on subscription payment method

This example specifies a set of text to be delivered to a subscriber if they are on an automatic-based payment method, versus an invoice-based payment method. We find this is a great example to be used 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 %}

Specify text based on product

Specify the correct text for your subscribers to receive based on the product.

{% if product.handle =="[REPLACE_WITH_product_handle]" %}

Here is the text that your subscriber should see if they purchase this product with the above and below syntax.

{% endif %}

Specify text based on multiple products

Use the following snippet if you have multiple products and would like to customize the message for each particular product.

{% if product.handle == "[REPLACE_WITH_product_handle]" or product.handle == "[REPLACE_WITH_product_handle]" or product.handle == "[REPLACE_WITH_product_handle]" or  product.handle =="[REPLACE_WITH_product_handle]" %}

Here is the text that your subscriber should see if they purchase any of the above products. Be sure to end the if statement below this line.

{% endif %}

To link to a url, surround the text with angle brackets:

<> or <{{subscription.billing_portal_management_url}}>

If you would like to locate our website, please click [here][1] to speak with one of our experts.