| 开发者 | asaricrm |
|---|---|
| 更新时间 | 2026年10月4日 23:47 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
=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:
html_class attribute to the form shortcode: [contact-form-7 id="123" html_class="asari-calculator-asari-calc-1"],<div class="asari-calculator-asari-calc-1"> ... </div>,data-asari-calculator="asari-calc-1" on a parent element in the page content.class: option, e.g. [number salary class:b3-edit]):
b3-edit writes the field value into cell B3 before calculation.b27-read displays the calculated value of cell B27. Read fields are made read-only, so their values are still sent with the form.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.= is a formula. Supported syntax:
B1, B1:B4 (case-insensitive),12.5, "yes" (write "" for a quote inside text),+ - * / % ^,= <> < > <= >= (also == and !=),&&, ||, !, TRUE, FALSE,SUM, AVERAGE (AVG), MIN, MAX, ROUND, ABS, CEIL, FLOOR, IF,, or ;.=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.
asari-calculators folder to /wp-content/plugins/ or install the plugin from the Plugins screen, then activate it.bN-edit / bN-read classes to its fields.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.
Yes. Return false from the asari_calculators_live_recalculation filter; the calculator then recalculates only on page load and before submission.
Deleting the plugin from the Plugins screen removes all calculators (the asari_calculators_data option, on every site of a multisite network). Deactivating keeps them.
Use the asari_calculators_enqueue_all_frontend_calculators filter (return true) to load all calculators, or asari_calculators_frontend_calculators to choose them for the current page.
Requires Plugins header); when it is missing or inactive, an admin notice links to install or activate it and calculators are not loaded on the frontend.html_class or a wrapper element in the form template.<, <> and <= are saved unchanged instead of being stripped or HTML-encoded.asari_calculators_live_recalculation filter); results are also restored after Contact Form 7 resets the form.uninstall.php removes the calculators when the plugin is deleted.1 000,50, 1.000,50, 10,000.50, -5 zł, yes/no words), results shown with the site decimal point, and the asari_calculators_number_format filter.IF evaluates 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.