=== Cost Calculator for Contact Form 7 ===
Contributors: azmarket
Tags: cost calculator, contact form 7, price calculator, quote form, estimate
Requires at least: 5.6
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 2.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Build price estimates and quote forms for Contact Form 7 with a visual formula builder — no field names or syntax to remember.

== Description ==

Cost Calculator for Contact Form 7 turns any Contact Form 7 form into a quote, estimate or price calculator. Add priced options, then build the total with a visual formula builder and see the result live while you edit.

[youtube https://www.youtube.com/watch?v=9lUnzwNFjto]

= Features =

* **Visual Formula Builder** – pick a template, click or drag fields, add operators and functions. Switch to text mode at any time.
* **Live preview** – try the formula with sample values before you save.
* **Unlimited totals** – add as many Calculated fields as you need. A total can use another total (subtotal, tax, grand total).
* **Number & currency format** – symbol and position, thousand and decimal separators, decimals. Presets for $, €, £, ₫, ¥ and ₹.
* **Hide a total** – keep a subtotal off the form but still calculate it and send it by email.
* **Totals in emails** – use `[your-total]` in the Mail tab; it is sent formatted.
* **Priced fields** – Checkbox, Radio and Dropdown fields with "value|label" options. Contact Form 7 number, select, radio and checkbox fields work too.
* **Formulas box** – see and edit every formula from the editor sidebar.
* Safe evaluation – formulas are parsed by the plugin, never with `eval()`.

= Formula syntax =

* Operators: `+ - * /` and brackets `( )`
* Functions: `round()`, `ceil()`, `floor()`, `abs()`, `min(a, b)`, `max(a, b)`
* Example: `quantity * unit_price + shipping`

= Source code =

The admin interface is built with Vue 3. The uncompressed source is included in the `formula-builder` folder; build it with `npm install && npm run build`.

== Installation ==

1. Install and activate Contact Form 7.
2. Upload the plugin to `/wp-content/plugins/` or install it from the Plugins screen, then activate it.
3. Edit a contact form. Under **Calculation**, add priced fields with **Checkbox**, **Radio** or **Dropdown**, then click **Calculated** to build the total.

== Frequently Asked Questions ==

= Where are formulas stored? =

On the contact form itself (post meta). They are saved when you click **Save formula** in the builder or **Save** on the form.

= Can a total use another total? =

Yes. Totals are worked out in the order they appear in the form, so put the total you reuse above the one that uses it.

= How do I show the total in the email? =

Use the Calculated field's name as a mail-tag, for example `[calculated-496]`. It is formatted with the field's display settings.

= Can I change the default currency symbol? =

Yes, per total in the builder's **Display** section, or for new totals with the `bh_cf7_cc_currency_symbol` filter.

== Screenshots ==

1. Formula Builder popup with templates, fields and live preview.
2. Display settings: currency, separators, decimals, hide and align.
3. Formulas box in the Contact Form 7 editor sidebar.

== Changelog ==

= 2.0.0 =
* New: visual Formula Builder (Vue 3) that opens from the **Calculated** button — templates, drag & drop fields, text mode and live preview.
* New: Formulas box in the editor sidebar to view and edit every formula.
* New: unlimited Calculated fields per form; a total can use another total.
* New: display settings for each total — currency symbol and position, separators, decimals (presets for $, €, £, ₫, ¥, ₹), hide on form, alignment.
* New: totals are submitted with the form and can be used as formatted mail-tags.
* New: Contact Form 7 number, select, radio and checkbox fields can be used in formulas.
* New: required (*) option for Checkbox, Radio and Dropdown fields; Slider renders as a range input.
* Improved: redesigned Calculation buttons; tag generator works with Contact Form 7 6.x.
* Security: formulas are evaluated by a built-in parser instead of `eval()`; saving requires a nonce and edit permission; all output is escaped.
* New: formulas and settings are removed when the plugin is deleted.

= 1.0.0 - 2018-07-01 =
* Released.

== Upgrade Notice ==

= 2.0.0 =
New visual Formula Builder, unlimited totals and currency formatting. Formulas from 1.0.0 keep working.
