=== H6 Smart Checkout Fields for WooCommerce ===
Contributors: hutsixdigital
Tags: woocommerce, checkout fields, checkout manager, conditional fields, checkout editor
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 2.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Add your own questions to the WooCommerce checkout, change the standard fields, charge for extras and control delivery dates.

== Description ==

H6 Smart Checkout Fields lets you ask customers exactly what you need at checkout, without writing code. Add a gift message, a VAT number, a delivery date or an engraving name. Rename, reorder or hide the standard WooCommerce fields. Charge for extras, choose which delivery dates customers can pick, and only ask a question when it applies to the order.

It is built for shop owners, not developers. The settings are written in plain English, every question has a short editor with the basics up front, and a "Try it out" tab shows you what a customer would be asked and charged before you go live.

Everything is included. There is no paid version and nothing is locked.

**Good for:**

* Gift messages, gift wrapping and personalisation
* Trade and wholesale details such as VAT numbers and purchase order numbers
* Delivery and collection dates, with the days you are closed ruled out
* Uploads such as artwork, proof of age or a purchase order
* Anything else you need to know before you can fulfil an order

= Change the standard fields =

* Rename any field and change the hint shown in the box
* Make fields required or optional
* Hide fields you do not need, such as the phone number
* Drag fields into the order you want
* Undo your changes and go back to WooCommerce's own wording at any time

= Ask your own questions =

* Short and long answers, dropdown lists, pick-one buttons, pick several and tick boxes
* Email address, phone number, number, date, time, date and time, and colour
* File uploads, with the file types and size you choose
* Headings and notes to break up a long checkout
* A hidden value saved with every order, for your own records
* Full or half width, placed with the billing details, the delivery address or the order notes

= Show a question only when it applies =

* Based on another answer, such as "Is this a gift?"
* Based on the order: products or categories in the cart, the subtotal or the number of items
* Based on the customer: their customer type, such as trade customers
* Based on their choices: delivery method, payment method, billing or delivery country
* Questions appear and disappear on the checkout as the customer makes their choices
* The same rules can make a question compulsory only in some cases

= Charge for an answer =

* A set amount, a different price for each choice, an amount for every item, or a percentage of the subtotal
* Optional minimum and maximum charges
* Your own name for the charge in the order total, with or without tax
* The total updates as soon as the customer picks an option
* A hidden question never adds a charge

= Check the answer =

* Shortest and longest answer allowed
* Must match or differ from another answer, such as a "confirm email" box
* Must be a proper email address, or a number within a range
* Your own message if the check fails

= Delivery and collection dates =

* Set the earliest date customers can pick, such as at least 3 days away
* Set the latest date, such as up to 60 days ahead
* Close days of the week, such as weekends, and single dates, such as bank holidays
* Add a cut-off time, so orders placed after 2pm count from the next day
* The date picker greys out dates outside the range, and every date is checked again when the order is placed, in your shop's time zone

= Ask once per item, and group questions =

* Ask a question once for every item or every product in the cart, such as a name to engrave on each item
* Group questions under their own heading in one of five places on the checkout, and show the whole group only when it applies

= After the order =

* Answers appear on the order screen, the thank-you page, the customer's account and order emails, and you choose where
* Show any answer as a column in your orders list, and find orders by it
* Uploaded files are linked from the order

= Move over from another plugin =

* Import your questions from Flexible Checkout Fields, with a preview first and an undo afterwards
* Keep the original field names, so past and new orders share one name and exports, invoice templates and other plugins keep working
* Choose the field name prefix, or turn it off, and keep a field name exactly as another plugin expects it
* Old answers still show under a question's new name, and can be copied across without deleting anything
* Save dates in the format your past orders use, such as 07.10.2026

= Try it out and back up =

* Describe an order and see which questions a customer would get, which they must answer and what they would pay
* Download a backup of your set-up, or move it from a test site to your live shop

== Installation ==

1. In your WordPress dashboard go to Plugins > Add New, search for "H6 Smart Checkout Fields" and click Install, then Activate. Or upload the plugin folder to `/wp-content/plugins/` and activate it.
2. Go to WooCommerce > H6 Smart Checkout Fields.
3. Choose a tab, click "Add a question" or "Edit" on a standard field, then save.

WooCommerce must be installed and active, and your checkout page must use the classic checkout (see the FAQ).

== Frequently Asked Questions ==

= Does it work with the block checkout? =

Not yet. It changes the classic WooCommerce checkout. If your checkout page uses the newer Checkout block, the settings screen tells you, and you can switch the page back to the classic checkout. (For developers: the classic checkout is the `[woocommerce_checkout]` shortcode.)

= Can I show a question only for some orders? =

Yes. Open the question, choose "When to show it", and add rules such as "Categories in the cart include Gifts" or "Customer type is Trade customer". You can also show a question based on another answer.

= Can I limit which dates customers can pick? =

Yes. Add a Date or "Date and time" question, open "Check the answer", and set the earliest and latest dates in days from today, the days of the week you are closed, any dates you are closed and an optional cut-off time. For example, "at least 3 days away, not at weekends, not on 25 December".

= Can customers be charged for an answer? =

Yes. Open the question and choose "Charge for it". For dropdowns and pick-several questions you can set a different price beside each choice. The charge appears in the order total as soon as the customer picks it.

= Can I make a question compulsory only sometimes? =

Yes. "When it must be answered" works like "When to show it", so you can make a VAT number compulsory for trade customers only, for example.

= How do I check my rules before customers see them? =

Use the "Try it out" tab. Choose what is in the cart, the customer type, the delivery and payment methods and the countries, and you will see which questions appear, which must be answered and what they would cost.

= Are file uploads safe? =

Each upload is checked on the server against the file types and size you allow, and program and script files are always refused, whatever the settings say. Files are stored in a protected folder and linked from the order.

= Where do the answers appear? =

On the order screen, and wherever you choose from: the thank-you page, the order page in the customer's account, order emails to the customer and order emails to you. You can also add any answer as a column in your orders list.

= Will I lose my settings when I update? =

No. Your questions and changes to the standard fields carry over. You can also download a backup from the Backup tab first.

= I'm switching from Flexible Checkout Fields. Will I lose my old answers? =

No. Old orders keep their answers and nothing on an order is deleted or overwritten. On the Import tab, preview what will be brought over, then import. By default each question keeps its original field name, so new orders store answers under the same name as old ones and your exports and invoice templates keep working. If a question has to take a new name, the old name is added as an "other name for this answer" and past answers still show.

= What are the field name and prefix? =

Every question has a field name. Answers are stored on the order under that name with an underscore in front, for example a field named shipping_region is stored as _shipping_region. By default this plugin puts h6_ in front of the names it makes. Under Field names you can change that prefix or leave it empty, and in a question's Advanced section you can use a name exactly as typed. Another plugin may read an answer by its exact name, so don't rename those.

= Which fields can't I use as a field name? =

WooCommerce's own checkout fields, such as billing_email or order_comments, and a name already used by another question. You'll see an error when you save instead of the name being changed.

= How do I copy old answers to a question's current name? =

Add the old name under "Other names for this answer". Past answers then show without any change to the order. To also store them under the current name, use "Copy old answers to current keys" on the Backup tab, or run `wp h6scf migrate-meta --all-fields`. It only fills names that are empty, never deletes the old answer and is safe to repeat.

= Can I script the move across several shops? =

Yes. With WP-CLI: `wp h6scf import-fcf --dry-run` previews, `wp h6scf import-fcf --mode=merge` imports (add `--mode=replace` to replace your set-up, `--no-keep-keys` to use the prefix, `--source=inspire` for the older Flexible Checkout Fields copy, `--format=json` for scripts), `wp h6scf export --file=backup.json` and `wp h6scf import --file=backup.json` move a set-up between sites, and `wp h6scf migrate-meta` copies old answers. Commands exit with an error code if something fails.

= Is it compatible with WooCommerce's order tables (HPOS)? =

Yes.

== Screenshots ==

1. Billing details: the standard fields and your own questions in one list, with a show or hide switch and drag to reorder.
2. Editing a question: choices with their own prices, and a rule to show it only when the cart is over £25.
3. What customers see: extra questions, a question asked once per item, and the gift wrapping charge in the order total.
4. Try it out: describe an order and see which questions a customer would get and what they would pay.
5. Answers shown as columns in your orders list.

== Changelog ==

= 2.1.0 =
* New: import your questions from Flexible Checkout Fields, with a preview, a merge or replace choice and an undo. Also available with WP-CLI (`wp h6scf import-fcf`).
* New: choose the field name prefix, or use none, and keep a question's field name exactly as typed so other plugins that read it keep working. Reserved WooCommerce names and repeated names are refused when you save, with a clear message.
* New: other names for a question's answer, so orders saved under an older field name still show their answers, in the admin, emails, the thank-you page, the customer's account and the orders list. Nothing on the order changes.
* New: copy old answers to the current field name, from the Backup tab or `wp h6scf migrate-meta`. It never deletes or overwrites.
* New: a Field names tab listing what each question is sent as and stored under, and a warning when changing a field name would hide answers on existing orders.
* New: choose the format a date is saved and shown in, and the value a tick box saves, so new orders match old ones.
* Backups now include these settings. Backups from earlier versions still restore.
* The Flexible Checkout Fields import works while that plugin is still active, and carries over customer role rules (including on standard fields). Standard fields it does not show, such as the shipping phone, are switched off to match. A rule that cannot be copied imports the question switched off rather than shown to everyone.
* A switched-off billing or shipping country stays in the form, out of sight, so tax, shipping and payment still get a country.
* Developers: add importers for other plugins with the h6scf_importers filter and the H6SCF_Importer interface.
* Existing shops are unchanged: questions keep their names and the h6_ prefix stays unless you change it.

= 2.0.0 =
* New: show a question only for certain carts, customers, countries, delivery methods or payment methods, and make it compulsory only in some cases.
* New: charge for an answer, with a set amount, a price per choice, an amount per item or a percentage, with optional minimum and maximum charges.
* New answer types: pick several, time, date and time, colour and hidden value.
* New: check that an answer matches or differs from another answer, is a proper email address or is a number within a range.
* New: limit the dates customers can pick for a delivery or collection date: earliest and latest date, closed days of the week, closed dates and a cut-off time.
* New: ask a question once for every item in the cart, and group questions under their own heading anywhere on the checkout.
* New: show answers as a column in your orders list and find orders by them.
* New: "Try it out" tab to see what a customer would be asked and charged, and a Backup tab to save or move your set-up.
* Redesigned settings screen for shop owners: a plain-English summary, tabs named after the checkout's own sections, drag to reorder, and a question editor that keeps the basics up front with everything else tucked away.
* Rules are built from dropdowns of your own categories, products, customer types, delivery methods, payment methods and countries, instead of typed codes.
* Fixed: questions with cart, customer, payment, delivery or country rules now appear and disappear on the checkout page itself, not just when the order is placed.
* Fixed: a question hidden by another answer, or inside a hidden group, no longer adds its charge.
* Fixed: every copy of a required repeated question inside a group must now be filled in.
* Fixed: order search finds custom answers on stores using WooCommerce's order tables.
* Fixed: the choices of a dropdown can be edited again.
* Fixed: restoring a backup no longer loses dropdown choices, file-type limits or changes to standard fields.
* Clearer message when a number is outside the allowed range.
* For developers: filters and actions to add your own answer types, rules and settings.
* Everything is included; there is no paid version. Your existing settings are preserved.

= 1.2.0 =
* Added conditional display logic to show or hide custom fields based on another field's value.
* Added field validation with minimum length, maximum length, and regular-expression pattern matching.
* Added new custom field types: date, radio buttons, password, heading/description, and secure file upload.
* Added per-field file upload controls for allowed file types and maximum size, with script and executable types always blocked.
* Custom field data, including uploaded files, now displays as links in admin orders and emails.
* Updated translation metadata and release package cleanup.

= 1.1.1 =
* Improved settings sanitisation for checkbox controls.
* Improved display of select field values in admin orders, emails, and customer order views.
* Updated translation metadata and release package cleanup.

= 1.1.0 =
* Added the ability to turn off custom fields on order pages and emails.
* Complete redesign of the checkout field builder UI.
* Added tabbed Billing, Shipping, and Order field management.
* Added drag-and-drop field builder rows.
* Added dedicated add-field modal workflow.
* Added inline editing for custom fields.
* Added checkout fields reset button.
* Improved field badges, spacing, and admin styling consistency.
* Simplified field management and action controls.
* Improved responsive admin layouts.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 2.1.0 =
Adds an importer for Flexible Checkout Fields, control over field names and the prefix, and tools so old orders keep showing their answers. Your existing settings are unchanged.

= 2.0.0 =
Major update: rules, charges, delivery date limits, extra answer types and a much simpler settings screen, all built in and free. Your existing settings are preserved.

= 1.2.0 =
Adds conditional field logic, validation rules, and new field types including date, radio, password, and secure file uploads.

= 1.1.0 =
Major improvements to the checkout field builder interface with a cleaner workflow, improved field management, and refined admin UX.
