Document – WPForms – Cost Calculator

With the WPForms Cost Calculator, you can create dynamic and interactive forms that provide users with instant cost calculations or estimates. This is particularly useful for businesses or websites that offer products or services with variable pricing based on user selections or quantities.

Here are some key features and capabilities typically offered by the WPForms Cost Calculator:

  1. Calculation Fields: This extension introduces calculation fields into your WPForms forms. You can define these fields and specify mathematical formulas or expressions using variables and operators.
  2. Variable Inputs: Users can input values into the form, such as quantities, dimensions, or other parameters that affect the final cost calculation.
  3. Conditional Logic: The plugin allows you to incorporate conditional logic into the calculations. This means that you can set up different calculations based on specific conditions or user choices.
  4. Dynamic Updates: As users make changes or update input values, the cost calculation is automatically updated in real-time, providing instant feedback.
  5. Customizable Output: You can customize the display and formatting of the calculated cost or estimate. This might include adding currency symbols, decimal places, or any additional text.
  6. Integration with WPForms: The extension seamlessly integrates with the WPForms plugin, allowing you to leverage its form-building capabilities while adding cost calculation functionality.

Table of contents:

Plugin Installation – top

Download it here: https://add-ons.org/plugin/wpforms-cost-calculator/

Once you’ve downloaded a plugin, you’ll need to install it on your website. Log into your WordPress admin dashboard. Navigate to the “Plugins” section and click on “Add New.” Search for the plugin by name and click “Install Now” once you find it.

After installation, click on “Activate” to activate the plugin.

Configuration

In the WPForms form editor, you’ll find a new “Calculator” section. Here, you can create and manage your calculations, including:

  • Calculation Formulas: Define the mathematical expressions and logic for your calculations.
  • Conditional Calculations: Set up rules to apply different calculations based on form field values.
  • Calculation Formatting: Customize the display of your calculated values, such as currency formatting, decimal precision, and more.

Calculation settings

Step 1: On your WP dashboard, head to WPForms – Create a new form.

Step 2: In your form editor, head to Add Fields – Drag and drop the Calculator button.

 Drag and drop the Calculator button.

Step 3: Enter your formula

Enter your formula for WPForm cost calculator

when you enter, suggested functions will appear

Number format

IF Conditions

Logical operators (==, !=, <, <, >=, <=) are supported, but logically they can only return true (1) or false (0). In order to leverage them, use the built-in if function:

✔️ One condition:

if(condition,true,false)

E.g: If your bill is more than $500 you will get 5% discount on total.

  • Step 1: Drop down fields: Total (type:number)and Total After Discount (type: calculator)
  • Step 2: Set formula:
if( {field_id="6"} >500, {field_id="6"}-{field_id="6"} *0.05, {field_id="6"} )

Where:

field_id=”6″: ID of Total ( when you click Show Smart Tag, it is displayed)

  • Step 3: Save and have a look:
IF condition for wpforms cost calculator

✔️ Two condition:

if(if( condition, true, if( condition, true, false))

E.g: Calculate the entrance fee to the zoo park:
Children under 10 years old receive a 50% discount, persons over 70 years old receive a free, and everyone else pays the exact original price.

  • Step 1: Drop down fields: Original Fee (type:number), Age(type:number slider), Final Fee(type:calculator)
  • Step 2: Set formula:
if( {field_id="17"} <10, {field_id="18"} *0.5, if( {field_id="17"} >=70,0, {field_id="18"} ))

Where:

field_id=”17″: ID of Age

field_id=”18″: ID of Original Fee

  • Step 3: Save and Have a preview:
IF condition for wpforms cost calculator
IF condition for wpforms cost calculator
IF condition for wpforms cost calculator

Age Calculation

Method 1: Based on Date of Birth to present.

E.g:

  • Step 1: Drop down fields: Date of Birth (type:date) and Age (type: calculator).
  • Step 2: Set formula:
age( {field_id="7"} )

Where:

field_id=”7″: ID of Date of Birth ( when you click on Show Smart Tag, it is displayed)

  • Step 3: Save and have a look!
Age Calculation for wpform
Age Calculation for wpform

Method 2: Based on date of birth until a given date.

  • Step 1: Drop down fields: Date of Birth (type:date), Given Date(type:date) and Age (type: calculator).
  • Step 2: Set formula:
age2( {field_id="7"} , {field_id="9"} )

Where:

field_id=”7″: ID of Date of Birth

field_id=”9″: ID of Given Date

  • Step 3: Save and have a look!
Age Calculation for wpform
Age Calculation for wpform

Date/ Month/ Year Calculations

days( end, start)
months( end, start)
years( end, start)

E.g:

end: ID of Date B

start: ID of Date A

Date/ Month/ Year Calculations for wpform
Date/ Month/ Year Calculations for wpform

Supported symbols – top

SymbolExplanation
+Addition Operator eg. 2+3 results 5
Subtraction Operator eg. 2-3 results -1
/Division operator eg 3/2 results 1.5
*Multiplication Operator eg. 2*3 results 6
ModModulus Operator eg. 3 Mod 2 results 1
(Opening Parenthesis
)Closing Parenthesis
SigmaSummation eg. Sigma(1,100,n) results 5050
PiProduct eg. Pi(1,10,n) results 3628800
nVariable for Summation or Product
piMath constant pi returns 3.14
eMath constant e returns 2.71
CCombination operator eg. 4C2 returns 6
PPermutation operator eg. 4P2 returns 12
!factorial operator eg. 4! returns 24
loglogarithmic function with base 10 eg. log 1000 returns 3
lnnatural log function with base e eg. ln 2 returns .3010
powpower function with two operator pow(2,3) returns 8
^power operator eg. 2^3 returns 8
rootunderroot function root 4 returns 2
sinSine function
cosCosine function
tanTangent function
asinInverse Sine funtion
acosInverse Cosine funtion
atanInverse Tangent funtion
sinhHyperbolic Sine funtion
coshHyperbolic Cosine funtion
tanhHyperbolic Tangent funtion
asinhInverse Hyperbolic Sine funtion
acoshInverse Hyperbolic Cosine funtion
atanhInverse Hyperbolic Tangent funtion

Use cases – top

InputResultExplanation
2+3-14Addition and Subtraction operator
2*5/101Multiplication and Division operator
tan45 or tan(45)1Trigonometric Function ( tan in Degree mode)
tan45 or tan(45)1.619775190543862Trigonometric Function ( tan in Radian mode)
Pi1,15,n or Pi(1,15,n)1307674368000Product of Sequence
Sigma1,15,n or Sigma(1,15,n)120Sum of Sequence( also called summation)
2^38Exponent( note this operator is left associative like MS Office)
5P360Permutaion Method to calculate all the permutaions
sincostan90 or sin(cos(tan(90)))0.017261434031253Multiple functions with or without parenthesis (both works)

Video Demo