Guide: Liquid in Shopify's checkout

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

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 | money }}

{%- endif -%}

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us