Prices & Quantity Calculations
The plugin provides a robust system for calculating prices, quantities, and other variables:
The custom calculation engine utilizes the JavaScript language, supporting any JavaScript syntax and functions, including those from the Math object.
Beyond standard JavaScript, the plugin incorporates special shortcodes. For example, the [price] shortcode represents the calculation result, formatted as:
[price] = 110.00
Additional shortcodes can retrieve the value, price, or quantity of any form element. These don’t have to be written manually; simply use the “Add a value” button to visually select an element, and the plugin will insert the corresponding shortcode:
[price] = [item-1_value]
Key arithmetic operators include:
- + : Addition
- – : Subtraction
- * : Multiplication
- / : Division
For conditions, the “Add a condition” button provides access to the conditions panel:
Create conditions using the “Add a condition” button and the condition dropdowns. A dropdown at the top of the list specifies if all conditions must be met or just one for the condition to apply.
After saving in the conditions panel, the plugin automatically generates the condition syntax:
[price] = 10 if([item-1_isChecked] && [item-2_value] < 25) { }
Add the desired conditional pricing within the braces:
[price] = 10 if([item-1_isChecked] && [item-2_value] < 25) { [price] = 20 }
In this scenario, the default price is $10, adjusted to $20 if certain conditions are met.
Leveraging full JavaScript syntax, nested conditions and "else" statements are also possible:
if([item-1_isChecked]) { if([item-2_isChecked]){ [price] = 20 } else { [price] = 10 } }
The "Add a distance" feature, enabled when the "Google Maps API key" is configured, calculates distance or travel time between addresses from form fields, returning a shortcode like [distance-1-2].
The "Date difference" button calculates the days between dates from two datepickers in the form.