=== Toply Return Risk Predictor ===
Contributors: toply
Tags: woocommerce, returns, fraud prevention, risk analysis, cash on delivery
Requires at least: 5.0
Tested up to: 6.9
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.3.8
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Identify high-risk customers for WooCommerce stores using historical order analysis.

== Description ==

Toply Return Risk Predictor is an essential tool for any WooCommerce store that offers cash-on-delivery (COD) payment. The plugin automatically analyzes your order history and identifies customers who have a pattern of returning or refusing parcels.

Statistics show that a single refused parcel can wipe out the profit from 3-4 successfully completed orders due to round-trip shipping costs. Toply Return Risk Predictor gives you full visibility into these losses directly in your admin panel.

= Key Benefits =

* **Financial Dashboard:** A modern control panel shows your total monetary losses from returns and failed deliveries, your store-wide return rate percentage, and the total number of risky customers — all calculated automatically from your existing WooCommerce orders.

* **Risky Customers Table:** A paginated table lists every customer who has had at least one failure, sorted by number of incidents. Each row shows email, total orders, returns/failures, risk score (%), and a recommendation — so you always know who to watch before you ship.

* **COD Risk Alerts:** Customers with a risk score above 35% are automatically flagged with a **"Card Required"** warning directly in your dashboard — a clear signal to manually require card payment, call the customer to confirm, or hold the order before shipping. Stop losing money on refused parcels before they ever leave your warehouse. *(Full automatic COD blocking at checkout available in Pro.)*

* **Risk Badge on Orders List:** A color-coded "Return Risk" column is added to the WooCommerce orders list (green / orange / red). Spot high-risk orders instantly before processing or dispatching.

* **Order Detail Risk Profile:** Open any individual order and see the customer's full risk profile directly in the billing section — score percentage, risk level, number of past failures, and total orders placed.

* **Risky Customers Filter:** A dropdown on the orders list lets you instantly display only orders from customers with a history of failures. Select "Risky customers only" and click Filter — works with both standard WooCommerce and HPOS.

* **Admin Dashboard Widget:** A summary widget on the WordPress home screen shows your three key stats at a glance every time you log in. Move or hide it via Screen Options.

* **Phone Detection:** The plugin cross-references both billing email and billing phone when calculating a customer's score. If a customer places a new order with a different email but the same phone number, their risk history is still detected correctly.

* **Zero Configuration:** Install, activate, and the data is immediately available. The plugin reads directly from your existing WooCommerce orders — no import, no cron job, no setup required.

* **HPOS Compatible:** Fully compatible with WooCommerce High-Performance Order Storage (WooCommerce 7.1+) and standard post-based storage. Detection is automatic.

== Installation ==

1. Download the archive and extract the `toply-return-risk-predictor` folder into `/wp-content/plugins/`.
2. Activate the plugin from the 'Plugins' menu in WordPress.
3. Go to WooCommerce → Return Risk Predictor to view your dashboard and statistics.

== Frequently Asked Questions ==

= How is the score calculated? =
Score = (Failed + Refunded orders) ÷ Total orders × 100. Only orders with status "Failed" or "Refunded" are counted as losses. Cancelled orders are excluded because they do not always represent a delivery refusal.

= Is it safe for the database? =
Yes, queries are optimized and run only when an admin visits the plugin page or the orders list. The checkout process and front-end performance are not affected.

= Does it work with WooCommerce HPOS? =
Yes. The plugin automatically detects whether HPOS (High-Performance Order Storage) is enabled and uses the correct query path in both cases.

= What happens if a customer uses different emails? =
The plugin cross-references the billing phone number as well. If the same phone appears on a new order with a different email, the customer's full risk history is still applied correctly.

== Screenshots ==

1. The Return Risk Predictor control panel with capital statistics.
2. The color-coded risk indicator in the orders list.

== Changelog ==

= 1.3.8 =
* Fix: all interface strings replaced with English equivalents.

= 1.3.7 =
* Added permanent Free vs Pro comparison table at the bottom of the dashboard page.
* Added two header action buttons (Trial Gratuit / Cumpără Pro) for quick access after dismissing the promo banner.
* Added Pro upgrade link below "Card Required" recommendations in the risky customers table.
* Upgrade banner now dismissible permanently per user (stored in user_meta) — Guideline 11 compliant.

= 1.3.6 =
* Upgrade banner: redesigned copy to highlight COD blocking as main Pro benefit; sub-headline now bold white for maximum visibility.

= 1.3.5 =
* Upgrade banner: all text now white and clearly visible; buttons and notes aligned on one row with center alignment.

= 1.3.4 =
* Redesigned upgrade banner: all content right-aligned, reordered buttons (Try Pro Free → trial note → Buy Pro → billing options).

= 1.3.3 =
* Improved upgrade banner: trial note now clearly visible in green to highlight no credit card required.

= 1.3.2 =
* Redesigned Pro upgrade banner: more compact, mentions Pro explicitly, cleaner CTA buttons.

= 1.3.1 =
* Fixed: losses amount now displays the store's WooCommerce currency code (RON, EUR, USD, etc.).

= 1.3.0 =
* Added upgrade section in dashboard showing Pro features and personalized loss amount.
* Added "Start 7-Day Free Trial" button (no credit card required) and "See paid plans" button.

= 1.2.0 =
* Added "How to use" collapsible section in dashboard explaining all features, score colors, and where to find each function.
* Added WordPress admin dashboard widget showing total losses, return rate, and risky customer count (hideable via Screen Options).
* Added risk profile card in the billing section of individual order pages.
* Added "Risky customers only" filter dropdown on the orders list (works with both HPOS and legacy storage).
* Improved: badge-yellow color level for medium-risk customers in dashboard table.

= 1.1.0 =
* Full HPOS compatibility (WooCommerce 7.1+ custom order tables).
* Added dual hooks for orders list column — works on both legacy and HPOS screens.
* Dashboard queries now detect storage mode automatically.
* Fixed double-counting bug when filtering by both email and phone.
* Added Requires Plugins: woocommerce header.
* Plugin now initializes after WooCommerce is confirmed loaded.

= 1.0.2 =
* Added full internationalization (i18n) support with WordPress translation system.
* All interface strings are now translatable via translate.wordpress.org.
* Added Domain Path header and languages/ folder.

= 1.0.1 =
* Minor improvements.

= 1.0.0 =
* Initial community release. Historical analysis and risk scoring.
