$wsAccount or $wsExternalData) are documented in the respective module reference.
Many functions can alternatively also be used as modifiers (filters).
Basics
Functions are called with parentheses. Values passed to a function (so-called parameters) are separated by commas. Function names are case-sensitive (capitalization must be observed exactly).Notation
To output the result of a function in the template, the output notation is used:Parameter passing and order
By default, parameters are passed positionally (in the order of the signature). If the order of the parameters is to be changed, named parameters must be used (name per signature +=). The parameter names are then decisive, not the position.
Example
A voucher is to be renamed via the replace function. GUTSCHEIN_buy10 should become GUTSCHEIN_sale10.
The signature is: replace(content, search, replace). With positional passing, the order is therefore:
name="..."), the order is free:
Combining functions (chained processing)
Multiple functions can also be applied in sequence by using the first function as the argument of the second function. Example The shipping cost ID “versand_kostenfrei” should be renamed in a more readable way to “VERSAND KOSTENFREI” and the writing changed to uppercase. The functionsupper and replace are used:
Joining text and lists
With the+ operator, two texts (strings) can be directly joined into a new string. For lists, + can be used as an alternative to merge() to combine two listings.
Only values of the same type can be joined with +. Numbers or other types must first be converted to text using the str() function.
ExamplesCompose article number from prefix and ID:
str() before being joined with a string.
List of functions
abs
Theabs function returns the absolute value of a number — i.e., the value without a sign. A negative number is thereby made positive; a positive number remains unchanged.
Usage exampleUseful, for example, to always display discount amounts or price differences in the shop as a positive number — regardless of whether the value has a minus sign in the data. Signature
abs(value)
Parameters
value- The number whose absolute value is to be determined.
yes Example with a negative value
The current price of a product is stored in the
price field (here: 79.95), the original price in the setOrgPrice field (here: 99.95). The difference between the two can turn out negative depending on the calculation direction. With abs, it is ensured that the displayed amount is always positive.
ceil
Theceil function always rounds a number up to the next whole number — no matter how small the decimal portion is. So ceil(1.1) results in 2, just like ceil(1.9).
Usage exampleHelpful when values in the shop should always be rounded up “in favor of” a whole unit — e.g., quantities, packaging units, or calculated amounts. Signature
ceil(value)
Parameters
value– The number to be rounded up.
yes Example with a decimal number
To adjust the display of decimal places, use
ceil(2) | preparedFormat("name")Example - round up the calculated product weight
The shipping weight of a product (in this case 2.3 kg) is rounded up to full kilograms.
floor
currency
Thecurrency function formats a numeric value as a price according to the shop currency settings. This includes in particular:
- Decimal separator (e.g.,
,instead of.) - Number of decimal places (e.g., 2 in many currencies)
- Commercial rounding to the configured number of decimal places
Suitable for outputting amounts such as unit prices, discounts, subtotals, and totals. Signature
currency(price)
Parameters
price- The number to be formatted as a price.
yes Example with decimal places
If a numeric value should be output in a specific format independently of the currency (e.g., with a different number of decimal places), preparedFormat() is the appropriate function.
The price of a product is stored as a decimal number (here:
89.95). With currency, it is formatted according to the shop settings.
Output
dateFmt
ThedateFmt function brings a date or point in time into a desired display format. The input value must be in ISO 8601 format (e.g., 2018-03-11T11:20:11.000Z) — this format is used automatically by most systems.
Usage exampleWith this, e.g., order dates, delivery dates, or campaign periods can be displayed readably in the shop (e.g., as “11.03.2018” or “11:20:11”). Signature
dateFmt(isoDate, fmt)
Parameters
isoDate– Date/time in ISO 8601 format (e.g.,2018-03-11T11:20:11.000Z)fmt– Format specification that determines what the output should look like- The most important placeholders at a glance
%d= day (01–31)%m= month (01–12)%Y= year (4-digit)%H= hour (00–23)%M= minute (00–59)%S= second (00–60)
- You can use this to simply “assemble” the following formats, e.g.:
"%d.%m.%Y"→11.03.2018"%H:%M:%S"→11:20:11
- The most important placeholders at a glance
yes Example for outputting the order date from the “order time”
The order date in this example is stored in the following format —
2024-06-15T14:32:05.000Z. With dateFmt, it is converted into a readable date and a separate time for an order confirmation.
dateGreaterThan
ThedateGreaterThan function compares two date values (as strings) with each other and returns true if the first date is after the second date.
Usage exampleWith this, the template can, for example, check whether a delivery date is in the future or whether a period has already been exceeded. Signature
dateGreaterThan(firstDate, secondDate)
Parameters:
firstDate– First date (value to be checked)secondDate– Second date (comparison value)
yes Example of a date comparison
With
dateGreaterThan, you can check whether the order is after a fixed cut-off date — e.g., to consider only orders from 01.01.2025 onwards for a returns campaign.
dateLessThan
dateLessThan
ThedateLessThan function compares two date values (as strings) with each other and returns true if the first date is before the second date.
Usage exampleWith this, the template can, for example, check deadlines or periods — e.g., whether a date has already been exceeded or whether an event is still ahead. Signature
dateLessThan(firstDate, secondDate)
Parameters
firstDate– First date (value to be checked)secondDate– Second date (comparison value)
yes Example of a date comparison
With
dateLessThan, you can check whether the order is before a fixed cut-off date — e.g., to point out that the return period has already expired.
dateGreaterThan
decode
Thedecode function converts an encoded string back into its original plain text. Supported formats are base64 and hex. If the passed value is not a valid encoded string in the specified format, the function returns null.
Usage exampleUseful, for example, to decode externally encoded product data, voucher codes, or configuration values before further processing in the template. Signature
decode(content, format)
Parameters
content- The encoded string to be decoded.format- The encoding format to be used during decoding. Valid values:"base64","hex".
yes Example - decoding a Base64 string
encode
distinct
Thedistinct function removes duplicate entries from a listing and returns a new listing in which each value appears only once. For listings of data objects (maps), a key can optionally be specified by which the comparison is made. The specification of the key is only considered at the top level of a map.
Usage exampleUseful, for example, to remove duplicates from a list of product categories, variant attributes, or filter values before displaying them in the template. Signature
distinct(list[, key]
Parameters
list- The listing from which duplicates are to be removed.key (optional)- Key of a data object used for the comparison.
yes Example - removing duplicate size specifications from a variant list
encode
Theencode function encodes a string into a specified format. Supported formats are base64 and hex. The return value is always of type String.
Usage exampleUseful, for example, to safely encode voucher codes, product identifiers, or other values for passing to external services or in URLs. Signature
encode(content, format)
Parameters
content- The string to be encoded.format- The target format of the encoding. Valid values:"base64","hex".
yes Example - encoding as Base64
decode
floor
Thefloor function always rounds a number down to the next whole number — no matter how large the decimal portion is. So floor(4.9) results in 4, just like floor(4.1).
Usage exampleHelpful when values in the shop should generally be rounded down — e.g., for calculated quantities or intermediate results that may only be processed further as a whole number. Signature
floor(value)
Parameters
value– Numeric value to be rounded down.
yes Example with a decimal number
To adjust the display of decimal places, use
floor(4.9) | preparedFormat("name")The shipping weight of a product (in this case 2.7 kg) is rounded down to full kilograms.
ceil
ifnull
Theifnull function checks whether a value is present or not (null means: “no value present”). If the value is null, a replacement value is output instead. If a value is present, it is used itself.
Usage exampleSuitable, for example, for fallback logic in the shop — e.g., to display a replacement image if no product image is present, or to replace missing product data with default values. Signature
ifnull(object, value)
Parameters
object- The value to be checked.value- The alternative value that is output whenobjecthas the valuenull.
yes Example with a
null value
"web" is not null, so it is output itself).
The variable
$myProduct stores all information and data about a product. If no product image is found ($myProduct.custom.image.normal is null), then the replacement image noImageNormal.png is displayed.
int
Theint function converts a value into a whole number (integer). This is especially necessary when a numeric value is present as text (e.g., "10") and is to be processed further as a true number — e.g., for calculations or comparisons. If the conversion is not possible (e.g., for a word), null is returned. Decimal numbers are truncated to the whole number before the decimal point (not rounded).
Usage exampleUseful, for example, to convert quantity specifications or article IDs that are present as text (e.g., “1043”) into a number before further processing. Signature
int(value)
Parameters
value- The value to be converted into an integer.
yes Example with a string containing a number The text “10” is converted into the number 10. With the output, the text was converted into a number with which it is now possible to calculate.
null.
join
Thejoin function joins all entries of a listing into a string. Optionally, a separator can be specified that separates the elements from one another.
Usage exampleSuitable, for example, for outputting product properties, variant attributes, or categories as a continuous text — e.g., comma-separated in one line. Signature
join(list[, "separator"])
Parameters
list- The listing whose entries are to be joined.separator(optional) - Separator between the entries. Default: no separator.
yes Example without separator
The variant data of a product is loaded via
$wsProducts.variantInfo(). The attribute “color” contains a listing of options (here: "Red", "Blue", "Green"). The color names are collected in a loop, gathered in a listing with push, and joined into a readable text with join.
split
json
Thejson function outputs a data object in technical JSON notation — a standardized text format that can easily be processed by machines.
Usage exampleUseful for debugging in the template or for passing data to external services (e.g., tracking, analytics). Signature
json(object)
Parameters
object- The object to be output as a JSON string.
yes Example - output of product data for debugging
No more than five levels are output. Deeper levels are represented as
"…".keys
Thekeys function returns all identifiers (keys) of a data object (map) as a listing. A map consists of pairs of identifiers and values — e.g., {name: "Topseller", price: 12.99}. With keys, the identifiers can be specifically read out.
Usage exampleUseful, for example, to iterate over all entries of a data object and display both the identifiers and the associated values in the template — e.g., for dynamically built product data or configuration settings. Signature
keys(object)
Parameters
object- The data object whose identifiers (keys) are to be returned.
yes Example
last
Thelast function returns the last entry of a listing (list).
Usage exampleUseful, for example, to specifically display the last order item, the last breadcrumb entry, or the last element of a variant list. Signature
last(list)
Parameters
list- the listing whose last entry is to be returned.
yes Example
The category path (breadcrumb) is loaded as a listing via
$wsCategories.loadPath(). With last, the last entry is specifically read out, since it corresponds to the current category.
len
Thelen function determines the length, i.e., the number of characters for a text, the number of entries for a listing, or the number of key-value pairs for a data object.
Usage exampleUseful, for example, to count the number of products in a list, check the character length of an input, or determine how many entries a data object contains. Signature
len(sequence) Parameters
sequence- text, listing, or data object whose length is to be determined.
yes Example with text
The products of a category are loaded via $wsCategories.loadProducts() (here: 24 products in the category). With
len, the number is determined.
lower
Thelower function converts all letters of a text to lowercase.
Usage exampleUseful, for example, to display or compare user input, voucher codes, or product identifiers uniformly in lowercase. Signature
lower(content)
Parameters
content- the text to be converted to lowercase.
yes Example
upper
max
Themax function returns the highest value from a listing of numbers.
Usage exampleUseful, for example, to determine the most expensive price within a variant list or the highest available quantity. Signature
max(list)
Parameters
list- the listing with numeric values.
yes Example
The customer’s most recent orders are loaded via
$wsOrderHistory.loadList(). Each order contains, among other things, the field order.total (total price). The loaded order values are gathered in a separate listing with push, and then the highest value is determined with max.
49.90, 129.00, 89.95):
min
merge
Themerge function joins two data objects (maps) together. The entries from the second object (source) are taken into the first object (target). For lists, the entries of the second list are appended to the first. No new object is created; the first object is directly modified.
For maps, the optional parameter deep is available. With deep=true, nested maps are also merged instead of being overwritten.
Usage exampleUseful, for example, to merge default values for the product display with product-specific values. This way, default texts or fallback images can be defined that are only used when a product does not have its own value. Signature
merge(target, source[, deep=false])
Parameters
target- the target object into which the entries are inserted.source- the source object whose entries are taken over.deep(optional) - only for maps. Withtrue, nested maps are also merged.
yes Example - merge default values with product-specific data
If both objects contain the same identifier (key), the value from the first object is overwritten by the value from the second object.
deep merge)
Default values for a product also contain nested image data (image). With deep=true, these are not completely overwritten during the merge but are also merged — so that only the image paths actually supplied by the product are taken over, but missing ones are preserved by the default value.
min
Themin function returns the lowest value from a listing of numbers.
Usage exampleUseful, for example, to determine the cheapest price within a variant list or the smallest stock. Signature
min(list)
Parameters
list- the listing with numeric values.
yes Example
The customer’s most recent orders are loaded via $wsOrderHistory.loadList(). Each order contains, among other things, the field
order.total (total price). The order values are gathered in a separate listing with push, and then the lowest value is determined with min.
49.90, 129.00, 89.95):
max
preparedFormat
ThepreparedFormat function formats a number with respect to decimal separator and decimal places, based on a format stored in the shop.
Usage example
Useful, for example, to display quantity specifications, weights, or other numeric values appropriately for the shop.
SignaturepreparedFormat(number, formatName)
Parameters
number- The number to be formatted.name- Name of the format configured in the shop (e.g.,"amount").
yes Example
amount formats here to whole numbers)
The weight of a product is stored as a decimal number in the field
$myProduct.custom.weight (here: 2.300000). With preparedFormat, it is output according to the format "weight" stored in the shop.
2.300000 and format "weight" with one decimal place):
push
Thepush function adds a new element to the end of an existing list and returns the new number of entries in the listing. The list is directly modified; no new list is created.
Usage exampleUseful, for example, to specifically collect entries in a loop, such as filtered products, error messages, or dynamically composed output lists. Signature
push(list, element)
Parameters
list- The listing to which the new element should be appended.element- The value to be added.
yes Example - add element
The products of a category are loaded as a listing via
$wsCategories.loadProducts(). With push, products from a second category can be appended to the list — e.g., to include cross-selling items in the output.
$myProducts now contains all products of the first category plus the products from the cross-selling category.
random
Therandom function generates a random value.
Usage exampleUseful, for example, to generate random voucher codes. Note
The function is planned but is not yet supported at the moment.
range
Therange function generates a listing of consecutive whole numbers — from the start value to the end value. By default, it counts in steps of one. For descending series, a negative step size must be specified.
Usage exampleUseful, for example, to generate page breaks (pagination), quantity selectors, or numbered outputs in the template. Signature
range(start, stop[, step=1])
Parameters
start- Start value of the number series.stop- End value of the number series.step(optional) - Step size (default: 1). Use a negative value for descending series.
no Example of an ascending series
raw
Theraw function outputs a value without automatic cleaning of HTML characters, so that contained HTML code is interpreted by the browser as formatting instead of being displayed as plain text.
Usage exampleUseful, for example, to display formatted product descriptions or CMS content with HTML markup unchanged in the shop. Note
The function is planned but is not yet supported at the moment.
replace
Thereplace function replaces all occurrences of a search term in a text with another text.
Usage exampleUseful, for example, to make internal designations more readable for display in the shop. Signature
replace(string, search, replace)
Parameters
content- The source text.search- The text to be searched and replaced.replace- The text to be inserted instead.
yes Example
reverse
Thereverse function reverses the order of the characters in a text or the entries in a listing.
Usage exampleUseful, for example, to reverse an existing sort order or to output entries in reverse order (e.g., newest entries first). Note
The function is planned but is not yet supported at the moment.
round
Theround function rounds a number commercially up or down. Optionally, the desired number of decimal places can be specified. Without specification, it is rounded to a whole number.
Usage exampleUseful, for example, to display calculated intermediate values, weights, or quantities commercially rounded in the template. Signature
round(number[, precision=0])
Parameters
number- The number to be rounded.precision(optional) - Desired number of decimal places (default: 0).
yes Example without decimal places
precision parameter controls the mathematical rounding (to how many decimal places the value is rounded). However, the output, by system design, always shows up to six decimal places (e.g., 1.230000 instead of 1.23). To adjust the display (e.g., only 2 visible decimal places), round is used in combination with preparedFormat:
sort
Thesort function sorts the entries of a listing (list). By default, it sorts in ascending order. With the optional parameter reverse, however, the sort order can also be reversed.
Usage exampleUseful, for example, to sort product lists, variants, or filter options alphabetically or by numeric value. Signature
sort(list[, reverse=false])
Parameters
list- The listing whose entries are to be sorted.reverse(optional) - Withtrue, it sorts in descending order.
yes Example with numbers
float after sorting.
The variant data of a product is loaded via
$wsProducts.variantInfo(). The attribute “color” contains a listing of options (here: Red, Blue, Green, Beige). Since the options are present as objects (e.g., {name: "Red"}), the names are first collected in a separate listing with push. Then they are sorted alphabetically with sort and output in a loop.
split
Thesplit function splits a text into a listing (list) of individual entries based on a separator.
Usage exampleUseful, for example, to break down comma-separated values from product data, configurations, or external sources into individual entries and process them separately. Signature
split(content, separator)
Parameters
content- The text to be split.separator- The separator at which the text is split.
yes Example
join
startswith
Thestartswith function checks whether a text begins with a specific character sequence and returns true or false.
Usage exampleUseful, for example, to distinguish article numbers based on their leading characters and react accordingly in the template, e.g., to display products from specific product groups differently (e.g., to mark all article numbers that begin with
"TKK" as frozen products).
Signaturestartswith(str, prefix)
Parameters
str- The text to be checked.prefix- The character sequence to check for at the beginning of the text.
yes Example with a match
itemNumber (here: "TKK-40210"). Article numbers that begin with "TKK" belong to the frozen products group. With startswith, this is checked and a corresponding badge is displayed.
"TKK-40210")
static
Thestatic function generates the full path to a static file (e.g., JavaScript, CSS, images). By default, such files are located under media/themes/default on the shop’s server.
Usage exampleUseful, for example, to correctly include paths to static files in the template — even if the storage location changes later. Signature
static(path)
Parameters
path- Path to the file, relative to the static directory of the shop.
no Example
Instead of a fixed path:
static:
Through consistent use of
static, the storage location of the static files can be adjusted at any time (e.g., to a media server or a CDN) without the templates having to be changed. For category or product images, static is not needed — their paths are generated automatically and correctly.str
Thestr function converts a value into a text (string). For numbers, the result may look identical, but internally it is a string — i.e., no longer a numeric value that could be used for calculations. Instead, the value can subsequently be processed further with text-based functions such as replace, startswith, or split.
Usage exampleUseful, for example, to convert an article number that is present as a number into a text so that
startswith can subsequently check whether it begins with a specific character sequence.
Signaturestr(value)
Parameters
value- The value to be converted into text.
yes Example with a whole number
striphtml
Thestriphtml function removes all HTML formatting (tags) from a text and returns only the plain text content.
Usage exampleUseful, for example, to output HTML-formatted product descriptions as plain text. Signature
striphtml(content)
Parameters
content- The text from which the HTML formatting is to be removed.
yes Example
take
Thetake function returns the first characters of a text or the first entries of a listing.
Usage exampleUseful, for example, to display only the first characters of a product name or the first entries of a product list. Signature
take(content, count)
Parameters
content- The text or the listing from which the first elements are to be taken.count- the number of characters or entries to be taken from the beginning.
yes Example with text
The products of a category are loaded as a listing via $wsCategories.loadProducts() (here:
24 products). With take, in this example, only the first 3 entries are taken and output in a loop as a teaser.
"Sneaker Classic", "Laufschuh Pro", "Sandale Sport", "Wanderstiefel", …)
takelast
takelast
Thetakelast function returns the last characters of a text or the last entries of a listing.
Usage exampleUseful, for example, to specifically display the last characters of an order number or the last entries of a list. Signature
takeLast(content, count)
Parameters
content- The text or the listing from which the last elements are to be taken.count- The number of characters or entries to be taken from the end.
yes Example with text
The category path (
Breadcrumb) is loaded as a listing via $wsCategories.loadPath() (here: 4 levels). With takeLast, only the last 2 entries are taken — e.g., to display only the current and the parent category in a sub-navigation.
take
trim
Thetrim function removes superfluous spaces at the beginning and end of a text.
Usage exampleUseful, for example, to clean user input, imported product data, or external values of unwanted whitespace before further processing. Note
The function is planned but is not yet supported at the moment.
type
Thetype function returns the data type of a value as text — e.g., whether it is a text (string), a whole number (int), a decimal number (float), a listing (list), or a data object (map).
Usage exampleUseful, for example, for debugging or to check in the template whether a value has the expected type before it is processed further. Signature
type(object)
Parameters
object- The value whose data type is to be determined.
yes Example using a text
upper
Theupper function converts all letters of a text to uppercase.
Usage exampleUseful, for example, to display voucher codes, shipping methods, or headings uniformly and in uppercase. Signature
upper(content)
Parameters
content- The text to be converted to uppercase.
yes Example
lower
Modifier
Many functions can alternatively also be used as modifiers (filters) in filter notation. The first parameter is to the left of the pipe operator|; further parameters are specified in parentheses.
Alternatively, a function can also be written with the filter operator | (pipe) (= filter notation). The first parameter is to the left of the operator.
Example
