=== Fiscalità ITA Light ===
Contributors: dot4all
Donate link: https://dot4all.it
Tags: woocommerce, italy, vat, tax, vies
Requires at least: 6.2
Tested up to: 6.9
Requires PHP: 7.4
WC tested up to: 10.3.3
Stable tag: 3.2.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Italian fiscal fields for WooCommerce: VAT, tax code, SDI/PEC, customer type, optional VIES validation.

== Description ==
**Fiscalità ITA Light for WooCommerce** adds the Italian fiscal fields required at checkout and the logic for visibility, requirement, and invoicing.

### Main features
- Custom fields: **VAT (P.IVA)**, **Tax Code (Codice Fiscale)**, **SDI Code**, **PEC**, **Customer type** (Private / Company / Freelancer).
- Automatically shows/hides fields based on **customer type** and **country** (with “Limit to Italy” option).
- **VIES** validation with cache, retry, and fallback (checkVatApprox).
  If valid, VAT is removed automatically, including **Checkout Blocks (Store API)**.
- Compatible with **WooCommerce PDF Invoices & Packing Slips** (separate numbering for receipts).
- “VAT not applied (VIES)” badge in checkout, thank you page, emails, and admin.
- VIES column in the orders list and visual tag in the order view.
- Fully compatible with High Performance Order Storage (HPOS).

### Settings
Find settings in **WooCommerce → Fiscalità ITA**:
- Enable/require Italian fiscal fields.
- Enable/disable **VIES** validation and set your requester VAT.
- Configure prefixes and counters for PDF receipts.

### Compatibility
- WooCommerce 7.0+ (tested up to **10.3.3**)
- Classic checkout and Checkout Blocks (Store API)
- PHP 7.4+
- WPML / Polylang / Loco Translate (tested)

== External services ==
This plugin connects to the EU VIES VAT validation web service provided by the European Commission (VIES) to validate EU VAT numbers and apply VAT exemption for eligible B2B customers.

Data sent: country code and VAT number entered at checkout; if configured, the requester country code and requester VAT number.
When: only when VIES validation is enabled and the customer is checking out with a VAT number.

Service terms/legal disclaimer: https://european-union.europa.eu/legal-notice_uk
Privacy policy: https://commission.europa.eu/privacy-policy-websites-managed-european-commission_en

== Installation ==
1. Install and activate the plugin like any other WordPress extension.
2. Open **WooCommerce → Fiscalità ITA** to configure options.
3. (Optional) Enter your Italian VAT as “VIES requester” for more reliable checks.
4. Test checkout with a valid EU VAT to confirm VAT removal.

== Changelog ==
= 3.2.2 =
* Corretto il salvataggio delle caselle di controllo: le opzioni disattivate, tra cui "Abilita P.IVA", non vengono più riattivate dopo il salvataggio.
* Corretta la gestione dei valori disattivati per campi fiscali, integrazione PDF e opzioni VIES.
* Gli aggiornamenti parziali delle impostazioni tramite API REST conservano i valori delle opzioni non inviate.

= 3.2.1 =
* Declared and tested compatibility with **WooCommerce 10.3.3**.
* Refinements: hook priority for live VAT removal, improved Store API handling (Blocks).

= 3.2.0 =
* New VIES validation with cache, retry, and fallback (checkVatApprox).
* Automatic VAT removal on classic checkout and Checkout Blocks.
* Informational badges in checkout, thank you page, emails, and admin.
* VIES column in orders list and tag in order view.
* “Limit to Italy” option improved (dynamic field hide when country ≠ IT).
* HPOS and WooCommerce PDF Invoices & Packing Slips compatibility.
* JS/session refactor (works for guest users).
* Security and sanitization improvements.
* Updated translations (IT/EN).

== Upgrade Notice ==
= 3.2.2 =
Corregge il salvataggio delle impostazioni disattivate, tra cui "Abilita P.IVA". Dopo l'aggiornamento, salvare nuovamente le opzioni desiderate.

= 3.2.1 =
Compatibility update for WooCommerce 10.3.3 and minor hook refinements.

= 3.2.0 =
Adds VIES validation with automatic VAT removal for EU customers, badges, and new settings.

== Frequently Asked Questions ==
= VIES returns “INVALID” for a valid VAT number =
Try a clean check by appending `?dot4all_fiscalita_ita_light_nocache=1&dot4all_fiscalita_ita_light_nocache_nonce=...` (admin only, nonce required).
Make sure PHP **SOAP** is enabled and the server can reach `ec.europa.eu`.

= Can I use the plugin with Checkout Blocks? =
Yes. The plugin is fully compatible with WooCommerce Store API.

= VAT is not removed even when VIES is valid =
Check that:
- “Calculate tax based on” is not set to shipping with an empty address.
- The customer type is “Company” or “Freelancer”.
- The VAT number is correct (prefix optional).
- A cache plugin is not serving a static checkout.

= Does it generate invoices or receipts? =
Yes, if you use “WooCommerce PDF Invoices & Packing Slips”: you can set a separate receipt numbering.

== Credits ==
Developed by dot4all Srl
Support: https://dot4all.it/contatti/
