Variables and if/else in the checkout Text block
Show the buyer's delivery date, cart total or country in your checkout Text block, and pick what shows when a value is missing.
Last updated
Variables make your checkout Text block react to each buyer: show the delivery date they picked in the cart, a free shipping message once they spend enough, or a note for one country. The syntax is a small part of Shopify's Liquid, so it reads like your theme code.
{% if cart.attributes["Delivery date"] %}Delivery: {{ cart.attributes["Delivery date"] }}{% else %}Pick a delivery date in the cart.{% endif %}
A buyer who picked a date sees "Delivery: Saturday, December 5, 2026". Everyone else sees "Pick a delivery date in the cart."
Where variables work
Variables and tags work in the Headline, Text and Link text of any Text block, in all three styles (Plain, Card and Banner). The Link URL stays as you type it.
The text updates as the buyer's cart changes at checkout. The preview in the admin fills in example values: each cart attribute shows as its name in brackets (like [Delivery date]), the item count as 2, the cart total as 50.00 in your store currency and the country as US.
Variables
Write a variable inside double curly brackets, such as {{ cart.item_count }}.
| Variable | Shows |
|---|---|
cart.attributes["Any key"] | A cart attribute, such as a delivery date or gift message saved in the cart |
cart.attributes.key | The same, shorter, for names without spaces |
cart.note | The order note |
cart.item_count | The number of items in the cart, counting quantities |
cart.total_price | The cart subtotal in cents, in the buyer's currency, before order discounts. Use the money filter to show it as a price |
localization.country.iso_code | The buyer's country code, such as US or DE |
Attribute names must match exactly, including capital letters and spaces: cart.attributes["Delivery date"] and cart.attributes["delivery date"] are two different attributes. A name with a space needs the bracket form.
Values show exactly as they're saved in the cart. A delivery date saved in English shows in English in every checkout language.
Filters
Add a filter after a variable with |.
default: "text"shows the text when the value is missing:{{ cart.attributes["Gift message"] | default: "No gift message" }}moneyturns cents into a price in the buyer's currency:{{ cart.total_price | money }}shows "$50.00" for 5000.
You can chain them: {{ cart.total_price | default: 0 | money }}.
If, else and unless
Use {% if %} to show text only when a condition is true. Add {% elsif %} and {% else %} for other cases, and close with {% endif %}. {% unless %} ... {% endunless %} shows text when the condition is false. Tags can sit inside each other, and an if can wrap several lines of text.
| You write | True when |
|---|---|
{% if cart.note %} | The value is set |
== / != | Equal / not equal: localization.country.iso_code == "US" |
< > <= >= | Number comparisons: cart.item_count >= 3 |
contains | The text contains a word: cart.attributes["Delivery date"] contains "Saturday" |
and / or | Combine conditions: cart.item_count >= 2 and cart.total_price >= 5000 |
blank, empty, nil | Mean "no value": cart.note == blank is true when there's no note |
Put text in double or single quotes. To group conditions, use one if inside another instead of parentheses.
Missing values
A value that is empty or only spaces counts as missing, both in conditions and when it shows. A missing variable shows nothing, and the space it leaves behind is tidied up: Hey {{ cart.attributes.name }}! becomes "Hey!", not "Hey !".
If everything in the block ends up empty, the block hides for that buyer. To show something else instead, use {% else %} or the default filter.
Examples
Delivery date picked in the cart:
{% if cart.attributes["Delivery date"] %}Delivery: {{ cart.attributes["Delivery date"] }}{% else %}Pick a delivery date in the cart.{% endif %}
Free shipping over 50:
{% if cart.total_price >= 5000 %}Your order ships free.{% else %}Free shipping on orders over 50. Your subtotal is {{ cart.total_price | money }}.{% endif %}
Country-specific text:
{% if localization.country.iso_code == "US" %}Ships from our Texas warehouse in 1 to 2 days.{% elsif localization.country.iso_code == "CA" %}Ships to Canada in 3 to 5 days, duties included.{% else %}International orders ship within a week.{% endif %}
Bigger orders:
{% if cart.item_count >= 3 %}Thanks for stocking up! Your {{ cart.item_count }} items ship together.{% endif %}
Save checks
EliteCart checks your variables and tags when you click Save. If something is off, saving stops and the field shows what to fix, with the language name when it's a translation:
| Message | What to do |
|---|---|
| "Close the if tag." | Add the missing {% endif %} (or {% endunless %}). |
| "Remove the extra endif tag." | Remove the tag, or add the {% if %} it belongs to. |
| "Unknown variable: ..." | Check the spelling against the variables above. |
"Use cart.attributes["Delivery date"] for names with spaces." | Write the attribute name in brackets and quotes. |
| "Only the default and money filters are supported." | Remove the other filter. |
| "Check the condition in this tag." | Compare a variable with a value, like cart.item_count >= 2. |
AI translate keeps your variables and tags as they are and translates only the text around them.
Supported Liquid
The Text block supports the variables, filters and tags on this page. Loops, other filters, true / false and date formatting are not part of it; save the value in the cart in the format you want buyers to see.
Still stuck?
Chat with us and we'll help you get your cart live. Or email contact@elitecart.app.