Skip to content

Variables

Variables go inside double curly brackets. You can use them on their own or in a calculation:

Your total is {{ toMoney(orderTotal, currencyCode) }}

Numbers print as plain numbers (49.5, not $49.50), so wrap money in toMoney. Variable names are case-sensitive.

Available in the body text of most blocks: Text, Banner, Trust badges, Icons with text, FAQ, Contact info, Feature highlights, older Product offers, Discount buttons, older Checkbox product offer, Progress bar (cart totals), and checkbox and radio labels. The Progress bar (cart totals) doesn’t have the delivery variables or checkoutNotes. Line item text only has currencyCode from this table, and Progress bar (cart weight) has none of them. Product offers made with the new editor use their own tokens instead.

Variable Type What it contains
orderTotal number The checkout total, including shipping and tax once known
orderSubtotal number The subtotal of the products in the cart
currencyCode text The customer’s checkout currency, such as CAD
totalDiscountAmount number All discounts on the checkout: order, shipping, product, and codes
discountAllocationsAmount number Order-level and shipping discounts and codes, without product discounts
selectedDeliveryOptionDescription text The description of the chosen shipping method, if it has one
selectedDeliveryOptionLowerEstimate number The shortest delivery estimate for the chosen shipping method, in whole days
selectedDeliveryOptionUpperEstimate number The longest delivery estimate, in whole days
checkoutNotes text The order note the customer wrote
lines list One entry per cart line, holding its product and variant metafields. See metafields.
{{ orderSubtotal >= 75 ? 'Free shipping unlocked' : `Spend ${toMoney(75 - orderSubtotal, currencyCode)} more for free shipping` }}

These describe one line in the cart. They only have values when the block is placed under each line item in the Checkout Editor, and only in Text, Trust badges, Banner, and Line item text blocks.

Variable Type What it contains
lineQuantity number The line’s quantity
lineTotalAmount number The line’s total: price × quantity, after line discounts
price number The variant’s unit price
compareAtPrice number The variant’s unit compare-at price, if it has one
variantSku text The variant’s SKU
line object The line’s properties and metafields. See below.

price, compareAtPrice and variantSku are only loaded in Text, Banner, and Line item text blocks.

You save {{ toMoney((compareAtPrice - price) * lineQuantity, currencyCode) }}
line = {
attributes: { 'Engraving': 'For Sam', _buddy_data: '…' }, // line item properties
product: { metafields: { custom: { material: 'Organic cotton' } } },
variant: { metafields: { custom: { fit: 'Relaxed' } } },
}

Read a line item property with square brackets when the name has spaces:

{{ line.attributes['Engraving'] ? `Engraving: ${line.attributes['Engraving']}` : '' }}
Variable Type Where What it contains
cartCompareAtPrice number Text, Banner, Line item text The cart’s value at compare-at prices (price where there’s no compare-at price), times quantity
customer object Text, Banner, Line item text The logged-in customer’s checkout_buddy.field metafield, as customer.metafields.checkout_buddy.field
totalWeight number Progress bar (cart weight) only The cart’s weight in kilograms, to two decimals

Total savings across the cart:

You're saving {{ toMoney(cartCompareAtPrice - orderSubtotal, currencyCode) }} today

toMoney(amount, currencyCode) formats a number as money in the customer’s currency, for example $12.50 or 12,50 €.

{{ toMoney(lineTotalAmount, currencyCode) }}

Text, Banner, and Line item text blocks can show product and variant metafields.

  • For the line a block sits under: line.product.metafields.<namespace>.<key> or line.variant.metafields.<namespace>.<key>.
  • For any line in the cart: lines[0].product.metafields.<namespace>.<key>, where 0 is the first line. Not available in Line item text.
{{ line?.product?.metafields?.custom?.care_instructions }}

Things to know:

  • Put a namespace or key with a hyphen in brackets: line.product.metafields.custom["size-chart"].
  • Values are the raw metafield value. A list or JSON metafield prints as text; a money metafield prints as JSON.
  • The metafield must have a definition with Storefront API access turned on in Settings → Custom data.
  • The ?. stops the expression failing before the metafield has loaded or when the block isn’t under a line item.

A variable that doesn’t apply prints as nothing, which is usually what you want: variantSku when the variant has no SKU, or checkoutNotes when there’s no note.

Checkout blocks you placed on the thank you and order status pages show as thank you page blocks, so their text reads the order instead of the cart:

  • Kept from checkout: orderTotal, orderSubtotal, currencyCode, toMoney, lineQuantity, lineTotalAmount, variantSku, selectedDeliveryOptionLowerEstimate and selectedDeliveryOptionUpperEstimate.
  • lines and line are different there. lines lists each item’s title, quantity and sku. Under an item, line has its title, variantTitle, quantity, total, sku, productType, vendor and attributes (its line item properties). Neither has product or variant metafields.
  • Added: the order variables below, attributes (the order’s cart attributes), and the thank you page’s own values, such as firstName. See personal text.
  • Not available: customer, price, compareAtPrice, cartCompareAtPrice, totalDiscountAmount, discountAllocationsAmount, selectedDeliveryOptionDescription and checkoutNotes.

attributes is the way to show what a customer typed into a form field:

Delivery date: {{ attributes?.['Delivery date'] }}

Use ?. with attributes, because it’s empty when the order has no attributes.

These only work on the thank you and order status pages. Checkout has no order yet.

Variable Thank you page Order status page What it contains
orderId Yes Yes The order’s ID, the number at the end of the order’s address in Shopify admin, such as 6123456789012
orderNumber The confirmation code Yes The order number customers see, such as #1001
confirmationNumber Yes Yes The order’s confirmation code, such as XK4P9QZ2M. Orders placed before 2024 might not have one.

The thank you page can’t show the order number. Shopify gives apps the order ID and confirmation code there, but not the order number, so on the thank you page orderNumber is the confirmation code. Customers still see the order number on the order status page and in their order confirmation email.

The same text works on both pages. This shows #1001 on the order status page and the confirmation code on the thank you page:

Your order: {{ orderNumber }}

If you used variables from our old help pages:

  • lines and customer only contain metafields. lines doesn’t have titles, prices, or quantities.
  • customer only contains the checkout_buddy.field metafield.
  • New: discountAllocationsAmount, totalWeight, toMoney, line.attributes, and attributes on the thank you page.