=== Retiora – Returns & Withdrawal Management ===
Contributors: assistenzawpclinic
Tags: withdrawal, returns, rma, evidence, woocommerce
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Digital withdrawal, return, evidence, and explicit refund workflows for WooCommerce.

== Description ==

Retiora provides technical tools designed to support digital withdrawal and return workflows in WooCommerce. It supports customer-account and email-verified guest requests, product eligibility configuration, consent evidence, merchant review, PDF receipts, Return/RMA cases, inspection, and explicit WooCommerce refunds.

Retiora records deterministic submission evidence and a SHA-256 receipt hash. Subsequent workflow events form a tamper-evident audit chain that administrators can verify on demand. These controls help support integrity verification; they are not external timestamps, digital signatures, notarization, or legal certification.

Eligibility, temporal rules, exception contexts, and consent requirements are merchant configuration and evidence inputs. Retiora does not provide a legal determination of eligibility. Configuration, applicable law, retention periods, and merchant decisions remain the store owner's responsibility. Acceptance of a withdrawal does not automatically issue a refund: return and refund operations remain separate, explicit workflows.

= Features =

* Account and email-verified guest withdrawal flows, including partial quantities.
* Configurable global, category, product, and variation eligibility rules.
* Operational time-window policy and recorded decision snapshots.
* Consent capture for Classic Checkout and WooCommerce Checkout Blocks.
* Merchant accept/reject workflow with separate private and customer-facing notes.
* PDF receipt with authorized downloads, evidence snapshots, and SHA-256 hashes.
* Tamper-evident audit chain with read-only integrity verification.
* Return/RMA cases for physical, digital, and service items.
* Partial receipt, inspection, and customer-safe Return visibility.
* Explicit full or partial WooCommerce refunds with tax and external-refund reconciliation.
* Optional WooCommerce 11.1+ withdrawal-surface integration while Retiora retains validation, evidence, and workflow ownership.
* Translation-ready customer, email, PDF, and administration labels using WordPress internationalization APIs.
* Translation support through WordPress.org language packs.
* Tested with WPML and Polylang.

Retiora does not automatically refund, restock, change order status, create shipping labels, or provide carrier tracking.

== Installation ==

1. Install and activate WooCommerce.
2. Install Retiora from the WordPress plugin screen, or upload the plugin ZIP.
3. Activate Retiora. If WooCommerce is unavailable, Retiora shows an administrator notice and keeps its WooCommerce-dependent components inactive.
4. Configure eligibility, temporal, and consent defaults under WooCommerce > Settings > Retiora.
5. Review withdrawal, Return/RMA, receipt-storage, and environment information under WooCommerce > Returns & withdrawals.

Activation and upgrades create or update Retiora's custom tables non-destructively. Deactivation does not remove data.

== Frequently Asked Questions ==

= Is an account, license, or external service required? =

No. All included features work locally without a WPClinic account, license key, paid plan, or external licensing service. WooCommerce is required.

= Does Retiora support HPOS? =

Yes. Retiora uses WooCommerce order APIs and declares compatibility with High-Performance Order Storage (HPOS).

= Does Retiora support multilingual sites? =

Retiora is translation-ready and uses WordPress.org language packs when available. It has been tested with WPML and Polylang. Polylang for WooCommerce has not been tested. Store content and translations supplied by other plugins are managed separately.

= What happens with virtual or downloadable products? =

Retiora records configured eligibility, exception and consent information for these items. Return cases can distinguish items that do not require physical return. It does not automatically decide whether a legal exception applies or revoke download permissions.


= Does Retiora automatically determine legal eligibility? =

No. Retiora applies merchant-configured operational rules and records evidence. Legal applicability and final decisions remain the merchant's responsibility.

= Does Retiora automatically issue refunds? =

No. An authorized administrator must review the current proposal and explicitly create a WooCommerce refund. A changed WooCommerce refundable balance invalidates an older proposal.

= Does Retiora support guest customers? =

Yes. Guest access uses a short-lived, order-bound secure link sent only after matching the order number and billing email. Raw access tokens are not stored.

= Does Retiora support WooCommerce Checkout Blocks? =

Yes. Consent capture uses WooCommerce public Additional Checkout Fields and Store API checkout hooks. Classic Checkout is also supported.

= Does Retiora work with WooCommerce's built-in withdrawal feature? =

Yes. With WooCommerce 11.1 or newer, merchants can optionally choose a WooCommerce-integrated customer experience. WooCommerce's public withdrawal address then leads to Retiora's secure flow, while Retiora continues to validate the request, record item quantities and evidence, and manage review, returns, and refunds. Retiora does not use WooCommerce's native withdrawal persistence as Retiora evidence and never enables the WooCommerce feature automatically.

= Where are PDF receipts stored? =

Receipts use high-entropy filenames under `wp-content/uploads/retiora-private`. Apache and IIS deny files are created, and downloads use an authorized controller. Web-server rules vary; see the Nginx recommendation below.

= Does Retiora change stock? =

No. Retiora requests WooCommerce refunds with restocking disabled and does not otherwise mutate stock.

= What happens if WooCommerce already has a refund? =

WooCommerce remains the economic source of truth. External refunds reduce refundable amounts and quantities. Retiora rejects a stale proposal and requires the administrator to review the recalculated proposal; it does not claim ownership of the external refund.

= Does accepting a withdrawal mean that it has been refunded? =

No. Withdrawal review, Return/RMA handling, inspection, and refund are distinct statuses and operations.

== Receipt Storage and Nginx ==

Retiora never exposes a receipt file path as the customer download URL. Authorized downloads pass through WordPress. The plugin writes Apache `.htaccess`, IIS `web.config`, and `index.php` protections, but server-level protection depends on the hosting environment.

For Nginx, ask the server administrator to deny direct requests to the private directory. A typical site-specific rule is:

`location ^~ /wp-content/uploads/retiora-private/ { deny all; }`

Confirm the actual WordPress content and uploads paths before applying server configuration. This recommendation supplements Retiora's authorization controller and does not promise absolute privacy on every server configuration.

== Privacy ==

Retiora stores withdrawal and item snapshots, WooCommerce order/item references, a customer email snapshot, configured eligibility and temporal decisions, consent evidence, merchant decisions, Return/RMA and inspection data, refund references, event-chain hashes, and receipt metadata. PDF receipts contain the withdrawal submission snapshot and customer email.

Retiora does not add raw IP addresses, user agents, device fingerprints, or analytics to persisted withdrawal records. Guest lookup rate limiting uses short-lived salted fingerprints; raw guest access and confirmation tokens are represented only by hashed transient/option keys. Retiora has no runtime third-party service and sends no data to WPClinic. Dompdf is a bundled local library.

Retiora data is preserved on deactivation and, by default, on uninstall. If the merchant explicitly enables delete-on-uninstall, Retiora removes its custom tables, plugin options and transients, product/category/order-item metadata, and files scoped to `uploads/retiora-private`. Existing WooCommerce orders, refunds, accounting records, and native order notes are not deleted. Merchants remain responsible for defining and communicating an appropriate retention policy.

== Public Extension Points ==

Retiora's stable extension points use the `retiora_` prefix. Filters include:

* `retiora_withdrawable_order_statuses` — eligible WooCommerce order statuses.
* `retiora_reference_date_candidates` — additional operational reference-date candidates.
* `retiora_eligibility_reason_codes` and `retiora_merchant_decision_reason_codes` — reason labels.
* `retiora_consent_evidence` and `retiora_eligibility_decision` — evaluated evidence/decision objects.
* `retiora_resolved_guest_order` — guest lookup order resolution.
* `retiora_guest_access_token_ttl`, `retiora_guest_lookup_rate_limit`, and `retiora_guest_lookup_rate_window` — bounded guest-security settings.

Lifecycle actions include `retiora_initialized`, `retiora_before_withdrawal_submit`, `retiora_after_withdrawal_created`, `retiora_after_withdrawal_status_changed`, `retiora_after_return_created`, and `retiora_after_return_received`. Failure/notification actions are also prefixed `retiora_`. Extension code should treat persisted status values, reason codes, option names, metadata keys, email IDs, and custom table names as the documented extension interface.

No public REST route, public verification API, scheduled cron event, remote executable code, tracking service, or external timestamping service is registered.

== Screenshots ==

1. Select order items and quantities for a withdrawal request.
2. Review the selected items before confirming the withdrawal.
3. View a submitted withdrawal and access its receipt.
4. Follow withdrawal status from the My Account Orders table.
5. Review customer requests in the administration withdrawals list.
6. Manage a withdrawal with its review controls and audit timeline.
7. Review a return case, received quantities, inspection and refund proposal.
8. Check environment, receipt storage and database status in Diagnostics.

== Support ==

For product information, visit https://wpclinic.it/retiora. After directory publication, use the Retiora support forum on WordPress.org for plugin support. Do not post customer details, access links or PDF receipts in public support topics.

== Third-party Libraries ==

PDF receipts are generated locally with Dompdf. The package includes Dompdf, php-font-lib, php-svg-lib, Masterminds HTML5 and Sabberworm PHP CSS Parser. Their license and font attribution files are included with the libraries under vendor/. No remote PDF service is used.

== Changelog ==

= 1.1.0 =
* Initial public release candidate: complete account and guest withdrawal workflows, eligibility and temporal context, consent evidence, PDF receipts and integrity verification.
* Includes merchant review, Return/RMA handling, inspection and explicit WooCommerce refund workflows.
* Includes optional integration with WooCommerce 11.1+ withdrawal surfaces, HPOS support and Classic/Blocks checkout consent capture.
* Includes translation-ready strings and tested WPML/Polylang integration.
