This page will explain how the calculation system works in ez Form Calculator for WordPress. The plugin allows you to add element values, subtract, multiply, divide and many more math operations with ease.
The plugin works like this:
- Element values are calculated automatically
- Values are added up from top to bottom
- Some elements might contain calculation rows (e.g. multiply with other elements)
- All calculation elements might overwrite the price from where it’s positioned (if the option ‘overwrite_price’ is set to ‘Yes’)
In general, there are many ways to set up a form. The most common ones are described below.
Elements are calculated from top to bottom, so every element is added consecutively. For example, a simple order consists of only Numbers elements. The calculation is handled like this:
- Product A: 15 | Price = 15
- Product B: 20 | Price = 35
- Product C: 10 | Price = 45
- Price = 45
Advanced Calculation with Subtotal Elements
Complex calculation forms can be realized with the help of Subtotal elements. This way, multiple calculations can be created in a single form.
- Product A: 5
- Product B: 10
- Width: 100
- Height: 70
- Subtotal 1:
- Calculation: Product A * Product B = 5 * 10 = 50
- Subtotal 2:
- Calculation: Width * Height = 100 * 70 = 7000
- Subtotal 3:
- Calculation: Subtotal 1 + Subtotal 2 = 50 + 7000 = 7500
- Price = 7500
The following flowchart shows how the user input is processed by the plugin.
First, the (user) input is registered and the calculations of all elements in the form are processed. The “Calculate” section in the element options are run from top to bottom.
Afterward, the discount section is processed. Every row in the discount section will be checked if the calculated value of the element should be modified, for example, set a fixed value, increase value by a fixed percentage, modify the factor and so on.
Subsequently, the conditional section is processed. Depending on the value of the current element, the plugin will perform conditional actions, if all conditions are met.
- Make sure that the option “overwrite_price” in the quantity elements are set to “Yes”. Otherwise, the calculated value will be added, which is wrong for this purpose.
- Calculations may be wrong when using conditionally hidden subtotal values in the first row. In order to avoid this, simply set the first calculation row to “0” (equals / no target / 0).