Liquid in Shopify's checkout

Checkout Blocks supports leveraging Liquid syntax across many of our blocks in order to facilitate complex personalization use cases.

Common liquid snippets

Checkout metafields

Easily surface custom fields saved to checkout on the thank you & order status page by referencing the checkout metafields. Learn more:

{{ checkout.metafields.checkoutblocks.vat.value }}

Replace checkoutblocks with your namespace and vat with your custom field key as defined on the block.

Product tags

Conditionally show line item content based on the product tags.

{%- if line_item.product.tags contains 'final-sale' -%}
Final sale
{%- endif -%}

Line Item Attributes (Properties)

Iterate over line item attributes (properties) and surface information such as delivery estimates, preorders, and more.

{%- assign first_line_attribute = line_item.attributes | first  -%}
{%- assign first_attribute_value =  first_line_attribute.value | json_parse  -%}
{%- assign message =  first_attribute_value.message -%}
{%- if message -%}
  {{ message }}
{%- endif -%}

Check if checkout is B2B

Conditionally show content if the checkout instance is B2B.

{%- if customer.b2b -%}
{%- endif -%}

Parse JSON

Checkout Blocks supports parsing JSON values such as from line item attributes (properties) or metafields.

{%- assign complex_json = checkout.metafields.checkoutblocks.complex | json -%}

Format currency

Checkout Blocks fully supports multi-currency checkout. Simply pass the money filter to parse and format money using the active currency format. Note this does not automatically convert the currency.

{{ checkout.total_price | money }}

Conditionally show the compare at price

You can conditionally show a line item's compare at price using this simple snippet.

{%- if line_item.variant.compare_at_price.amount -%}
On sale. Originally {{ line_item.variant.compare_at_price.amount | times: line_item.quantity | money }}
{%- endif -%}

Cart note

If you need to show the value of the cart note (such as what was entered on the cart):

{{ checkout.note }}

Cart attributes

If you need to show the value of a particular cart attribute such as a delivery date, you can use this snippet. Just change the key Delivery date to match your own.

{% assign delivery_date = '' %}
{% for attribute in checkout.attributes %}
  {% if attribute.key == 'Delivery date' %}
    {% assign delivery_date = attribute.value %}
  {% endif %}
{% endfor %}

Delivery Date: {{ delivery_date }}

Show entire checkout Liquid contents

If you need to see what values exist on the checkout object, you can using JSON filter to serialize. This should only be used for debug purposes.

{{ checkout | json }}

Show the "metafield trigger" value

This is only available to line item content blocks at this time. The following code will contain the value of the trigger.

{{ line_item.trigger }}

Format a date

In this example, we create a date 4 days in the future (432000 seconds) and then format it. Learn how to format dates in Liquid.
For example, 02/24/2025:

{% assign future_date = "now" | date: "%s" | plus: 432000 %}
{{ future_date | date: "%m/%d/%Y" }}

Alternatively, you can format the date like Feb 24, 2025

{% assign future_date = "now" | date: "%s" | plus: 432000 %}
{{ future_date | date: "%b %d, %Y" }}