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

Global Number Formatting Options

This page documents shared number-format behavior used by CartThrob tags that output monetary values.

CartThrob money tags commonly output formatted values through ExpressionEngine’s number formatter (ee()->number->format(...)). Some tags also support raw numeric output (for example, :numeric) when you need calculation-safe values.

All numeric inputs should be posted using standard numeric notation (1000.00, 1.5, etc.). Formatting should be handled at output time.

See also:

Parameters

These formatting parameters are used for output formatting.

Code note:

  • cart_shipping_plus_tax explicitly reads prefix, decimals, dec_point, and thousands_sep.
  • Other money tags typically format output through ee()->number->format(...) and follow store/default number-format behavior.

  • decimals

  • dec_point
  • thousands_sep
  • prefix

decimals

Controls decimal precision for formatted output.

Default in explicit CartThrob implementation (cart_shipping_plus_tax): 2.

decimals="2"

dec_point

Sets decimal separator character.

Default in explicit CartThrob implementation (cart_shipping_plus_tax): ..

dec_point="."

Example locale override:

dec_point=","

thousands_sep

Sets thousands separator character.

Default in explicit CartThrob implementation (cart_shipping_plus_tax): ,.

thousands_sep=","

Example locale override:

thousands_sep="."

prefix

Adds a string prefix to formatted monetary output.

Default in explicit CartThrob implementation (cart_shipping_plus_tax): $.

prefix="$"

Example:

prefix="Euro "

These tags are directly related to number formatting because they either:

  1. format numeric output directly, or
  2. expose formatted monetary variables.

Direct formatting tags

Cart and checkout totals tags

Discount/coupon and order summary tags

Tag pairs exposing formatted monetary variables

Behavior and Constraints

  1. Most CartThrob money-output tags format through ee()->number->format(...).
  2. cart_shipping_plus_tax is a special case with explicit in-tag formatting parameter handling.
  3. Many total tags support a :numeric modifier for raw values; use these for comparisons/calculations and formatted output for display.
  4. Formatting behavior can depend on store number-format defaults and ExpressionEngine number formatter behavior.
  5. Percentage tags (cart_discount_percent_of_subtotal, cart_discount_percent_of_total) return percentage numbers, not currency strings.

Examples

Default formatted cart total:

{exp:cartthrob:cart_total}

Raw numeric value for logic/calculations:

{exp:cartthrob:cart_total:numeric}

Explicit custom formatting (cart_shipping_plus_tax):

{exp:cartthrob:cart_shipping_plus_tax
  decimals="2"
  dec_point=","
  thousands_sep="."
  prefix="Euro "}

Utility formatting of an arbitrary number:

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

Configuration and Defaults

CartThrob number formatting defaults come from store settings and are used by tags that format output through ee()->number->format(...).

You can inspect currently configured defaults with view_setting:

{exp:cartthrob:view_setting decimals="yes"}
{exp:cartthrob:view_setting dec_point="yes"}
{exp:cartthrob:view_setting thousands_sep="yes"}
{exp:cartthrob:view_setting prefix="yes"}

Practical guidance:

  1. Use store defaults for consistent output across your cart/checkout pages.
  2. Override formatting per tag only when a template has a specific display requirement.
  3. Use :numeric output variants when values are used for comparisons/calculations.