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_taxexplicitly readsprefix,decimals,dec_point, andthousands_sep.Other money tags typically format output through
ee()->number->format(...)and follow store/default number-format behavior.- 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 "
Related Tags
These tags are directly related to number formatting because they either:
- format numeric output directly, or
- expose formatted monetary variables.
Direct formatting tags
- view_formatted_number: format an arbitrary number for output.
- arithmetic: can return formatted output when
format="yes". - cart_shipping_plus_tax: explicitly supports
prefix,decimals,dec_point, andthousands_sepparameters.
Cart and checkout totals tags
- cart_subtotal: formatted subtotal output (also used on Cart page and Checkout page).
- cart_subtotal_plus_shipping: formatted subtotal + shipping output (also used on Cart page and Checkout page).
- cart_subtotal_plus_tax: formatted subtotal + tax output (also used on Cart page).
- cart_subtotal_minus_discount: formatted subtotal - discount output (also used on Cart page and Discounts page).
- cart_shipping: formatted shipping output (also used on Cart page and Checkout page).
- cart_tax: formatted tax output (also used on Cart page and Checkout page).
- cart_total: formatted final total output (also used on Cart page and Checkout page).
- cart_discount: formatted discount output (also used on Checkout page and Discounts page).
Discount/coupon and order summary tags
- cart_discount_percent_of_subtotal: discount percentage output (also used on Discounts page).
- cart_discount_percent_of_total: discount percentage output (also used on Discounts page).
- coupon_info: formatted coupon discount amount variables (also used on Discounts page).
- discount_info: formatted discount amount variables (also used on Discounts page).
- order_totals: formatted aggregate order totals (also used on Cart page).
Tag pairs exposing formatted monetary variables
- cart_items_info: item/cart variables include formatted and
:numericforms (also used on Cart page and Checkout page). - order_items: purchased item variables include formatted and numeric forms (also used on Cart page, Checkout page, and Downloads page).
- cart_info: cart-level totals and metadata values include formatted monetary output (also used on Cart page).
- get_shipping_options: option price values are formatted for display (also used on Checkout page).
Behavior and Constraints
- Most CartThrob money-output tags format through
ee()->number->format(...). cart_shipping_plus_taxis a special case with explicit in-tag formatting parameter handling.- Many total tags support a
:numericmodifier for raw values; use these for comparisons/calculations and formatted output for display. - Formatting behavior can depend on store number-format defaults and ExpressionEngine number formatter behavior.
- 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:
- Use store defaults for consistent output across your cart/checkout pages.
- Override formatting per tag only when a template has a specific display requirement.
- Use
:numericoutput variants when values are used for comparisons/calculations.