CartThrob 9 documentation for ExpressionEngine commerce teams Visit CartThrob.com
CartThrob.com

View Formatted Number

view_formatted_number formats a numeric value for display using CartThrob/ExpressionEngine number-format behavior.

Implementation note: this tag directly returns:

ee()->number->format($this->param('number'))

Use this tag when you need to format an arbitrary numeric value in templates (not only cart totals).

See also:

Parameters

In addition to number, templates commonly use shared number-format settings/overrides documented on Global Number Formatting.

number

Numeric value to format.

number="12"

Behavior and Constraints

  1. This is an immediate-execution single tag.
  2. The tag passes only number directly into the number formatter.
  3. Output is a formatted display value (not a calculation-safe numeric type).
  4. For comparisons/calculations, use numeric outputs from source tags (for example :numeric variants) and format only at final display time.

Examples

Basic formatting:

{exp:cartthrob:view_formatted_number number="12.1234"}

Common formatting override usage (as used in installer/stub examples):

{exp:cartthrob:view_formatted_number number="12.1234" prefix="$" decimals="2"}

Format a computed number:

{exp:cartthrob:view_formatted_number number="{exp:cartthrob:arithmetic expression='12.1234 * 2'}"}