Skip to main content
Expressions in [[ ... ]], data-condition, data-ef-text, and similar attributes can call built-in functions. You can also register custom functions with registerTemplateFunction(name, fn) or registerTemplateFunctions({ name: fn, ... }).

Price display: when to use formatPrice vs as-is

Most checkout and cart values are already formatted (e.g. "$29.00"). Use them directly in [[ ... ]]. Use formatPrice() only when you need to display a raw number (e.g. *_raw keys or a computed number).
These are pre-formatted. Use [[ variable ]] only.In template: [[ checkout.total ]], [[ item.price ]], [[ bump.price ]]
Do not pass an already-formatted string into formatPrice (e.g. formatPrice(checkout.total, ...) or formatPrice(item.price, ...)). That can produce wrong or duplicated currency symbols.

formatPrice(value, currency?, locale?) / money / formatCurrency

Formats a numeric value as currency.

Cart helpers


String helpers

All coerce to string; null/undefined become empty string.

Custom functions

Register from application or plugin code:
Then in templates: [[ myFormat(item.name) ]], [[ double(item.quantity) ]], [[ greet(checkout.customer.first_name) ]].

Summary

  • Price display: Use the table above: pre-formatted keys as-is; formatPrice only for raw values or computed numbers.
  • Cart: cartCount, cartSubtotal, lineTotal; combine with formatPrice when you need a formatted string from a number.
  • Strings: upper, lower, capitalize, titleCase, camelCase, snakeCase, kebabCase (and aliases).
  • Custom: registerTemplateFunction / registerTemplateFunctions.
Next: Cart and Checkout.