=== Plogins Withdraw - Right of Withdrawal Button for WooCommerce ===
Contributors: motylanogha
Tags: woocommerce, withdrawal, right of withdrawal, eu, refund
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 8.1
Requires Plugins: woocommerce
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Full or partial EU right-of-withdrawal requests (Directive 2023/2673) for WooCommerce orders, with an admin log and email notifications.

== Description ==

Plogins Withdraw adds an easy withdrawal function to WooCommerce, aligned with **EU Directive 2023/2673** (the "withdrawal button", Art. 11a): a clear way for customers to declare that they withdraw from a distance contract, in full or per item, within the statutory withdrawal period.

It is a **request-and-log** plugin: it records the customer's withdrawal declaration, emails a confirmation to the customer and a notification to the shop, and tracks the request status in the admin. It never moves money on its own, you process any refund in the normal WooCommerce order screen, matching the legal model where the customer declares and the trader acts.

= What it does =

* **Withdrawal form**: the `[withdraw_form]` shortcode renders a two-step form: look up an order by number and billing email (works for guests too), then select items and quantities and submit the withdrawal declaration.
* **Full or partial withdrawal**: the customer chooses how many of each item to withdraw from.
* **Withdrawal button in My Account**: a "Withdraw from this order" button appears under the order details and links to your withdrawal page with the order pre-filled.
* **Withdrawal-period check**: configurable period (statutory minimum 14 days), measured from delivery (order completion) or, if never completed, from the order date.
* **Admin log**: a WooCommerce → Withdrawal Requests screen lists every request with its items, customer and status (pending, accepted, rejected, processed), filterable by status.
* **Emails**: automatic confirmation to the customer and notification to the shop.
* **Model withdrawal text**: an editable block on the form for the statutory model withdrawal form (Annex I.B).
* **Guest friendly**: no account needed; the order-number + billing-email lookup works for guest orders.
* **HPOS + Blocks compatible**: reads orders through the WooCommerce order API.

= Requirements =

* WordPress 6.5 or later
* PHP 8.1 or later
* WooCommerce 8.0 or later

== Installation ==

1. Install and activate WooCommerce.
2. Install and activate Plogins Withdraw.
3. Create a page and add the `[withdraw_form]` shortcode.
4. Go to **WooCommerce → Withdrawal**, select that page as the withdrawal form page, set the withdrawal period and eligible order statuses, and adjust the notification email and legal texts.

== Frequently Asked Questions ==

= Does it issue refunds automatically? =
No. This records the withdrawal request and tracks its status. Process any refund in the normal WooCommerce order screen; the request status is managed on the Withdrawal Requests screen.

= Does it work for guest orders? =
Yes. Customers look up their order with the order number and the billing email used at checkout, so guests can submit a withdrawal without an account.

= Is this legal advice? =
No. The plugin provides the technical withdrawal function and editable legal texts. Configure the period and wording to match your jurisdiction and the statutory model withdrawal form.

= Is it compatible with HPOS? =
Yes. Orders are read through the WooCommerce order API, which is HPOS-compatible.

== Screenshots ==

1. The withdrawal request form: order lookup by number and billing email (guest-friendly), with the 14-day right-of-withdrawal notice.
2. Item selection: full or partial withdrawal with per-item quantities, the model withdrawal text and the declaration.
3. Settings (WooCommerce → Withdrawal): withdrawal period, form page, eligible statuses, notification email and legal texts, with the request log.

== Translations ==

Plogins Withdraw is fully translatable and ships the `plogins-withdraw.pot` template. Translations are delivered by WordPress.org language packs from translate.wordpress.org, which is where Polish, German and Spanish are being contributed; the package itself carries no compiled translation files.

== Changelog ==

= 1.2.0 =
* Fixed: the form asked for the order number and then looked the order up by its database id. On a stock WooCommerce install those are the same value, so nothing looked wrong, but any plugin that renumbers orders breaks the pair: the shop printed a number in its own emails that its own withdrawal form then rejected. The lookup now resolves the displayed number, falling back to the id, with a `withdraw/resolve_order_number` filter for other numbering schemes.
* Fixed: the status email addressed the order by its database id rather than the number the customer sees, for the same reason.
* New: withdrawals are written into the order's own notes, both when the declaration arrives and when its status changes. The request log is a separate screen nobody has open; whoever opens the order next now sees what happened without knowing this plugin exists.

= 1.1.0 =
* New: a separate confirmation step. Choosing items and declaring withdrawal used to be one click. Article 11a(3) requires a confirmation control carrying no wording other than "confirm withdrawal", which only means something if the customer can read the declaration first, so the declaration is now shown back in full on a step of its own before anything is stored.
* New: the declaration carries the customer's name, the contract it refers to and their electronic contact details, which is what Article 11a(2) asks a withdrawal statement to contain. The name is prefilled from the order and stored with the request.
* New: the acknowledgement email is now a durable record under Article 11a(4). It repeats the declaration in full and states the date and time it was submitted, instead of only saying the request arrived.
* New: `[withdraw_link]` shortcode and an optional footer link. Article 11a(1) requires the function to be easily accessible for the whole withdrawal period, and the My Account control only reaches a signed-in customer already looking at that order, so a guest had no way in.
* Changed: the control now reads "Withdraw from contract here", the wording Article 11a(1) prescribes, instead of "Withdraw from this order".

= 1.0.8 =
* Fixed: a withdrawal could be recorded without the customer ever ticking the declaration. The checkbox carried only the browser's `required` attribute and the server never looked at it, so a request posted without it was stored as a valid declaration. That record is the whole point of the plugin, so it is now refused server-side and nothing is written.
* Fixed: the order link in the request log used the classic post editor URL, which does not open an order once HPOS is on, while the plugin declares HPOS compatibility. It now picks the right URL for whichever order storage the shop uses.
* Fixed: the confirmation sent to the customer ended with "We will confirm the next steps by email" and no code ever sent that email. Changing a request's status now writes to the customer, and the accepted message carries the 14-day return deadline and the refund method, which is information the trader owes anyway.

= 1.0.7 =
* Renamed to Plogins Withdraw so the name leads with the brand rather than a generic word, as the plugin review asked.
* Removed the "Tested up to" header from the main PHP file. It belongs in readme.txt only, where it is already declared; in both places the header can override the readme and show a compatibility version that was never intended.

= 1.0.6 =
* Translations: refreshed the bundled `plogins-withdraw.pot`, which had fallen behind the code. It was missing five strings from the withdrawal declarations admin screen and the privacy eraser, and still carried the plugin's pre-rename name. That template is what translators work from.
* Translations: corrected the Spanish catalogue, which called the right of withdrawal "retiro" throughout. Spanish consumer law calls it *desistimiento*, and the plugin's own description already used that term while its interface did not.

= 1.0.5 =
* Tested against WordPress 7.1. Verified by activating this build on a clean 7.1 install with WooCommerce 11.1, not by editing the header.

= 1.0.4 =
* New: withdrawal declarations are now covered by the WordPress personal-data tools. A privacy export includes a shopper's declarations, and an erasure request removes them, so a subject access or deletion request can be answered from the standard screen instead of by hand.
* Declared compatibility with WooCommerce 10.9.
* Copy: replaced long dashes with plain punctuation across the interface.
* Housekeeping: the release package no longer carries the translation catalogues, which come from the WordPress.org language packs.

= 1.0.3 =
* Corrected the German and Polish translations: "withdrawal" was rendered as "Auszahlung" (payout) in German and "wypłata" (payout) in Polish; both now use the correct right-of-withdrawal terms (Widerruf / odstąpienie od umowy). Also fixed a German grammar slip and standardised the Polish wording.

= 1.0.2 =
* Added bundled Polish, German and Spanish translations for the plugin interface.

= 1.0.1 =
* First stable release.

= 0.1.1 =
* Plugin Check: escaping/sanitisation/i18n/hygiene fixes (table-name identifiers now passed via %i placeholders in prepared statements).

= 0.1.0 =
* Initial release: `[withdraw_form]` shortcode (order lookup + full/partial item selection), My Account withdrawal button, configurable withdrawal period and eligible statuses, admin request log with statuses, customer and shop emails, editable model withdrawal text. HPOS + Blocks compatible.

== Upgrade Notice ==

= 0.1.0 =
Initial release.
