============================================================
 Greek VAT & Invoices for WooCommerce - What's New
============================================================

Version 1.2.6 (2026-10-20)
------------------------------------------------------------

 ★ New: Invoice Marker and Filter on the Orders List

   Shops with many orders could not tell at a glance which orders asked
   for a Τιμολόγιο. The WooCommerce Orders list now has:

   • A slim icon column right after the checkbox: a round document icon
     on every order whose document type is Τιμολόγιο. Receipts and older
     orders without a type show nothing.
   • A "Τιμολόγια (N)" link at the end of the status row. One click lists
     only the invoice orders. It is always shown, also as
     "Τιμολόγια (0)", and N counts the invoices among the orders in the
     "All" list (trash excluded).
   • The filter stays active when you use the list's search box or Filter
     button.

   New file:
   • includes/class-order-list.php

   Modified files:
   • greek-vat-invoices-for-woocommerce.php (load + init, version bump,
     stylesheet also loaded on the classic Orders screen)
   • assets/css/admin.css (marker styles; removed the unused
     .grvatin-invoice-column rules)

   Safety notes:
   • Display and filter only: reads existing order meta, writes nothing.
   • Every value is HTML-escaped.
   • Fail-open: if anything goes wrong the Orders list is shown exactly
     as WooCommerce builds it.
   • Works with the orders table (HPOS) and the classic orders screen.
   • The filter accepts only the exact value ?grvatin_doc=invoice.

------------------------------------------------------------

Version 1.2.5 (2026-10-14)
------------------------------------------------------------

 ★ New: Invoice Details as a Tidy Card on the Order Edit Screen

   On the WooCommerce order edit screen the invoice fields used to
   appear as plain label/value lines (Block checkout) or as a plain
   "Στοιχεία Τιμολογίου" block (Classic checkout). They now appear as
   one card at the bottom of the Billing column:

   • Header: document type (Τιμολόγιο / Απόδειξη) and, once generated,
     the invoice number and date.
   • Invoices: company name, ΑΦΜ (monospace), ΔΟΥ and business activity,
     with labels above the values. Empty fields show a dash.
   • Receipts: just the "Απόδειξη" header.
   • The VAT exemption line is intentionally not part of the card; it
     is still shown where it always was (General column, once an
     invoice number exists).

   New file:
   • includes/class-order-admin-card.php

   Modified files:
   • includes/class-checkout-fields.php (removed the old plain admin
     display and its hook; the card replaces it)
   • greek-vat-invoices-for-woocommerce.php (load + init, version bump)
   • assets/css/admin.css (card styles)

   Safety notes:
   • Display only: reads existing order meta, writes nothing.
   • Every value is HTML-escaped.
   • Fail-open: if the card cannot be built, nothing is hidden and the
     order screen is shown exactly as WooCommerce built it.
   • Block checkout: WooCommerce's plain lines are hidden only in the
     read-only view, and only for orders where the card was built. The
     edit form behind the pencil icon is untouched, so every field stays
     editable, and saving an order changes none of the stored data.
   • Uses WooCommerce's hooks woocommerce_admin_order_data_after_billing_address
     (action) and woocommerce_admin_billing_fields /
     woocommerce_admin_shipping_fields (filters, view context only).

------------------------------------------------------------

Version 1.2.4 (2026-10-14)
------------------------------------------------------------

 ★ New: Invoice Details in the Orders List "Quick Preview"

   The eye icon on the WooCommerce Orders list opens a quick preview
   of an order. It previously showed nothing from this plugin. It now
   shows a compact block at the top of the preview:

   • Invoice orders (Τιμολόγιο): invoice number + date (once the order
     is Completed and a number exists), company name, ΑΦΜ, ΔΟΥ,
     business activity, and the VAT exemption status/reason if any.
   • Receipt orders (Απόδειξη): a single "Απόδειξη" line (plus the
     number/date once generated).
   • Orders with no invoice/receipt data (e.g. placed before the plugin
     was installed) show no block at all.

   New file:
   • includes/class-order-preview.php

   Modified files:
   • greek-vat-invoices-for-woocommerce.php (load + init the new class,
     version bump)
   • assets/css/admin.css (styles for the preview block)

   Safety notes:
   • Display only: reads existing order meta, writes nothing.
   • Every value is HTML-escaped before it is shown.
   • Fail-open: any error inside the feature is caught and the standard
     WooCommerce preview is shown unchanged.
   • Works with HPOS and legacy order storage, and with both Classic
     and Block checkout (uses the same order meta in both).
   • Uses WooCommerce's own hooks:
     woocommerce_admin_order_preview_get_order_details (filter) and
     woocommerce_admin_order_preview_start (action).

------------------------------------------------------------

Version 1.2.3 (2026-09-12)
------------------------------------------------------------

 ★ Fixed: Two PHP Notices on Newer WordPress/WooCommerce

   Sites running WordPress 6.7+ and/or WooCommerce 11.0+ could see:

   "Function _load_textdomain_just_in_time was called incorrectly...
   Translations should be loaded at the init action or later."

   "Function woocommerce_register_additional_checkout_field was
   called incorrectly. Additional checkout fields should be
   registered on the woocommerce_init action or later."

   Both traced to the same cause: Block Checkout field registration
   ran on the `woocommerce_blocks_loaded` hook, which fires before
   WordPress's `init` action — too early for both the field labels'
   translation strings and the field-registration call itself.
   Registration now runs on `woocommerce_init` instead, exactly as
   WooCommerce's own guidance recommends. Purely a hook-timing fix —
   fields register and behave identically, verified against both
   Απόδειξη and Τιμολόγιο selections with WP_DEBUG logging on.

   Modified files:
   • includes/class-block-checkout.php — register_fields() now
     hooked to woocommerce_init instead of woocommerce_blocks_loaded

------------------------------------------------------------

Version 1.2.2 (2026-09-10)
------------------------------------------------------------

 ★ Clarified: Checkout ΑΦΜ "Valid" Message Was Misleading

   At checkout, typing any well-formed 9-digit number showed a
   green "✓ Έγκυρο" ("Valid") message — indistinguishable from a
   real verification, even though the plugin only checks digit
   count by default (no AADE lookup is performed unless a
   separate, not-yet-exposed AADE validation mode is manually
   enabled). A customer could see "Valid" for a made-up number,
   and there was no way for the store owner to tell the
   difference afterwards.

   The message now explicitly says the format is correct but the
   number has not been verified as real. Same wording change
   applied to the plugin's readme.txt FAQ, so this limitation is
   clear before installing, not just after.

   Modified files:
   • includes/class-vat-validator.php — basic-mode success
     message now states "correct format" instead of implying a
     genuine validation
   • assets/js/checkout.js — checkout now displays the server's
     actual per-mode message instead of a hardcoded generic
     "Valid" label

------------------------------------------------------------

Version 1.2.1 (2026-09-01)
------------------------------------------------------------

 ★ Bug Fix: Block Checkout Blocked Orders on "Απόδειξη" (Receipt)

   Selecting "Απόδειξη" correctly hid the Company Name, ΑΦΜ, ΔΟΥ,
   and Business Activity fields, but WooCommerce Blocks' own
   client-side validation still treated them as required, so the
   customer could not place the order. The required state is now
   evaluated against which invoice type is actually selected, both
   server-side and client-side, so Receipt orders are no longer
   blocked by fields the customer cannot see or fill in.

   Requires WooCommerce 9.9.0 or later for this per-field
   conditional behavior (needed for WooCommerce's own conditional
   required-field support). On older WooCommerce versions, the
   plugin falls back to enforcing required invoice fields on the
   server only, the same as before the required/optional fields
   feature existed, rather than incorrectly treating fields as
   always required client-side.

   Modified files:
   • includes/class-block-checkout.php — required flag is now a
     WooCommerce Blocks conditional rule tied to the invoice-type
     field, gated on WooCommerce 9.9.0+
   • assets/js/block-checkout.js — explicitly synchronizes each
     field's validation-store error with live visibility, the
     admin's required setting, and its current value

------------------------------------------------------------

Version 1.2.0 (2026-08-11)
------------------------------------------------------------

 ★ Per-Field Required/Optional Invoice Settings

   New settings section "Υποχρεωτικά Πεδία Τιμολογίου" under
   WooCommerce → Settings → Ελληνικά Τιμολόγια lets the store
   admin mark each of the 4 invoice fields as required or
   optional independently: Company Name, ΑΦΜ, ΔΟΥ, Business
   Activity. All 4 default to required, matching prior behavior
   for existing installs.

   New options (all default 'yes'):
   • GRVATIN_require_company
   • GRVATIN_require_vat
   • GRVATIN_require_doy
   • GRVATIN_require_activity

   ΑΦΜ format (9 digits) is still validated whenever a value is
   entered, regardless of the required/optional setting.

   Modified files:
   • includes/class-admin-settings.php — new settings section
   • includes/class-checkout-fields.php — gated PHP validation
     and optional-label display for Classic Checkout
   • assets/js/checkout.js — per-field required toggle
   • includes/class-block-checkout.php — gated required flags
     and validate callbacks for Block Checkout
   • greek-vat-invoices-for-woocommerce.php — localized the new
     settings to checkout.js

 ★ Bug Fix: Block Checkout "(Optional)" Label Mismatch

   Previously only ΑΦΜ was registered with required => true in
   Block Checkout; Company Name, ΔΟΥ, and Business Activity were
   registered required => false even though server-side
   validation already rejected them empty. Block Checkout's
   "(Optional)" label now accurately reflects each field's real
   required setting.

 ★ Bug Fix: Uppercase Conversion Setting

   The "Μετατροπή σε Κεφαλαία" checkbox saved to option
   GRVATIN_uppercase, but every consumer read
   GRVATIN_uppercase_fields — so toggling it never had any
   effect. The setting id now matches what's actually read.

 ★ Donate Link Updated

   Replaced the PayPal donate link with
   https://paypal.me/TheodoreSfakianakis across the plugin
   header, admin settings page, and all documentation files.

------------------------------------------------------------

Version 1.1.0 (2026-03-13)
------------------------------------------------------------

 ★ WooCommerce Block (Gutenberg) Checkout Support

   Full support for the new WooCommerce Block-based checkout
   page using the official Additional Checkout Fields API.

   New files:
   • includes/class-block-checkout.php
   • assets/js/block-checkout.js

   What it does:
   • Registers 5 checkout fields via woocommerce_register_additional_checkout_field():
     - Invoice Type (Τύπος Παραστατικού) — select: Απόδειξη / Τιμολόγιο
     - Company Name (Επωνυμία Επιχείρησης) — text
     - VAT Number (ΑΦΜ) — text, mandatory
     - Tax Office (ΔΟΥ) — text
     - Business Activity (Επάγγελμα) — text
   • Conditional field visibility: Company, VAT, DOY, Activity fields
     dynamically show/hide when the customer selects Τιμολόγιο or Απόδειξη
   • Server-side validation: VAT, DOY, Company, and Activity are
     validated as required only when invoice type is "invoice"
   • Field data saved to order meta using the same keys as classic checkout
     (_billing_invoice_type, _billing_vat_number, _billing_doy,
      _billing_business_activity, billing_company via set_billing_company)
   • Native admin order display — WooCommerce renders the fields
     automatically in the order edit screen (no duplicates)
   • Native email display — WooCommerce includes the fields in order
     emails automatically via WC_Emails::additional_checkout_fields()
   • JavaScript uses MutationObserver with 50ms debounce to detect
     DOM changes and toggle field visibility in the block checkout

 ★ New Admin Settings

   Modified file: includes/class-admin-settings.php

   • Checkout Type setting: Choose between "Classic (Shortcode)" and
     "Block (Checkout Block)" — saved as option 'grvatin_checkout_type'
   • Block Position setting: Choose where invoice fields appear in
     the block checkout — "Contact Information (top)" or
     "Additional Order Information (bottom)"
     Saved as option 'grvatin_block_position'
   • Classic Position setting: The existing 10-position dropdown,
     now only shown when Classic checkout type is selected
   • Admin JavaScript toggles visibility of the position dropdowns
     based on the selected checkout type

 ★ VAT Number (ΑΦΜ) Now Mandatory

   The VAT number field is now required (was optional before).
   In block checkout, server-side validation enforces this when
   invoice type is selected.

 ★ Smart Component Loading

   Modified file: greek-vat-invoices-for-woocommerce.php

   • GRVATIN_Checkout_Fields is always loaded (needed for admin
     order display and email hooks in both modes)
   • GRVATIN_Block_Checkout is loaded additionally when checkout
     type is set to "block"
   • In block mode, the classic display hooks (display_invoice_fields_admin
     and display_invoice_fields_email) return early to avoid duplicate
     display — WooCommerce handles rendering natively

 ★ Code Quality Improvements

   • Removed dead code: eliminated unused billing_address key check
     in get_submitted_invoice_type()
   • Added MutationObserver debounce (50ms) to prevent excessive
     DOM processing in block-checkout.js
   • Proper early returns in display hooks to prevent duplicate
     field rendering in admin orders and emails

------------------------------------------------------------

Version 1.0.8 (2025-01-17)
------------------------------------------------------------
   • Simplified plugin for WordPress.org release
   • Added real-time VAT validation (9 digits)
   • Added numeric-only input filter for VAT field
   • Beautified admin settings page with gradient styling
   • Added author information and donate button
   • Improved checkout JavaScript for better field toggle
   • Enhanced mobile responsiveness
   • Removed advanced features temporarily (moved to roadmap)

Version 1.0.7
------------------------------------------------------------
   • Fixed checkout field toggle functionality
   • Improved CSS styling
   • Bug fixes and performance improvements

Version 1.0.0
------------------------------------------------------------
   • Initial release
   • Basic invoice/receipt selection
   • Greek VAT fields (ΑΦΜ, ΔΟΥ)
   • Company information fields

============================================================
