Liquid Examples

Capitilization of names

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

Display tax in receipt

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

Replace commas in currency

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

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 %}
Cheers,
{{merchant_name}}

Specify text based on 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

{% 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:

<https://example.com/my_page> 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.

[1]: http://www.example.com

Math Operators