I present to you a WordPress plugin that allows you to create flexible forms of the calculator.
Briefly about the possibility of plug-in:
Principle of fields: the field form the formula of the form:
field1 + (3 * field (field 2 + field 4))
For each field you can set the action performed in front of him and after him.
Arithmetic operations can be anything, it all depends on your imagination and level of knowledge of elementary mathematics.
Here are some examples of signs for construction of the formula:
(parentheses): ($a + $b) * $c
+ Addition: $a + $b
- Subtract $a - $b
* Multiplication $a * $b
/ Divide $a / $b
Modulo (remainder after integer division of $ a $ b) - $a % $b
How to calculate interest: ($number * $amount percentage /100)
We examine the possibility of the order of each field.
Text Block.
Display text - any text can use the HTML thus enabling the calculator to take any form ofregistration. Since version 2.5, we can derive value from the array $ _SESSION directly in the text. Of the session details below in the section $ _SESSION.
The order - the numeric sort order of fields in the formula, sorting from smallest to largest, in the order (ASC).
CSS - a class for this block. Need only specify the class name for example: myclass, and the file of your theme, or connected via the calculator settings file *. css to specify rules for the class. How the calculator generates CSS and HTML, you can see below.
The drop-down list.
The name of the field - the text entered in this field will be displayed above the drop-down list.
To - here it is necessary to specify the arithmetic sign that will set the action in front of thisdrop-down list.
After - here you specify the arithmetic sign that will set the action after the drop-down list.
The order - the numeric sort order of fields in the formula, sorting from smallest to largest, in the order (ASC).
The values of the list - to form a drop-down list, you must arrange the data according to certain rules! For example: [price]:name;[500]:Installation of windows;[0]:null;
Necessarily between these signs [price]: name;
If you miss even one, then the field will be invalid.
p.s. Input constructed by replacing a str_replace.
CSS - a class for this block. Need only specify the class name for example: myclass, and the file of your theme, or connected via the calculator settings file *. css to specify rules for the class. How the calculator generates CSS can be found below.
Checkbox.
The name of the field - the text entered in this box will appear above the block checkboxes.
To - here it is necessary to specify the arithmetic sign that will set the action in front of a group of checkboxes.
After - here you specify the arithmetic sign that will set the action after a group of checkboxes.
The order - the numeric sort order of fields in the formula, sorting from smallest to largest, in the order (ASC).
Of the list - to create a list of checkboxes, you need to arrange the data according to certain rules! For example: [price]:name;[500]:Installation of windows;[0]:null;
Necessarily between these signs [price]: name;
p.s. Input constructed by replacing a str_replace.
Action - action between the selected checkboxes for example defines the action of multiplication, if checkbox consist of a list: [500]:Site;[200]:Design layout;
then form the next row (500 * 200).
CSS - a class for this block. Need only specify the class name for example: myclass, and the file of your theme, or connected via the calculator settings file *. css to specify rules for the class. How the calculator generates CSS can be found below.
Radio buttons:
The name of the field - the text entered in this field will be displayed on a group of radiobuttons.
To - here it is necessary to specify the arithmetic sign that will set the action in front of thisblock of radio buttons.
After - here you specify the arithmetic sign that will set the action after a block of radio buttons.
The order - the numeric sort order of fields in the formula, sorting from smallest to largest, in the order (ASC).
The values of the list - to form a group of radio buttons, you need to arrange the dataaccording to certain rules! For example: [price]:name;[500]:Installation of windows;[0]:null;
Necessarily between these signs [price]: name;
p.s. Input constructed by replacing a str_replace.
CSS - a class for this block. Need only specify the class name for example: myclass, and the file of your theme, or connected via the calculator settings file *. css to specify rules for the class. How the calculator generates CSS can be found below.
Entered the field:
The name of the field - the text entered in this box will appear above the text field.
To - here it is necessary to specify the arithmetic sign that will set the action in front of thistext box.
After - here you specify the arithmetic sign that will set the action after the text field.
The order - the numeric sort order of fields in the formula, sorting from smallest to largest, in the order (ASC).
Price - the cost of the field, which was introduced with the price action as described belowin the input data from the user.
Action - this action means that we do with data entered by the visitor.
CSS - a class for this block. Need only specify the class name for example: myclass, and the file of your theme, or connected via the calculator settings file *. css to specify rules for the class. How the calculator generates CSS can be found below.
A hidden field.
To - here it is necessary to specify the arithmetic sign that will set the action in front of thissrktym field.
After - here you specify the arithmetic sign that will set the action after the hidden field.
The order - the numeric sort order of fields in the formula, sorting from smallest to largest, in the order (ASC).
Price - the cost of the hidden field.
SESSION field.
To - here it is necessary to specify the arithmetic sign that will set the action before the selected session.
After - here you specify the arithmetic sign that will set the action after the selectedsession.
The order - the numeric sort order of fields in the formula, sorting from smallest to largest, in the order (ASC).
ID of a calculator - to indicate from a calculator created by you to take data from the session.
ID field or the sum SUM calculator - to specify the ID of the screening results of the field, ortotal amount of the calculator, for the amount necessary to enter SUM.
Itself creates a session only after the user clicks Calculate. An associative array is as follows:
Array
(
[wpcalculator-1] => Array
(
[2] => 8000
[sum] => 727600
[4] => 399
[5] => 600
[6] => 3
[3] => 1400
)
)
where wpcalculator-1, figure 1 is a calculator, ID, and a nested data array keys mean the sort order, but the key SUM - is the total cost calculation.
To call a session in a text box to create a BBCode, it looks like this:
[session id="calc_id"] id_key or sum [/session].
For example from a calculator, we want to get the key value 5, then in the text box to create such code: [session id="1"]5[/session].
If the array wpcalculator-1 exists and it has a row with key 5 then we get the result in figure600.
Similarly, if you want to get the amount of the calculator you need to substitute the 5 Instead of the sum [session id="1"]sum[/session].
Primitive will assume further with the array data we have on the site to form a complex calculation or some limiting yourself only by simple statements If and Else in PHP ...
Session there until the user closed the browser.
Design - a new feature in WP Creator Calculator, the calculator design choice. By default,do not select any design. Patterns over time will grow. If you have a desire to help, you can send your template to e-amil zetrider@bk.ru.
Settings - This section is simple and complex settings that are needed for building complex formulas involving computing where two or more calculators.
The name of the button - this button calculation, calculate the default. You can customizeeach individual calculator.
The text to the amount - the text displayed before the final sum, for example: Total. You can customize each individual calculator.
The text of the following amounts - Appears after the amount, for example: Rub. You can customize each individual calculator.
POST ACTION - If this field to specify the web address, then after clicking on the button to calculate a calculator you choose, you will come to that address. You can customize eachindividual calculator.
CSS - Full web address to your Css file. You can specify a separate stylesheet for the calculator. Or you can leave it blank and fill in all the styles in the css file of your theme. Ifyou choose to design what a topic, then this field will automatically record the css fileyou've chosen a template.
How does the CSS in the WP Creator Calculator.
.wp_calculate{} /* div - container calculator */
.wp_calculateID_CALC{} /* div - container with the ID calculator calculator */
.wp_calculate_form {} /* form - a calculator */
.wp_calculate_formID_CALC {} /* form - a calculator with ID Calculator */
.wp_calculate_text {} /* div - the text block */
.wp_calculate_textID_ROW {} /* div - the text block with the ID field */
.wp_calculate_description {} /* div - description of the fields */
.wp_calculate_descriptionID_ROW {} /* div - describes the fields in the ID field */
.wp_calculate_select {} /* select - a class list */
.wp_calculate_selectID_ROW {} /* select - a class list with the ID field */
.wp_calculate_checkbox {} /* input - the class of checkboxes */
.wp_calculate_checkboxID_ROW {} /* input - the class of checkboxes with the ID field */
.wp_calculate_radio {} /* input - the class of radio buttons */
.wp_calculate_radioID_ROW {} /* input - the class of radio buttons with the ID field */
.wp_calculate_inputtext {} /* input - the input field class */
.wp_calculate_inputtextID_ROW {} /* input - the input field with class ID field */
.wp_calculate_submit {} /* input - the calculation of class buttons */
.wp_calculate_submitID_CALC {} /* input - the class of the button with the ID calculation calculator */
.wpcalculator_price {} /* div - a class for the calculation results */
.wpcalculator_priceID_CALC {} /* div - a class for the results of calculations with a calculator ID */
where:
ID_CALC = ID Calculator
ID_ROW = ID field (not sorted), and the ID field of the MYSQL
How does the HTML to WP Creator Calculator (example of a simple formula):
<div class="wp_calculate wp_calculate1">
<form method="POST" action="#calculate1" class="wp_calculate_form
wp_calculate_form1" name="calculateform1">
<div class="wp_calculate_text wp_calculate_text1 ">We present an example of a
calculator </div>
<div class="wp_calculate_description wp_calculate_description2">select a service
</div>
<select name="calculateprice[12]" class="wp_calculate_select
wp_calculate_select2 ">
<option value="8000+">website </option>
<option value="2000+">Develop a layout </option>
<option value="1000+">Optimizing your site </option>
</select>
<br />
<div class="wp_calculate_description wp_calculate_description3">design services
</div>
<input type="checkbox" name="calculatepricecheckbox[][13]" value="600"
class="wp_calculate_checkbox wp_calculate_checkbox3 "> develop a logo
<br />
<input type="checkbox" name="calculatepricecheckbox[][13]" value="800"
class="wp_calculate_checkbox wp_calculate_checkbox3 "> Develop a corporate
identity
<br />
<input type="hidden" name="calculatepricecheckboxid[3]" value="13" >
<div class="wp_calculate_description wp_calculate_description4">To register a
domain name? </div>
<input type="radio" name="calculateprice[14]" value="((0"
class="wp_calculate_radio wp_calculate_radio4 "> No
<br />
<input type="radio" name="calculateprice[14]" value="((399"
class="wp_calculate_radio wp_calculate_radio4 "> Yes
<br />
<input type="hidden" name="calculateprice[15]" value="600)" >
<div class="wp_calculate_description wp_calculate_description6">How many
domains will need to register? </div>
<input type="text" name="calculatepricetext[16]" value=""
class="wp_calculate_inputtext wp_calculate_inputtext6 ">
<br />
<input type="hidden" value="calculate1" name="calc_id_post">
<input type="submit" value="calculate" class="wp_calculate_submit
wp_calculate_submit1" name="calculate1">
</form>
<br style="clear:both;">
</div>
<br style="clear:both;">
<div class="wpcalculator_price wpcalculator_price1" id="calculate1">Total 488
200 $. </div>
<br style="clear:both;">
As can be seen from where all arithmetic is transmitted directly through the VALUE field.
How to edit a formula.
After adding the fields in the calculator below is a block with the name: Formula
As can be seen in the screenshot, all data for each block laid in order, if you mess with the mouse to move the obscure field and the pop-up window you will see a brief hint.
The screenshot also seen the error arose from the fact that the sort fields are the same.This should not be allowed, since the formula can line up incorrectly. Because of the sort fields depends on what the value of what will be interconnected.
The same unit can be seen in the screenshot: The formula in the form of text, we explain this line: 12 +13 + ((14 * 15) * 16)
here are the sort fields and values from before and after, it will be easier to navigate andfind errors in your formula.
How do I insert a calculator on the site.
The code for the files of your theme:
Shortcode for pages and entries: [wpcalculator idcalc="1"]
where 1 - is the ID you want to display the calculator.
Advanced analysis of data transmitted calculator.
The calculator is a shortcode call display more detailed analysis of the calculations. To display the detailed analysis necessary to shortcode looks like this:
[wpcalculator idcalc="ID" show_result="true"].
You get the following:
The transmitted data (as a string, all numeric values ??with arithmetic signs):
8000 + (600 +800) + ((399 * 600) * (2 * 1))
and Session list:
Array
(
[wpcalculator-1] => Array
(
[2] => 8000
[sum] => 727600
[4] => 399
[5] => 600
[6] => 3
[3] => 1400
)
)
Requires: 3.0 or higher
Compatible up to: 3.2.1
Last Updated: 2011-11-25
Downloads: 2,861
0 of 1 support threads in the last three weeks have been resolved.
Got something to say? Need help?