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:
- Single tag: returns the aggregated
totalvalue. - 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
- Totals are aggregated from configured order field mappings (
orders_total_field,orders_subtotal_field,orders_tax_field,orders_shipping_field,orders_discount_field). - Each aggregated monetary value is sanitized and summed as an absolute value.
countis the number of matching order entries.- Monetary outputs are number-formatted before rendering.
- If the orders channel is not configured, totals remain
0and count remains0. - 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