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: https://shopify.dev/docs/api/liquid/objects/metafield#metafield-access-metafields.

{{ 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 -%}
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" }}

Show recurring total for a line item

If you need to show the recurring total for a subscription line item before one-time discounts, you can use the line_level_total_discount value. Note: This only works on a line item content block.

{%- if line_item.line_level_total_discount > 0 and line_item.has_selling_plan -%}
Recurring total: {{ line_item.line_price | plus: line_item.line_level_total_discount | money }}
{%- endif -%}

Supported Liquid variables

The following list includes all supported Liquid variables that can be included within a Dynamic content block or Line item content block. Some variables are only accessible on certain pages of checkout and are denoted as such. Other variables may only be included in specific block types and are denoted as such. Refer to Shopify's Liquid documentation for specifics on each variable.

Checkout

  • checkout.attributes
  • checkout.currency
  • checkout.has_selling_plan
  • checkout.item_count
  • checkout.line_items_subtotal_price
  • checkout.locale
  • checkout.market
  • checkout.metafields
  • checkout.note
  • checkout.requires_shipping
  • checkout.shipping_price
  • checkout.tax_price
  • checkout.total_price

Customer

  • customer.id
  • customer.b2b
  • customer.full_name
  • customer.first_name
  • customer.last_name
  • customer.email
  • customer.phone

Localization

  • localization.market

localization.market

  • localization.market.id
  • localization.market.handle

Order

Order variables are only accessible on the order status page.

  • order.id
  • order.legacyResourceId
  • order.name

Shop

  • shop.name
  • shop.url

Line item

The following line item variables are only accessible within a Line Item Content block.

line_item

  • line_item.attributes
  • line_item.gift_card
  • line_item.has_selling_plan
  • line_item.line_price
  • line_item.line_level_discount_allocations
  • line_item.line_level_total_discount
  • line_item.options_with_values
  • line_item.price
  • line_item.product
  • line_item.quantity
  • line_item.requires_shipping
  • line_item.sku
  • line_item.subtitle
  • line_item.title
  • line_item.trigger
  • line_item.type
  • line_item.variant
  • line_item.variant_id
  • line_item.vendor

line_item.product

  • line_item.product.is_gift_card
  • line_item.product.product_type
  • line_item.product.requires_selling_plan
  • line_item.product.tags
  • line_item.product.vendor

line_item.variant

  • line_item.variant.available_for_sale
  • line_item.variant.barcode
  • line_item.variant.compare_at_price
  • line_item.variant.id
  • line_item.variant.price
  • line_item.variant.requires_shipping
  • line_item.variant.sku
  • line_item.variant.title
  • line_item.variant.unit_price
  • line_item.variant.weight
  • line_item.variant.weight_unit

line_item.variant.price

  • line_item.variant.price.amount
  • line_item.variant.price.currency_code