描述
ASARI Calculators adds a spreadsheet editor to WordPress and connects it to the Contact Form 7 forms you already use, so you do not need to rebuild them in a separate form builder. You model the calculation the way you would in a spreadsheet: values and formulas such as =ROUND(B2*B3,2) or =IF(B4>0,B2/B4,0) in a grid of cells, edited under ASARI Calculators in the admin menu. Then you bind cells to form fields by adding a class such as b2-edit to an input or b7-read to a result. Results update live as visitors type, are sent in the Contact Form 7 email, and follow Polish and English number formats.
The plugin requires Contact Form 7. Until Contact Form 7 is installed and active, an admin notice is shown and calculators are not loaded on the site.
Example calculator
The Add example calculator button at the top of the ASARI Calculators screen creates a ready-made loan or lease instalment calculator (amount, annual interest rate, number of months monthly instalment, total cost, total interest) together with its Contact Form 7 form. The calculator then shows the form shortcode to paste into a page, with a Copy button and a link to edit the form. Labels are created in the site language. The button is shown until the example calculator exists.
Connecting a calculator to a form
Mark the form with the calculator ID, in one of these ways:
- add the
html_classattribute to the form shortcode:[contact-form-7 id="123" html_class="asari-calculator-asari-calc-1"], - or wrap the fields in the form template:
<div class="asari-calculator-asari-calc-1"> ... </div>, - or, outside Contact Form 7 markup, use
data-asari-calculator="asari-calc-1"on a parent element in the page content.
Then bind fields or text elements to cells with classes (in Contact Form 7 tags use the class: option, e.g. [number salary class:b3-edit]):
b3-editwrites the field value into cell B3 before calculation.b27-readdisplays the calculated value of cell B27. Read fields are made read-only, so their values are still sent with the form.- A read list, radio or checkbox selects the option that matches the result, either the same text (
High) or a label that reads as the same number (Yes - ...for 1,1,67%for 1.67). The other options are locked, and the selected one is sent with the form. A single checkbox is checked when the result is not 0.
Results update live while visitors fill in the form, and the calculator also recalculates when the page loads, immediately before the form is submitted and after Contact Form 7 resets the form.
Formulas
A cell starting with = is a formula. Supported syntax:
- cell references and ranges:
B1,B1:B4(case-insensitive), - numbers and text in double quotes:
12.5,"yes"(write""for a quote inside text), - arithmetic:
+ - * / % ^, - comparisons:
= <> < > <= >=(also==and!=), - logic:
&&,||,!,TRUE,FALSE, - functions:
SUM,AVERAGE(AVG),MIN,MAX,ROUND,ABS,CEIL,FLOOR,IF, - argument separator:
,or;.
Examples: =B1*2, =SUM(B1:B4), =ROUND(B1/12,2), =IF(B1>0,B1,0), =IF(B3>5000,"high","low").
Formulas are evaluated by the plugin’s own parser; they cannot run JavaScript. A formula that cannot be parsed shows an empty value.
Numbers in Polish and English
Field values are read in both Polish and English formats: 1 000,50, 1.000,50 and 10,000.50 all work, a label such as Basic - 250 zł becomes 250, -5 zł becomes -5 and 1,67% becomes 1.67. Labels starting with Tak / Yes / True become 1, and Nie / Bez / No / False become 0. A single separator followed by three digits (1,234) follows the site language: on a Polish site 1,234 is 1.234 and 1.234 is 1234, on an English site the other way round. Number inputs are always read exactly.
Results in text fields and elements use the site decimal point, e.g. 7147,39 on a Polish site; number inputs always get 7147.39. Use the asari_calculators_number_format filter to add a thousands separator, e.g. array( 'decimal' => ',', 'thousands' => ' ' ) for 7 147,39.
The plugin includes a Polish translation (used on WordPress 6.8 and later); WordPress.org language packs take precedence when available.
螢幕截圖


b2-edit and b7-read classes inside the calculator wrapper.

IF formula that returns text, used to fill a read field.安裝
- Install and activate Contact Form 7.
- Upload the
asari-calculatorsfolder to/wp-content/plugins/or install the plugin from the Plugins screen, then activate it. - Go to ASARI Calculators and click Add example calculator, or build your own calculator and save it.
- Mark a Contact Form 7 form with the calculator ID and add
bN-edit/bN-readclasses to its fields.
常見問題
-
Does the plugin load scripts on every page?
-
No. The frontend script and style load only on requests that render a marked Contact Form 7 form or contain a calculator marker in the page content, and only the calculators used there are printed into the page.
-
Can results be calculated only when the form is submitted?
-
Yes. Return
falsefrom theasari_calculators_live_recalculationfilter; the calculator then recalculates only on page load and before submission. -
What happens to my calculators when I delete the plugin?
-
Deleting the plugin from the Plugins screen removes all calculators (the
asari_calculators_dataoption, on every site of a multisite network). Deactivating keeps them. -
My calculator is inserted in a way the plugin does not detect.
-
Use the
asari_calculators_enqueue_all_frontend_calculatorsfilter (returntrue) to load all calculators, orasari_calculators_frontend_calculatorsto choose them for the current page.
評價
There are no reviews for this plugin.
貢獻者及開發者
修改日誌
1.0.1
- Changed: The plugin description links to the ASARI website (asaricrm.com).
1.0.0
- Added: Add example calculator button that creates a loan instalment calculator with its Contact Form 7 form; calculators linked to a form show its shortcode with a Copy button and an Edit form link.
- Added: Contact Form 7 is a required plugin (
Requires Pluginsheader); when it is missing or inactive, an admin notice links to install or activate it and calculators are not loaded on the frontend. - Added: Calculators load automatically for Contact Form 7 forms inserted with the shortcode or block, marked with
html_classor a wrapper element in the form template. - Added: The browser warns before leaving the ASARI Calculators screen with unsaved changes (edits, added or deleted calculators); saving does not trigger the warning.
- Fixed: Deleting the last calculator and saving now leaves the list empty instead of bringing back the default calculator.
- Fixed: Read lists, radios and checkboxes select the matching option and are sent with the form (they were disabled and missing from Contact Form 7 emails, and radio and checkbox groups were replaced by plain text).
- Fixed: Saving a calculator that contained a double quote no longer replaces all calculators with the default one; unreadable submitted data now keeps the previous calculators and shows an error.
- Fixed: Formulas with
<,<>and<=are saved unchanged instead of being stripped or HTML-encoded. - Security: Formulas are evaluated by a dedicated parser instead of being compiled to JavaScript, so a formula can no longer execute code in visitors’ browsers.
- Added: Live recalculation while visitors edit bound fields (can be turned off with the
asari_calculators_live_recalculationfilter); results are also restored after Contact Form 7 resets the form. - Added:
uninstall.phpremoves the calculators when the plugin is deleted. - Added: Polish and English number formats in field values (
1 000,50,1.000,50,10,000.50,-5 zł, yes/no words), results shown with the site decimal point, and theasari_calculators_number_formatfilter. - Added: Translatable editor interface and a bundled Polish translation.
- Changed: One shared formula engine for the editor and the frontend; cell references are case-insensitive,
IFevaluates only the selected branch, text in formulas may contain non-ASCII letters, comparisons return 1 / 0 (usable in other formulas) and a bare range outside a function is an error.
0.1.0 – 0.1.3
- Internal development releases, not published.
