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

Order Totals

{exp:cartthrob:order_totals} calculates aggregate totals from order entries.

You can filter results using standard channel:entries-style parameters (date filters, author_id, status, and similar entry filters).

Behavior by usage style:

  1. Single tag: returns the aggregated total value.
  2. Tag pair: exposes the variables listed below.

See also:

Parameters

This tag does not define custom parameters of its own.

It uses channel:entries filtering parameters through CartThrob’s entries model. The orders channel is always constrained by CartThrob’s configured orders_channel. For parameter details, see channel:entries parameters.

Variables

- total - subtotal - tax - shipping - discount - count

total

The sum of the order totals that match your filter.

{total}

subtotal

The sum of the order subtotals that match your filter.

{subtotal}

tax

The sum of the order tax amounts that match your filter.

{tax}

shipping

The sum of the order shipping charges that match your filter.

{shipping}

discount

The sum of the order discount amounts that match your filter.

{discount}

count

The number of orders that match your filter.

{count}

Behavior and Constraints

  1. Totals are aggregated from configured order field mappings (orders_total_field, orders_subtotal_field, orders_tax_field, orders_shipping_field, orders_discount_field).
  2. Each aggregated monetary value is sanitized and summed as an absolute value.
  3. count is the number of matching order entries.
  4. Monetary outputs are number-formatted before rendering.
  5. If the orders channel is not configured, totals remain 0 and count remains 0.
  6. Single-tag output returns formatted {total}.

Examples

All orders:

{exp:cartthrob:order_totals limit="999999999"}

Orders from January 2010:

{exp:cartthrob:order_totals year="2010" month="01"}
Total: {total}
{/exp:cartthrob:order_totals}

Orders by member whose id is 1:

{exp:cartthrob:order_totals author_id="1"}
Total: {total}
{/exp:cartthrob:order_totals}

Orders from 2011 whose status is paid:

{exp:cartthrob:order_totals status="paid" year="2011"}
{total}
{/exp:cartthrob:order_totals}

Since order_totals is built on channel:entries filtering, dynamic date segments can be used for reporting URLs.

Examples:

site.com/order/totals/2011
site.com/order/totals/2011/10
site.com/order/totals/2011/10/01