Skip to main content
Operators are used in the template language to access values, calculate values, compare content, or combine conditions. They are a fundamental part of many template expressions, for example in outputs, conditions, or when working with lists and maps. Unlike functions, operators are not written as a call with parentheses but are used directly within an expression. The existing operators reference covers access, mathematical, comparison, logical, and the containment operator in in particular.

Basics

Notation

Operators are used directly within an expression. They can occur in an output as well as in a variable assignment or a condition. To output the result of an expression directly in the template, the output notation is used:
{{= <expression> }}
An expression can also first be assigned to its own variable to be reused later:
{{ var $myVariable = <expression> }}
The existing reference pages already show exactly this pattern for function calls, variables, and operator expressions.

Operators in outputs and conditions

Operators are particularly often used in these situations:
  • when accessing values in maps or lists
  • in calculations
  • in comparisons in if conditions
  • when linking multiple conditions
  • when checking whether a value is contained in a list or map
Examples:
{{= $myProduct.name }}
{{= $myPrice * $quantity }}
{{= $myProductStock > 0 }}
{{= $myPrice > 10 and $myProductStock > 0 }}
{{= "red" in $myAvailableColors }}
The operators page already documents . and [] for access, mathematical operators, comparison operators, logical operators, and in.

Order and parentheses

As soon as multiple operators are combined in an expression, parentheses should be used to make the desired order unambiguous. This not only increases readability but also prevents misunderstandings in more complex conditions. Example: {{= ($myPrice > 0 and $stock > 0) or $myIsBackorderAllowed }} Recommendation:
  • Simple expressions can be written directly.
  • For mixed comparisons and logical connections, parentheses should be used.
  • Especially with and, or, and not, a clear structure is important.

List of operators

Dot operator .

The dot operator is used to access an attribute of a map. The existing operators page describes the dot operator as standard access to attributes of an object and also shows that it does not work with list indices. Usage example
Typical examples are accessing product data, customer data, or other structured values.
Notation
{{= $myMap.key }}
Example – output product name
{{= $myProduct.name }}
Example – output shipping country from an order address
{{= $order.shippingAddress.country }}
Note: the dot operator is not suitable for numeric list indices. Example – does not work with a list
{{ var $myList = [4, 3, 2, 1] }}
{{= $myList.2 }}
Output
No output

Index operator []

The index operator is used to access values in lists or maps. With maps, the key is specified in square brackets. With lists, the numeric index is used. According to the existing documentation, a variable can also be used in the index operator. Usage example
Useful for dynamic keys or for accessing a specific list element.
Notation
{{= $myObject["key"] }}
{{= $myList[0] }}
Example – access a field in a map
{{= $myProduct["price"] }}
Example – output the first element of a list
{{ var $myList = [4, 3, 2, 1] }}
{{= $myList[0] }}
Output
4
Example – use a dynamic key
{{ var $fieldName = "price" }}
{{= $myProduct[$fieldName] }}
Note: list indices start at 0.

Addition operator +

The operator + is used to add numeric values. The current functions page additionally documents that + can also be used to concatenate strings as well as merge lists. This contradicts the older operators page; this draft therefore follows the newer functions page. Usage example
Can be used for calculations, but also for composing texts or merging lists.
Notation
{{= value1 + value2 }}
Example – add two numbers
{{= 10 + 1 }}
Output
11
Example – compose article number from prefix and ID
{{ var $prefix = "ART-" }}
{{ var $productId = "10452" }}
{{= $prefix + $productId }}
Output
ART-10452
Example – insert number into text
{{ var $quantity = 3 }}
{{= "Number of items in the basket: " + str($quantity) }}
Example – merge two lists
{{ var $listA = ["red", "green"] }}
{{ var $listB = ["blue"] }}
{{= $listA + $listB | json }}
Note: when concatenating texts, non-string values may need to be converted to a string first using str().

Subtraction operator -

The operator - subtracts one value from another. The operators page documents - as one of the basic mathematical operators. Usage example
Useful for price differences, discounts, or remaining quantities.
Notation
{{= value1 - value2 }}
Example – calculate price reduction
{{ var $regularPrice = 99.95 }}
{{ var $salePrice = 79.95 }}
{{= $regularPrice - $salePrice }}
Output
20
Example – calculate remaining stock after deduction
{{ var $stock = 15 }}
{{ var $reserved = 4 }}
{{= $stock - $reserved }}
Output
11

Multiplication operator *

The operator * multiplies two numeric values. It is part of the mathematical operators documented on the operators page. Usage example
Typical for quantity and price calculations.
Notation
{{= value1 * value2 }}
Example – calculate subtotal
{{ var $unitPrice = 19.99 }}
{{ var $quantity = 3 }}
{{= $unitPrice * $quantity }}
Example – calculate packaging units
{{ var $boxes = 4 }}
{{ var $itemsPerBox = 6 }}
{{= $boxes * $itemsPerBox }}
Output
24

Division operator /

The operator / divides one numeric value by another numeric value. This operator is also documented in the existing math overview. Usage example
Helpful for averages, ratios, or conversions.
Notation
{{= value1 / value2 }}
Example – calculate average price
{{ var $sum = 90 }}
{{ var $count = 3 }}
{{= $sum / $count }}
Output
30
Example – calculate a partial quantity
{{= 7.5 / 3 }}
Output
2.5
Note
For divisions, you should ensure that the divisor is not 0.

Modulo operator %

The modulo operator % returns the remainder of a division. The operators page expressly names % as the modulo operator. Usage example
Useful for checking even and odd values or implementing grid logic in lists.
Notation
{{= value1 % value2 }}
Example – check whether a number is even
{{= 8 % 2 == 0 }}
Output
true
Example – mark every third element in a list
{{ if $loop.index % 3 == 0 }}
  <div class="teaser-row-break"></div>
{{ /if }}

Equality operator ==

The operator == checks whether two values are equal. According to the existing reference, comparison operators always return a boolean value, i.e., true or false. Usage example
Can be used for status checks, country checks, or template logic.
Notation
{{= value1 == value2 }}
Example – check country
{{= $countryCode == "DE" }}
Example – compare price with maximum value
{{ var $maxPrice = 10.00 }}
{{ var $price = 10.00 }}
{{= $price == $maxPrice }}
Output
true

Inequality operator !=

The operator != checks whether two values are unequal. It also belongs to the comparison operators documented on the operators page. Usage example
Useful when a value explicitly must not correspond to a certain state.
Notation
{{= value1 != value2 }}
Example – only display when a customer is not blocked
{{= $customer.status != "blocked" }}

Less than <

The operator < checks whether the left value is less than the right value. According to the current operators page, comparison operators are intended for such value comparisons. Example – check price limit
{{= $price < 50 }}

Greater than >

The operator > checks whether the left value is greater than the right value. Example – check minimum order value
{{= $cartTotal > 100 }}

Less than or equal <=

The operator <= checks whether a value is less than or equal to another value. Example – check stock
{{= $score >= 80 }}

Greater than or equal >=

The operator >= checks whether a value is greater than or equal to another value. Example – check minimum age or threshold
{{= $score >= 80 }}

Logical and

The operator and links two conditions. The result is only true if both conditions are met. Exactly this behavior is described with examples on the operators page. Usage example
Useful when multiple prerequisites must be met at the same time.
Notation
{{= condition1 and condition2 }}
Example – only display the product if the price is valid and stock is available
{{= $price > 0 and $inventory > 0 }}
Example – buy button only for active products with stock
{{ if $product.active and $product.stock > 0 }}
  <button>Add to basket</button>
{{ /if }}

Logical or

The operator or links two conditions. The result is true if at least one of the conditions is met. According to the existing reference, or belongs to the logical operators. Usage example
Suitable for alternative approvals or special cases.
Notation
{{= $inventory > 0 or $allowPreorder }}
Example – display the product if stock is available or pre-order is allowed
{{= $inventory > 0 or $allowPreorder }}

Logical not

The operator not reverses the truth value of an expression. not is also part of the logical operators documented on the operators page. Usage example
Helpful when checking that a condition is not met.
Notation
{{= not condition }}
Example – only display when the user is not logged in
{{ if not $isLoggedIn }}
  <a href="/login">Log in now</a>
{{ /if }}
Example – display a message when no stock is available
{{ if not ($inventory > 0) }}
  <p>Currently not available</p>
{{ /if }}

Containment operator in

The operator in checks whether the left value is contained in the right object. The existing operators page expressly documents in as a containment operator and shows 1 in [1, 2, 3] as an example. Usage example
Useful for country lists, allowed values, color selections, or whitelists.
Notation
{{= value in collection }}
Example – check whether a color is available
{{= "red" in ["red", "green", "blue"] }}
Output
true
Example – check country against allowed country list
{{ var $allowedCountries = ["DE", "AT", "CH"] }}
{{= $countryCode in $allowedCountries }}