=== Fair Subscriptions – Cancellation & Withdrawal Button ===
Contributors: michaltry
Tags: subscriptions, cancellation button, withdrawal button, kündigungsbutton, widerrufsbutton
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 0.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Cancellation button for subscriptions (§ 312k BGB) and the EU withdrawal button (§ 356a BGB, Art. 11a Directive 2011/83/EU) for WooCommerce.

== Description ==

**Germany: cancellation button.** Anyone who lets consumers conclude continuing contracts online – subscriptions, memberships, subscription boxes – must offer a "Verträge hier kündigen" button, and a confirmation page with a "jetzt kündigen" button (§ 312k BGB). The Federal Court of Justice ruled on 16 July 2026 (I ZR 200/25) that the confirmation page may only ask for the data needed to identify the contract and must not require a login.

**EU: withdrawal button.** Since 19 June 2026 every online shop in the EU must let consumers withdraw from a contract through a clearly labelled function (Art. 11a Directive 2011/83/EU as amended by Directive (EU) 2023/2673; in Germany § 356a BGB).

Missing or hidden buttons cost money: if the cancellation button is missing, consumers may cancel at any time without notice, and competitors and consumer associations send warning letters (Abmahnungen).

= Cancellation button =

* Statutory labels: "Verträge hier kündigen" and "jetzt kündigen" (English and Polish equivalents for other languages).
* Confirmation page with only the fields the law allows: name, e-mail, contract, type of cancellation, requested date, reason for extraordinary cancellation. No login, no captcha.
* Logged-in customers pick their subscription from a list; guests are matched by contract or order number and e-mail.
* Ordinary cancellation ends at the end of the paid period; the customer keeps access until then.
* Immediate confirmation by e-mail with content, date and time of receipt and the end of the contract (§ 312k Abs. 4 BGB), plus a printable on-screen receipt.
* Cancellations that cannot be matched automatically are still received and confirmed, and flagged for review.

= Withdrawal button =

* "Vertrag widerrufen" link in the footer and on every order in My Account; "Widerruf bestätigen" button.
* Withdraw from a whole order or from single items, or describe the goods in a text field.
* Late withdrawals are received and flagged, never rejected.
* Confirmation e-mail and printable receipt; the withdrawal is noted on the order.
* Already using Germanized? It has its own withdrawal button – this one then stays off unless you switch it on.

= For the shop =

* Works with **Subscriptions for WooCommerce** (WP Swings, free). Support for WooCommerce Subscriptions is in beta.
* Renewal and trial-end reminder e-mails.
* **Tamper-evident event log**: every cancellation, withdrawal, e-mail and settings change is chained with SHA-256; the log page shows if an entry was changed or removed. CSV export.
* Pages are created on activation; shortcodes `[fair_cancellation]`, `[fair_withdrawal]`, `[fair_cancel_link]`, `[fair_withdraw_link]`.
* Distraction-free page template for the two forms (no upsells, no pop-ups).
* Block and classic themes, HPOS.
* Translations: English, German (Sie), Polish.

= Not legal advice =

The plugin implements the statutory requirements as described above. It does not replace advice from a lawyer. Poland has not yet transposed the withdrawal button into national law (draft UC169); the plugin follows the directive.

== Installation ==

1. Install and activate the plugin. It creates the cancellation and withdrawal pages (titled with the statutory labels in your site language).
2. Go to **WooCommerce → Cancellation & withdrawal → Settings** and check the e-mail address for notifications.
3. Make sure the footer links are visible on every page (or place the shortcodes in your own footer).

== Frequently Asked Questions ==

= Do I need the cancellation button if I only sell single products? =

No. § 312k BGB applies to continuing contracts (subscriptions). The withdrawal button applies to all online shops selling to consumers in the EU.

= Does the customer have to log in? =

No. The law and the Federal Court of Justice do not allow making cancellation depend on a login. Logged-in customers simply see their subscriptions pre-filled.

= Why does the subscription not end immediately? =

An ordinary cancellation takes effect at the end of the current period. The plugin schedules the end one hour before the next renewal, so no new period is charged. Extraordinary cancellations are flagged for you to decide.

= What happens if I deactivate the plugin? =

Cancellations scheduled for the end of the period are carried out immediately, so no subscription renews after a received cancellation. The plugin list warns you beforehand. The event log stays in the database, even after deleting the plugin.

= Can I change the button labels? =

The German labels are prescribed by law and fixed. Other languages use the translations.

== Changelog ==

= 0.2.0 =
* Event log retention support: old events can be pruned with a recorded anchor; the integrity check continues from it.
* Hooks for add-ons: fsub_mail (e-mail layout; the statutory content cannot be removed), fsub_declaration_received, fsub_admin_contract_html.
* Fix: an emptied "Next steps after a withdrawal" setting now falls back to the default text.

= 0.1.0 =
* First release: cancellation button (§ 312k BGB), withdrawal button (§ 356a BGB / Art. 11a Directive 2011/83/EU), confirmation e-mails, reminders, tamper-evident event log, WP Swings integration.
