
WPCC 3.5 - plugin for creating calculators in WordPress

The version of Creator Calculator 3.5 for CMS Wordpress has the following changes and features:
- Changed calculation algorithm
- Calculator table structure changed
- Added the ability to round the calculation result
- Now you can use arithmetic functions: Extract the square root, Raise to the power
- JQurey Copy field now works for all field types
- Fixed the template for constructing SELECT, RADIO lists (earlier: [100]: title; now: 100: title)
- Added ability to create lists for Checkbox
- Fixed logical errors in the calculation function
- New field added: Conditions
- Session auto start and jQuery plugin connection
- Extra calculator settings removed
- Added fields option: Exclude from formula
- Added fields option: Hide the field visually (for conditions to work)
- New field added: Slider (jQuery UI Slider)
- Fixed error connecting wp-load.php to plugin files
- Added Import and Export calculator formulas
- Added the ability to send user calculation results to e-mail with saving selected parameters
- Added new calculator themes
- Fixed sorting of fields
- Added the ability to connect scripts needed for the plugin to work on certain pages of the site
Demo calculator
Calculator to calculate the cost of creating the site
Selecting a brand car without calculating the cost
Warning to users of WPCC version younger than 3.5
Calculator table structure completely redesigned! This means that you will need to recreate the calculators! For your convenience, a function has been added that allows you to view the formula parameters of the calculator of the previous version. After you create new calculators, the old table can be deleted through the plugin settings.
Large screenshot of the admin panel interface WPCC 3.5

Description of the calculator
A Wordpress site administrator can create an unlimited number of calculator forms with their placement on the site pages, or through widgets.
The principle of the calculator:
field1 + sqrt ((field 3 * (field 2 + field 4)))
Literally:
(id1 (sign after field)) the square root of ((sign before field id3 sign after field) (sign before field id2 sign after field) ( id4 characters after the field))
Calculator Options
Each calculator can be called by its name. This name is displayed only in the administrative panel.
Also, all calculators have the following individual settings:
General settings:
- The name of the button is Calculate by default. You can specify for example: Get the result
- Text before sum - default: Result. It is displayed before the calculation result.
- Text after amount - default: Rub. For example, you can specify $.
- Action forms - where to redirect the user after calculation. (Only works if JavaScript is disabled)
- Round the result - you can select the function with which the result will be processed. Available to you: Round (from 0 to 4 decimal places), Ceil and Floor.
- Calculator design: You can choose one of four ready-made themes for every taste, or make changes to an existing one.
Email settings:
- Enable sending letters - if you want to send letters after calculation, select Yes
- Subject - The subject of the letter that is sent to E-Mail. After the topic, the username is automatically added. For example: Calculation of the calculator from the user Vasya Pupkin.
- To which E-Mail to send - specify email. The default email address is admin.
- Text at the beginning of the letter - Text in front of the table with the calculation results
- Text in front of the form - Displayed before the user’s email sending form.
- Successful sending message - Displayed when the message has been sent successfully.
ps Fields do not pass validation. What the user specified or not specified is sent.
Downloading plugin scripts:
From version 3.5, for the plugin to work fully, libraries are connected: (jquery-ui-core, jquery-ui-slider, wpcc.js, etc.). In order not to clutter up your page, you can specify the ID of the pages on which the plugin shortcode is placed, then the scripts will be loaded only there. If you use the plugin widget, then specify 0 (zero) to load scripts on all pages of the site. These settings are the same for all created calculators.
Field types, their parameters, description
In the plugin next to each parameter of the field there is a question mark "?". When you click on the question mark, you will be taken to the page of the developer's site with a more detailed description of the parameter.
Text block:
Displays the title and text specified in its parameters.
- Title - displayed above the field.
- Text - you can specify any arbitrary text that is not involved in the calculation formula. The field supports html tags. Indentation is added automatically (nl2br).
All the results of the calculator’s calculations are recorded in the session, in connection with this, you can specify the following codes that will output the desired result from $ _SESSION.
[session id = "calculator number"] indicate the number of the calculator field or specify sum to display the result [/ session] - Visually hide the field - adds display: none for the field block. It is necessary for working with the condition field.
Select:
Displays a drop-down list with the ability to select 1 parameter.
- Title - displayed above the field.
- Signs before - The arithmetic sign that will stand in front of the field. For example + or + (
- Signs after - The arithmetic sign that will cost after the field. For example - or) -
- List - This field allows you to create options in the drop-down list. In previous versions, the lists were compiled according to the following template:
[price]: field name;
[price2]: field name2;
since version 3.5 the list template has become easier:
price: field name
price2: field name2 - This field participates in the calculation formula - If you want to exclude this field from the calculation formula, select the None option. The selected parameters by the user will be recorded in the session.
- Visually hide the field - adds display: none for the field block. It is necessary for working with the condition field.
Checkbox:
Allows you to make multiple selections from a list.
- Same as the SELECT field except for the parameters:
- Action data - arithmetic sign, which means action between the selected checkboxes.
- By default - You need to specify the number that will be used in the calculation in the case when no checkbox has been selected.
- This field participates in the calculation formula - If you want to exclude this field from the calculation formula, select the None option. The selected parameters by the user will be recorded in the session. It’s worth taking into account the moment, if the field is not involved in the formula, you do not need to specify the “Data action” parameter, then you can see all the data that the user selected in the message to be sent.
Radio:
Allows you to make a single selection from the list.
- Similar to the SELECT field.
Input Text:
Displays a field for user input.
- Signs before - The arithmetic sign that will stand in front of the field. For example + or + (
- Signs after - The arithmetic sign that will cost after the field. For example - or) -
- By default - You need to specify a number that will be used in the calculation in the case when the visitor has not entered anything in the field.
- Price - You need to specify a number that will be associated with the action specified in the field parameter and performed with the data entered by the user.
- Data action - Arithmetic sign, which means the action with the entered data by the visitor and the price of the field.
- Visually hide the field - adds display: none for the field block. It is necessary for working with the condition field.
- This field is involved in the calculation formula - If this field should be excluded from the calculation formula, select No. The selected parameters by the user will be recorded in the session. It’s worth taking into account the moment, if the field is not involved in the formula, you do not need to specify the “Action with data” parameter, then you can see all the data that the user entered in the message being sent.
Input Hidden:
A hidden field that participates in the calculation formula but is not displayed to users.
- Signs before - The arithmetic sign that will stand in front of the field. For example + or + (
- Signs after - The arithmetic sign that will cost after the field. For example - or) -
- Price - You need to specify the number that will be involved in the calculation.
$ _SESSION:
A hidden field that participates in the calculation formula, but is not displayed to users. Allows you to get data from the results of calculators.
- Signs before - The arithmetic sign that will stand in front of the field. For example + or + (
- Signs after - The arithmetic sign that will cost after the field. For example - or) -
- By default - You need to specify the number that will be used in the calculation when the data from the session is empty.
- Calculator ID - Specify the ID calculator, from which to get the data
- Field ID or sum - Specify the field ID or write sum to get the result
jQuery field:
A hidden field that participates in the calculation formula, but is not displayed to users. Allows you to get the value of the field after the action by the user with the specified field.
- Signs before - The arithmetic sign that will stand in front of the field. For example + or + (
- Signs after - The arithmetic sign that will cost after the field. For example - or) -
- By default - You need to specify the number that will be used in the calculation in the case when these fields are empty.
- Field ID - Specify the ID of the field from which you want to copy data. Works for: Input text, Select, Radio, Checkbox, Slider
Arithmetic function:
A hidden field that participates in the calculation formula, but is not displayed to users. Allows you to wrap fields in the selected function and perform certain actions with it during the calculation.
- Signs before - The arithmetic sign that will stand in front of the field. For example + or + (
- Signs after - The arithmetic sign that will cost after the field. For example - or) -
- What function we use - It is possible to select two functions:
1. Extract square root - allows you to extract the square root from a field or group of fields. For correct operation , be sure to wrap the field in brackets. For example:
We want to extract the square root from field 15, so the formula should look like this:
[12] (15) - square brackets only visually indicate that this field is an arithmetic function.
If we want to extract the square root from a group of fields, they should also be wrapped with square brackets:
[12] (15 + 57-11)
2. Raise to a power - allows you to raise a field or group of fields to a power. For correct operation, the field must be enclosed in parentheses! At the end of the bracket, indicate the degree to which the field should be raised. For example, we raise field 10 to degree 2:
[12] (10, 2) - where 2 is the degree.
We must indicate in the “Sign before” or “Sign after” the field that we raise to the power the following parameters :, 2)
Slider:
A field that allows you to display a slider (slider).
- Signs before - The arithmetic sign that will stand in front of the field. For example + or + (
- Signs after - The arithmetic sign that will cost after the field. For example - or) -
- By default - You need to specify a number that displays a slider in the specified interval between the Minimum and Maximum values.
- Visually hide the field - adds display: none for the field block. It is necessary for working with the condition field.
- Minimum value - You need to specify a number, which will be the minimum value of the slider.
- Maximum value - You need to specify a number that will be the maximum value of the slider.
- Step - You need to specify the number with which step the slider will “slide”.
- Position - in what position the slider will be displayed. Vertically or horizontally.
- This field participates in the calculation formula - If you want to exclude this field from the calculation formula, select the None option. The selected parameters by the user will be recorded in the session.
IF VAL Field == Val User Condition:
A field that is not visible to the user, but takes part in the calculation.
- Какое поле сравниваем - Укажите ID поля, значение которого мы будем сравнивать для выполнения условия. Работает для: Input Text, Select, Checkbox, Radio, Slider.
- Какое значение должно быть у поля - Укажите значение, которое будет сравниваться в условии. Например 100
- Какие поля отображаем - Укажите ID полей через запятую, которые нужно отобразить и включить в формулу расчете. У указанных полей параметры «Визуально скрыть это поле» должен быть выставлен: «Да, добавить display: none»
- Какие поля скрываем - Укажите ID полей через запятую, которые нужно скрыть и исключить в формуле расчете. У указанных полей параметры «Визуально скрыть это поле» должен быть выставлен: «Нет»
Как вставить калькулятор на страницу:
When editing a calculator, you can find a shortcode near its name that you can use.
The shortcode is as follows:
[wpcc id="1"]
where 1 is the ID of your calculator.
If you need to insert a calculator in the php theme file, use the following code:
What does “Field Formula Text Formula” mean?
Displays the field structure of your calculator with the characters set in the "before" and "after" parameters.
This paragraph makes it easy to find errors in your formula.
What does string mean?
After calculating the calculator in the administrative panel, you can see the "String" field, which displays data from the fields, their signs "before" and "after".
This line is executed before the sum is displayed.
What is "$ _SESSION ['wpcc_X']"
After calculating the calculator in the administrative panel, you can see the data array from the session. In the array, the key is the field ID, and the value is the result of the field. The sum key contains the result of the calculation.
The array also contains the names of the specified or selected data by the user in the calculator.
Session Array Example
Content
Array
(
[2] => 3
[3] => 9000
[4] => 1
[5] => 19
[8] => 180
[9] => zetrider.ru
[11] => 520
[14] => 850
[names] => Array
(
[2] => Интернет магазин
[3] => Разработать логотип, Фирменный стиль
[4] => Нет
[5] => 19
[8] => Да
[9] => zetrider.ru
[11] => Новости, Регистрация
[14] => 3D экскурсия офиса, Корзина товаров
)
[sum] => 15300
)
What is “ksort (array ())”
After calculating the calculator in the administrative panel, you can see the sorted array of calculating the data with their “before” and “after” signs. Allows you to fully see the picture of the formula. The array key is NOT a field ID. This is the serial number in the array.
How to change calculator styles
In the calculator at the time of writing, 4 simple topics have been created.
The theme files are located in the plugin folder / wp-creator / calculator / theme / name of the theme you selected for the calculator
. Each folder has a style.css file that is responsible for the design of the calculator.
How to use the calculator for other purposes
There are times when you do not need to calculate anything in the calculator, but you need to get data from users.
For example: You want to implement a form in which the choice of a car brand will be offered. The visitor, when choosing a particular car brand using the “Condition” field, displays the following options for the configuration of technical specifications. After all the actions you receive the data that the user has selected.
To implement a similar task, we set “No” for all fields in the parameter: “This field participates in the calculation formula”.
Using CSS, you can hide the field of the calculation result so that the visitor does not see the information that he does not need, in which 0 rubles will be displayed. The style responsible for the block with the result of the calculation: .wpcc_result or wpcc_result_X where X is the ID of your calculator.
How to export a formula
You can copy the serialized array for further transfer or import to another calculator via the "Export Formula" button. In the exported data, all created fields and individual calculator settings are saved.
How to Import a Formula
You can import a previously serialized array from another calculator using the Import Formula button. The imported data contains all the created fields and individual settings of the calculator. If you are importing data from another site (or transmitted from a friend), do not forget to change the e-mail in the calculator settings to which letters will be sent.
CSS calculator
/*
X = ID калькулятора
XF = ID поля
*/
.wpcc {}
.wpcc_x {}
.wpcc_form {}
.wpcc_form_x {}
.wpcc_box {}
.wpcc_box_XF {}
.wpcc_description {}
.wpcc_text {}
.wpcc_text_XF {}
.wpcc_select {}
.wpcc_select_XF {}
.wpcc_checkbox {}
.wpcc_checkbox_XF {}
.wpcc_radio {}
.wpcc_radio_XF {}
.wpcc_inputtext {}
.wpcc_inputtext_XF {}
.wpcc_jq_slider {}
.wpcc_jq_slider_vertical {}
.wpcc_jq_slider_horizontal {}
.wpcc_jq_slider_box {}
.wpcc_jq_slider_box_XF {}
.wpcc_jq_slider_text {}
.wpcc_jq_slider_text_XF {}
.wpcc .ui-slider-horizontal {}
.wpcc .ui-slider-vertical {}
.wpcc .ui-slider-range {}
.wpcc .ui-slider-handle {}
.wpcc_submit {}
.wpcc_submit_X {}
.wpcc_loading {}
.wpcc_result_block {}
.wpcc_result_block_X {}
.wpcc_result {}
.wpcc_result_x {}
.wpcc_mail {}
.wpcc_mail_X {}
.wpcc_mail .wpcc_text {}
.wpcc_mail .input {}
.wpcc_mail .textarea {}
.wpcc_mail .wpcc_submit {}
.wpcc_mail .wpcc_loading {}
.wpcc_mail_success {}
.wpcc_mail_success .wpcc_text {}
.wpcc_widget {}
HTML calculator
How to install the plugin:
1. Download the plugin - http://wordpress.org/plugins/wp-creator-calculator/
2. Upload wp-content / plugins /
3 to the plugins folder of your site. 3. Activate the plugin
4. On the left in the admin panel menu select WPCC
5. Create and customize your calculator.
ps I am looking for a voluntary translator for the plugin and instructions in English.
UPD: Version 3.5.2
- Added parameter for the condition "Condition Operator": ==,>, <,> =, <=
- Added filter parameter for the “Input text” field: only numbers and period
- Fixed error changing the name of the calculator
- Added a new field “Result of fields”. Allows you to select fields and apply arithmetic to them
UPD: video : www.youtube.com/watch?v=eMHBxILCa9s