Step by Step instruction for a simple order form
This feature is part of the Visforms Subscription and not available in the free Visforms version..
We propose reading the documentation from the beginning, starting with the Introduction. We will not repeat concepts and explanations made in previous parts of the documentation, here.
The demo form
The demo form would allow a user to buy apples. The user can select the amout of apples they want to buy, from a dropdown list. If the user orders 10 kilogramm of apples or more, they qualify for a 2,5 % discount. Further on the form calculates the tax value and the total sum. Obviously a real live form would also have field where the user enters customer information, which we skipped in the demo form.
The demo form has the following fields:
Name | Type | Function |
---|---|---|
Amount | Select | Select the amount |
Sum (Euro) | Calculation | Calculates the price from selected amount and price per kilogramm |
Discount (Euro) | Calculation | Calculates the discount |
7% Tax (Euro) | Calculation | Calculates the tax value |
Total (Euro) | Calculation | Calculates the total sum |
The field "Amount"
The field "Amount" is of type select. It has t options (see screenshot). Please not that the values of the options (in the option list) are numbers, where as the labelsof the options (in the option list) are strings.
The standard Visforms field feature "custom text" was used to add the article image and a description of the article.
The field "Sum"
A simple multiplication
The field sum calculates the price which the user has to pay for their apples according to the amount of apples the user has selected and the fix price per kilogramm.
Please note, that any number used in a calculation must use the dot as decimal separator. We use the option "Decimal separtor" to control, that the result of the calculation is displayed with a dot as decimal separator as well.
We use the option "Precision" to make sure, that any number used in the calculation is rounded properly to 2 decimal places.
The option "Decimals fixed" is used to make sure, that all calculated values are displayed, as we would expect it for a currency, with two decimal places. Thus the number 9.9 is displayed as 9.90
As fields of type calculation can only display numbers, we have added the currency in the field label.
The field discount
Use conditions in calculations
In our setup an order only qualifies for discount, if the user orders 10 kilogramm apples or more. It is possible to manage such simple conditions in fields of type calculation. Please use the following syntax:
(Condition) ? result if condition is true : result if condition is not true
In our demo form this translates to the following formula:
So the formula we use in the demo form is as follows:
([AMOUNT] >= 10) ?(-(([SUM]*2.5)/100)) : 0
If the condition ([AMOUNT] >= 10)
is true the calculation (-(([SUMME]*2.5)/100))
is performed. This will result in a negative value, the discount value. If the condition is not true the discount calculation will result in 0
.
The field "Tax"
Brackets help us to make sure that the calculation is performed in the proper order. First sum and discount are added up, afterwards the the tax value is calculated.
The field "Total"
The calculation of the total sum follows the same rules as the tax calculation. We could have used a simple addition of the fields "Sum", "Discount" and "Tax" as well.