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.
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.
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.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.
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.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.
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.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.Related topics
- Guide: Displaying areas depending on counter values
- Guide: Removing price formatting in specific places
- Materials: Commercial calculations
- Materials: Modulo calculation
- Reference: DC- (loops)
