=== Onlinefotka Checkout Field Editor for WooCommerce ===
Contributors: onlinefotka
Tags: woocommerce, checkout fields, custom fields, checkout editor, field editor
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
WC requires at least: 7.0
WC tested up to: 9.9
Stable tag: 1.2.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Edit, reorder, add and remove WooCommerce checkout fields with drag-and-drop, conditional logic, validation rules, and full block checkout support.

== Description ==

**Checkout Field Editor by Onlinefotka** gives you complete control over the WooCommerce checkout page — without touching any code.

Edit existing fields, add custom ones, reorder everything with drag-and-drop, hide fields based on conditions, and validate input with your own rules.

Built for both the classic WooCommerce checkout and the new block-based checkout (WC 8.6+).

=== Edit Built-in WooCommerce Fields ===

* Change labels and placeholder text for all billing, shipping, and order fields
* Mark fields as required or optional
* Enable or disable individual fields
* Drag-and-drop reorder fields within each section
* Reset any section back to WooCommerce defaults with one click

=== Add Custom Fields ===

* Add unlimited custom fields to billing, shipping, or order sections
* Field types: Text, Email, Phone, Number, Textarea, Select, Radio, Checkbox, Date, Hidden
* Set label, placeholder, description (helper text shown below the field), and CSS class
* Control sort order within the section
* Show or hide the field value in WooCommerce admin order details
* Show or hide the field value in WooCommerce order emails

=== Conditional Logic ===

* Show a field only when specific conditions are met
* Conditions can reference any checkout field — built-in WooCommerce fields or your own custom fields
* Operators: equals, not equals, contains, not empty, is empty
* AND logic — all conditions must be true for the field to appear
* Hidden fields are automatically excluded from required validation and are not saved to the order

=== Validation Rules ===

* Add a custom regex pattern to any text-type field (e.g. `^SK[0-9]{10}$` for Slovak VAT numbers)
* Set a custom error message displayed when the pattern does not match
* Validation only runs when the field has a value — empty optional fields are not rejected

=== Block Checkout Support (WC 8.6+) ===

* Custom fields of type Text, Select, and Checkbox are automatically registered with the WooCommerce Blocks checkout API
* Works alongside classic checkout — both can coexist on the same site
* Field values are saved consistently regardless of which checkout type the customer used

=== Virtual & Downloadable Products ===

* Optionally hide the entire shipping address section when the cart contains only virtual or downloadable products
* If the cart contains at least one physical product, shipping fields are shown normally

=== Order Data ===

* Custom field values are displayed in the WooCommerce admin order detail page
* Custom field values are included in WooCommerce order emails (configurable per field)
* Values are saved to order meta and accessible via WooCommerce order methods

=== Translations ===

The plugin interface is available in the following languages:

* **English** (built-in)
* **Slovak** (sk_SK)
* **German** (de_DE / Deutsch)
* **Czech** (cs_CZ / Čeština)

Want to translate the plugin into your language? The `.pot` template file is included in the `languages/` folder. You can also contribute translations via [translate.wordpress.org](https://translate.wordpress.org/).

=== Requirements ===

* WordPress 6.0 or higher
* WooCommerce 7.0 or higher
* PHP 7.4 or higher

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install via **Plugins → Add New**
2. Activate the plugin through the **Plugins** screen
3. Navigate to **WooCommerce → Checkout Fields** to start editing

== Frequently Asked Questions ==

= Does this work with the WooCommerce block checkout? =

Yes. Custom fields of type Text, Select, and Checkbox are automatically registered with the WooCommerce Blocks checkout API (requires WooCommerce 8.6+). Types Textarea, Radio, and Hidden appear on classic checkout only — the Blocks API does not support these types natively.

= Can I reorder the built-in WooCommerce fields? =

Yes. On the Billing, Shipping, and Order tabs you can drag rows to change the order. The new order is saved automatically via AJAX and also when you click Save Changes.

= Will my changes affect the block checkout? =

Label, placeholder, required and sort-order changes for built-in WooCommerce fields (First Name, Email, etc.) apply to classic checkout only. Block checkout controls its own built-in fields natively. Custom fields you add are registered in both checkout types.

= What happens to field values when I delete a custom field? =

The field definition is removed from the database and the field no longer appears at checkout. Previously collected order meta values (customer data) are NOT deleted — they remain on the orders where they were saved.

= Can I use conditional logic to hide the VAT field for individual customers? =

Yes. Add a Select or Radio field like "Customer type" with options "Individual" and "Business", then add your VAT field with a condition: Customer type equals Business.

= Does the regex validation work on both classic and block checkout? =

Regex validation runs server-side during `woocommerce_checkout_process` (classic) and is also applied via the Store API for block checkout orders.

= What is the CSS class field for? =

WooCommerce uses CSS classes to control field width. Common values: `form-row-wide` (full width), `form-row-first` (left half), `form-row-last` (right half).

= Does this plugin delete my data when uninstalled? =

No, by default no data is deleted on uninstall. You can enable "Delete all plugin data on uninstall" in Settings if you want a clean removal.

== Screenshots ==

1. Billing Fields — sortable list of built-in WooCommerce billing fields with label, placeholder, required and enabled toggles
2. Custom Fields — list of custom fields with type, section, required badge and quick enable toggle
3. Add Custom Field — form with label, key, type, section, placeholder, description, options, validation regex and conditional logic builder
4. Settings — shipping field options, hide shipping for virtual products, data settings
5. Conditional Logic builder — add conditions referencing any checkout field with operator selector

== Changelog ==

= 1.2.4 =
* Added "Buy me a coffee" PayPal donate link in the plugin action links (WP admin → Plugins list)
= 1.2.3 =
* Fix: "Country is required" validation error on checkout when billing_state was marked required in admin — plugin now respects WooCommerce's locale decision to make state not-required for countries without states (e.g. Slovakia)
= 1.2.2 =
* Fix: WooCommerce address-i18n JS was also resetting field CSS classes (form-row-first/last) per country locale — now overriding locale classes so admin-configured widths are always respected
= 1.2.1 =
* Fix: WooCommerce address-i18n JS was re-sorting checkout fields by country locale after PHP render — now overriding locale priorities so admin-configured order is always respected
= 1.2.0 =
* Added live Checkout Preview panel in the custom field editor — see exactly how the field will look on the checkout page as you edit it
* Added German (de_DE) translation
* Added Czech (cs_CZ) translation
* Updated Slovak (sk_SK) translation
= 1.1.0 =
* Added visual field width picker (Full / Left ½ / Right ½) for built-in and custom fields
* Added Cart Fields tab — collect extra information on the Cart page before checkout
* Cart field values saved to WooCommerce session and transferred to order meta on completion
* Added Slovak (sk_SK) translation
* Added languages/.pot template for community translations

= 1.0.0 =
* Initial release
* Edit built-in WooCommerce billing, shipping and order fields
* Drag-and-drop reordering with AJAX persistence
* Custom fields: Text, Email, Phone, Number, Textarea, Select, Radio, Checkbox, Date, Hidden
* Description / helper text per custom field
* Regex validation with custom error messages
* Conditional logic with AND rules
* Show custom field values in admin order detail and order emails
* Block checkout support via WooCommerce Blocks API (WC 8.6+)
* Hide shipping fields for virtual / downloadable products
* Reset any section to WooCommerce defaults
* HPOS (High Performance Order Storage) compatible
