Skip to main content
You can calculate in the template, using four families of tags that differ in what they calculate with.
There are three of each of the first three families, addressed via the digit in the name: DC-Counter1 to DC-Counter3. There are no more than that, and they apply to the entire page. If you are already using three counters at the same time and need a fourth, you have to reset one of them and reuse it.

The counter

DC-Counter1…3 counts and outputs its current value. That is all it can do, and that is exactly why it is the right choice for the most common task: numbering what a loop iterates over.
Reset the counter before every loop. Otherwise it continues counting from the value that an earlier loop on the same page left behind.

Reacting to specific positions

As a range tag, DC-Counter1…3 checks against a comma-separated list of counter values.
For regular patterns, listing values is impractical because the list grows with the number of products. Use DC-Int1…3_mod() for that instead, see below.

Counting two lists separately

If each list should start at 1, the reset belongs at the beginning of each list.

The integer variable

DC-Int1…3 calculates with integers. All suffixes change the stored value; it is output only by DC-Int1…3. All suffixes with an argument support tag-in-tag, so the initial value can come from another tag.
A division by 0 has no effect: the value keeps its previous state, and there is neither an error message nor an abort. Therefore, check the divisor yourself if it comes from a tag.

Every second row

This is the classic use of _mod(): the remainder of the division by 2 is 0 for even positions and 1 for odd ones.
You create a grid in the same way: _mod(3) results in 0, 1, 2 and repeats, so the result 0 marks every third position and thus the start of a new row.
Materials: Modulo calculation

Bracketing by values

Like the counter, DC-Int1…3 as a range tag checks against a comma-separated list.

The commercial calculation

DC-CommercialCalc1…3 calculates with decimal numbers and outputs the result in the price formatting set in the shop configuration shop.config. Internally, calculations are performed with full precision; rounding only happens on output.
_percent(), _VAT(), _VATadd() and _VATsub() differ in one point that is easily overlooked. _VATadd() calculates upwards from the net value, while _VAT() and _VATsub() calculate out of a gross value. For 100.00 € and 19 percent, _VATadd(19) therefore results in 119.00 €, whereas _VAT(19) results in 15.97 € and _VATsub(19) in 84.03 €.

Prices as the initial value

All single tags that output a price formatted by WEBSALE are permitted as the argument. The price formatting is automatically switched off before the value is taken over.
Write fixed values in the argument without thousands separators and with a period as the decimal separator. Do not include a currency, otherwise the result is unusable.

A discount in two steps

Two of the three calculators can be combined: one holds the initial value, the other calculates the amount to be deducted.

More decimal places

DC-CommercialCalc1…3 rounds to two decimal places. If you need more, append _prec and the desired number of places.
Output with _prec does not use the shop’s price formatting but the technical format: no thousands separator, period as the decimal separator. For amounts that the buyer is meant to read, the tag without a suffix is therefore the right choice. _prec is intended for values that are processed further, for example in an interface.
1 to 10 decimal places are permitted. A higher value makes the tag invalid.
  • Materials: Commercial calculations
  • Guide: Removing price formatting in specific places

One-off calculations without intermediate storage

For a calculation that is only needed in one place, there are four tags that take both values in the argument and output the result immediately. No calculator is used up for this.
Both arguments support tag-in-tag, and _prec works the same way as with DC-CommercialCalc1…3. These four tags are not described in the previous documentation, but they exist in the shop.
If the second value for DC-Div() is 0, the tag outputs nothing. The page then simply stays empty at that spot.

Overview of the tags

All tags are permitted in all templates.
The suffixes of the DC-Int and DC-CommercialCalc families are appended with an underscore: ~DC-Int1_add(3)~. The previous documentation lists them without an underscore in its table of contents, but correctly in its examples.
  • Guide: Displaying areas depending on counter values
  • Guide: Removing price formatting in specific places
  • Materials: Commercial calculations
  • Materials: Modulo calculation
  • Reference: DC- (loops)