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, Upsell / Cross sell, Discount buttons, 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.

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.

In subheadings, totalDiscountAmount, discountAllocationsAmount, checkoutNotes and lines aren’t available.

{{ 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 ? line.product.metafields.custom.care_instructions : '' }}

Things to know:

  • Write the full path without ?. at least once. Checkout Buddy decides which metafields to load by looking for product.metafields.<namespace>.<key> or variant.metafields.<namespace>.<key> inside {{ }}. If you only write line?.product?.metafields?.custom?.badge, the metafield is never loaded and prints nothing. Use the pattern above: check with ?., then output the full path.
  • One metafield per line of text. Put each metafield expression on its own line in the field.
  • Namespaces and keys can only contain letters, numbers, and underscores. Metafields with a hyphen in the namespace or key can’t be read.
  • 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 ?. check before the ? stops the expression failing, and hiding the block, 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. Two exceptions:

  • variantSku prints the word undefined when the variant has no SKU. Check for it: {{ variantSku && variantSku !== 'undefined' ? variantSku : '' }}.
  • checkoutNotes prints undefined in fields that can’t read the note.

Blocks on the thank you and order status pages have a smaller set: orderTotal, orderSubtotal, currencyCode, lineQuantity, lineTotalAmount, variantSku, the three delivery variables, lines and line.

They also have one variable checkout doesn’t: attributes, the order’s cart attributes. It’s the way to show what a customer typed into a form field:

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

toMoney, customer, price, compareAtPrice, cartCompareAtPrice, totalDiscountAmount, discountAllocationsAmount and checkoutNotes aren’t available in body text there. Use ?. with attributes, because it’s empty when the order has no attributes. Line item text on those pages has toMoney.

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.