Skip to main content
Windward

ADDTOTAL and GETTOTAL Functions

Overview

The ADDTOTAL function adds a given value to a named variable. If you call the function like ADDTOTAL(10, 'total') it adds ten to the variable named 'total'. This variable is NOT a template variable, and can not be accessed through any other function or tag.

 

ADDTOTAL does not return any data, so if you use it in an out tag the tag will be hidden in the output.

To show the current value of the variable, use the GETTOTAL function with the name of the variable you want to show, e.g. GETTOTAL('total'). So, to use it in a list would be something like this:

[forEach:order] [out:amount] [out:ADDTOTAL(amount, 'orderTotal')] 
[:forEach]Total: [out:GETTOTAL('orderTotal')]

Syntax

ADDTOTAL(value, variable)

  • value - Required.  The number you want to add to your running total.
  • variable - Required.  The name of the variable you wish to use to keep track of the total (a string).

GETTOTAL(variable)

  • variable - Required.  The name of the variable you wish to get the current total for (a string).

Running Total Example

See how to use ADDTOTAL/GETTOTAL to calculate a running total in this step-by-step example.

  • Was this article helpful?