=== Ditobreak Fiscal Checkout Fields ===
Contributors: ditobreak
Requires at least: 6.4
Tested up to: 6.8
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.3.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Adds Italian fiscal fields to the WooCommerce checkout with formal validation, fail-safe compatibility checks, and support for both WooCommerce legacy order storage and HPOS.

== Description ==

This plugin adds the following WooCommerce checkout fields:

* Customer type: private customer or company / VAT holder
* Codice Fiscale
* Partita IVA
* Codice SDI
* PEC

It stores all values as WooCommerce order meta through the WooCommerce order object, avoiding direct post meta writes. This keeps the plugin compatible with both WooCommerce legacy order storage (WordPress posts/postmeta) and High-Performance Order Storage (custom order tables).

== Order storage compatibility ==

The plugin works whether HPOS is enabled or disabled. It uses WooCommerce order CRUD methods, so WooCommerce decides where the data is stored: legacy posts/postmeta when HPOS is off, or custom order tables when HPOS is on.

The plugin does not require HPOS and does not show any warning just because HPOS is disabled.

== Fail-safe compatibility behavior ==

The plugin does not stop working just because WordPress or WooCommerce are updated beyond the tested version.
It continues running on future versions as long as the required WooCommerce and WordPress APIs are still available.

If a real incompatibility is detected, such as WooCommerce being inactive, minimum versions not being met, or required order APIs being missing, the plugin does not register checkout functionality and shows an admin-only notice. This avoids breaking the public site.

== Validation rules ==

Private customer:

* Codice Fiscale is required and must be formally valid as a 16-character Italian personal tax code.
* Partita IVA is not allowed.
* SDI is optional and defaults to 0000000 when empty.
* PEC is optional but must be a valid email when filled.

Company / VAT holder:

* Partita IVA is required and must be formally valid as an Italian VAT number. Optional IT prefix is accepted.
* Codice Fiscale is optional; if filled, it can be a valid 16-character personal code or an 11-digit entity code.
* At least one electronic invoice address is required: SDI or PEC.
* SDI must be 7 alphanumeric characters. 0000000 is accepted.
* PEC must be a valid email when filled.

== Installation ==

1. Upload the ZIP from Plugins > Add New > Upload Plugin.
2. Activate the plugin.
3. Deactivate any old checkout field plugin that duplicates the same fields.
4. Run a test order before using it in production.

== Changelog ==

= 1.3.0 =
Clarified and documented support for both WooCommerce legacy order storage and HPOS. The plugin does not require HPOS and never warns merely because HPOS is disabled.

= 1.1.0 =
Added fail-safe compatibility checks, admin-only incompatibility notices, defensive hook signatures and checkout JavaScript file.

= 1.0.0 =
Initial release.

== Changelog ==

= 1.3.0 =
* Added dedicated top-level WordPress admin menu page "Dati fiscali" with Dashicon icon.
* Added compatibility/status checks page for PHP, WordPress, WooCommerce, CRUD order APIs and HPOS status.
* Added minimal settings for enabling checkout fields, default SDI for private customers, business invoice channel requirement and output locations.
