=== AIRF Advanced Intelligent Restock Forecast ===
Contributors: thinlayerlabs
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 8.0
WC requires at least: 8.0
WC tested up to: 9.8
Stable tag: 0.4.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

AI-powered WooCommerce restock forecasting with reorder recommendations, supplier lead times, and scheduled analysis.

== Description ==
AIRF helps WooCommerce store owners make better replenishment decisions without leaving wp-admin.

Instead of relying on rough guesswork or a single recent sales window, AIRF combines current stock, product movement, and supplier lead times to show which products need attention first, when stockouts are likely, and what to reorder next.

Use AIRF to:
1. Spot products that are heading toward stockouts before they become expensive problems
2. Estimate reorder quantities with supplier lead time taken into account
3. Review demand forecasts, urgency, trend direction, and stockout windows in one place
4. See revenue impact, reorder timing, anomalies, seasonality, and market-event context where available
5. Export reports, print recommendations, and keep a history of past analyses inside WooCommerce admin

What you get in this version:
1. A dashboard with credits, last analysis status, top recommendations, summary insights, and forecast preview
2. An insights area with demand forecast charts, ABC inventory classification, revenue impact, reorder calendar, anomaly alerts, seasonal patterns, market events, and export tools
3. A history view with previous analyses and recommendation snapshots
4. Settings for auto-analysis scheduling, weekly digest email, customer base countries, plan sync, and site information
5. Supplier lead-time fields directly on WooCommerce product inventory screens
6. Manual analysis runs plus automatic scheduled analysis
7. Plan-aware visibility for credits, usage, and available insight depth inside the plugin

Getting started is simple:
1. Install and activate the plugin
2. Open WooCommerce > AIRF Restock Forecast
3. Enter a recovery email and verify the site from inside WordPress
4. Add supplier lead days to the products you restock regularly
5. Optionally choose customer base countries and schedule settings
6. Run analysis and review recommendations in the AIRF screens

Store owners do not need a separate AIRF dashboard account to use the plugin inside WordPress admin.

External services used:
1. AIRF forecasting service operated by Thinlayer Labs
	- Purpose: site registration, plan/quota status, analysis, cached analysis, analysis history, and customer-country settings.
	- Data sent: store domain, WordPress/WooCommerce/plugin version metadata, recovery email for registration, and anonymized/aggregated inventory and sales signals (SKU, product name, stock, price, monthly sales totals, lead days).
	- Data not sent: customer names, customer email addresses, customer phone numbers, customer addresses, payment details.
	- Trigger: after an admin explicitly consents in the setup screen, requests verification code, and verifies the site; then during analysis/status sync and scheduled analysis tasks.
	- Service terms: https://thinlayerlabs.com/terms
	- Service privacy policy: https://thinlayerlabs.com/privacy

== Installation ==
1. Upload the plugin files to /wp-content/plugins/airf-restock-forecast
2. Activate the plugin through the Plugins screen in WordPress
3. Open WooCommerce > AIRF Restock Forecast
4. Verify the site with your recovery email
5. Add supplier lead days to your products and run your first analysis

== Screenshots ==
1. Dashboard overview with credits, summary, and top restock recommendations.
2. Dashboard details with recommendation table and forecast preview.
3. Insights forecast view with product selector, stockout timing, reorder quantity, and trend.
4. Revenue impact and reorder calendar insights.
5. Demand anomaly alerts, seasonal patterns, market events, and export tools.
6. Analysis history timeline with previous recommendation snapshots.
7. Settings for plan visibility, auto-analysis schedule, and weekly digest email.
8. Settings for customer base countries and site information.

== Frequently Asked Questions ==

= Does this plugin send data to an external service? =
Yes. Anonymized and aggregated sales data is sent to the AIRF forecasting service for analysis. No customer personal data is transmitted.

= Do I need a separate AIRF account? =
No separate AIRF dashboard account is required. Setup happens inside WordPress by entering a recovery email, consenting to the service terms, and completing email verification.

= What WooCommerce data is used? =
AIRF uses product SKUs, monthly sales quantities, current stock, prices, and supplier lead days that you enter on each product, plus basic store and plugin metadata needed for registration and analysis.

= Why should I enter supplier lead days? =
Supplier lead days help AIRF estimate when you need to place orders, not just when stock may run out. This improves reorder timing and calendar-based recommendations.

= What are customer base countries used for? =
Customer base countries help AIRF surface relevant holidays, seasonal peaks, and market events for the places where your customers are based.

= Can I use the plugin on the Free plan? =
Yes. The Free plan includes limited monthly analysis credits and a smaller feature set. Higher plans provide more credits and deeper insight coverage.

= Can I export or print the forecast results? =
Yes. AIRF includes CSV export and print actions, and eligible plans can generate a supplier order report from the Insights area.

== Changelog ==
= 0.4.5 =
* Improved: replaced the anomaly alert card list with a searchable, filterable, paginated table and restored clear spike/drop direction badges.
* Improved: fixed the dashboard analysis overview chart initialization and added high-level context explaining how analyzed products are selected for each run.
* Improved: clarified slow country-save failures with a timeout-specific admin notice and a longer settings API timeout for country updates.

= 0.4.4 =
* Improved: increased the plugin-side analysis request timeout to 240 seconds so large-store runs can wait longer for slower AIRF API processing before the WordPress client gives up.
* Improved: aligned the plugin timeout budget with the updated AIRF API analysis recovery path for slow or degraded upstream analysis runs.

= 0.4.3 =
* Fixed: large catalogues could leave the "Analyzing…" spinner running indefinitely after a worker crash, timeout, or out-of-memory event.
* Improved: the background analysis worker now raises its memory and time limits, streams products in chunks, and writes a heartbeat so a watchdog can recover stalled runs without a manual page refresh.
* Improved: when a worker is killed mid-run, the plugin defers a reconcile instead of failing immediately, so monthly analysis quota is not double-spent on transient failures.
* Improved: catalogue rotation across analysis runs now advances only after a confirmed successful API result, so transient failures no longer skip parts of the catalogue.
* Improved: advisory lock is now site-scoped on multisite networks, preventing sibling sites from blocking each other's analysis runs.
* Improved: hardened the internal loopback dispatch endpoint with per-IP throttling, address allowlisting, and a single-use token.

= 0.4.2 =
* Updated plugin metadata and product page link for review resubmission.
* Reworked POST array sanitization to satisfy Plugin Check 1.9.0.

= 0.4.1 =
* Updated bundled Chart.js to 4.5.1.
* Moved verification screen JavaScript to the admin enqueue flow.
* Replaced flagged input reads with explicit sanitization.
* Removed the hardcoded cron URL trigger.

= 0.4.0 =
* Email-verified domain registration and account recovery.
* Auto-analysis scheduling with day/time picker.
* Customer base country picker with market event insights.
* Demand forecast charts with zoom and pan.
* Revenue impact analysis and reorder calendar.
* Seasonal pattern detection and demand anomaly alerts.
* Supplier order report generation.
* CSV export and print report.
* Polar billing integration for Starter and Growth plans.
* Local bundled chart libraries for admin visualizations.

= 0.1.0 =
* Initial implementation scaffold.
* Added supplier lead-time product field.
* Added weekly digest schedule and email sender.
* Added service plan links in admin page.
