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.
Cart variables
Section titled “Cart variables”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` }}Line item variables
Section titled “Line item variables”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) }}The line object
Section titled “The line object”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']}` : '' }}Other variables
Section titled “Other variables”| 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) }} todaytoMoney
Section titled “toMoney”toMoney(amount, currencyCode) formats a number as money in the customer’s currency, for example $12.50 or 12,50 €.
{{ toMoney(lineTotalAmount, currencyCode) }}Metafields
Section titled “Metafields”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>orline.variant.metafields.<namespace>.<key>. - For any line in the cart:
lines[0].product.metafields.<namespace>.<key>, where0is 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.
Variables that might be missing
Section titled “Variables that might be missing”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.
Thank you and order status pages
Section titled “Thank you and order status pages”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,selectedDeliveryOptionLowerEstimateandselectedDeliveryOptionUpperEstimate. linesandlineare different there.lineslists each item’stitle,quantityandsku. Under an item,linehas itstitle,variantTitle,quantity,total,sku,productType,vendorandattributes(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 asfirstName. See personal text. - Not available:
customer,price,compareAtPrice,cartCompareAtPrice,totalDiscountAmount,discountAllocationsAmount,selectedDeliveryOptionDescriptionandcheckoutNotes.
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.
Order ID and order number
Section titled “Order ID and order number”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 }}Changes from the old help center
Section titled “Changes from the old help center”If you used variables from our old help pages:
linesandcustomeronly contain metafields.linesdoesn’t have titles, prices, or quantities.customeronly contains thecheckout_buddy.fieldmetafield.- New:
discountAllocationsAmount,totalWeight,toMoney,line.attributes, andattributeson the thank you page.
