=== RawType Order Exporter — Spreadsheet & CSV for WooCommerce ===
Contributors: rawtypedev
Tags: woo export, export orders, excel export, csv export, order report
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Requires Plugins: woocommerce

Export WooCommerce orders, products & customers to Excel or CSV. Visual query builder with smart filters and bulk download.

== Description ==

**RawType Order Exporter — Spreadsheet & CSV for WooCommerce** lets you build custom data queries visually and download WooCommerce orders, customers and products as Excel (.xlsx) or CSV files with smart filters — no coding required.

Whether you need a quick order report for your accountant, a filtered product list for inventory, or a full customer spreadsheet for your CRM, this plugin handles it in seconds.

= Why Choose This Plugin? =

* **Visual Query Builder** — drag, drop and configure fields without writing a single line of code
* **Export to Excel & CSV** — native .xlsx and .csv support, ready to open in Excel, Google Sheets or LibreOffice
* **Woo Orders Export** — download orders with all details: status, totals, line items, shipping, billing and custom fields
* **Product & Customer Data** — not just orders — get products with variations, stock, prices, and customers with purchase history
* **Smart Filters** — filter by date range, order status, product category, customer role and more before downloading
* **Bulk Processing** — handle thousands of rows efficiently with background processing
* **Modern React Interface** — fast, responsive admin panel powered by the WordPress REST API
* **HPOS Compatible** — fully compatible with WooCommerce High-Performance Order Storage
* **Lightweight & Fast** — minimal footprint, loads only on plugin pages
* **Translation Ready** — fully internationalized with translations for 10 languages included

= Export Woo Data Your Way =

Stop copying data manually from your Woo store. This plugin gives you a visual query builder where you select exactly which fields to include in your Excel or CSV spreadsheet. Choose from orders, products or customers, apply filters, and download your file in one click.

= Works With =

* WooCommerce 8.2+ (including HPOS)
* WordPress 5.8+
* PHP 7.4+
* Excel, Google Sheets, LibreOffice, Numbers

= Pro Features =

* Scheduled automatic reports (daily, weekly, monthly)
* Direct Google Sheets integration
* Advanced calculated columns
* Email delivery of spreadsheet files
* Priority support
* [View Pro features →](https://rawtype.dev/rawtype-order-exporter-woocommerce)

== Installation ==

1. Go to **Plugins → Add New** in your WordPress admin and search for "Export Orders to Excel".
2. Click **Install Now**, then **Activate**.
3. Navigate to **WooCommerce → Export Excel** to start building your first query.

Alternatively, upload the plugin ZIP file via **Plugins → Add New → Upload Plugin**.

= Requirements =

* WordPress 5.8 or higher
* WooCommerce 8.2 or higher
* PHP 7.4 or higher

== Frequently Asked Questions ==

= How do I export Woo orders to Excel? =

Go to **WooCommerce → Export Excel**, select "Orders" as your data source, choose the fields you want to include (order number, status, customer name, totals, line items, etc.), apply any filters, and click **Export to Excel**. Your .xlsx file downloads instantly.

= Can I export Woo orders to CSV? =

Yes. When building your query, choose CSV as the output format instead of Excel. The CSV file is generated with the same visual query builder, filters and field selection.

= What data can I export? =

Three data types are available: **orders** (with line items, billing, shipping, totals, custom fields), **products** (with variations, stock, prices, categories, images), and **customers** (with purchase history, addresses, roles).

= Does it support WooCommerce HPOS (High-Performance Order Storage)? =

Yes, the plugin is fully compatible with WooCommerce HPOS. It works with both the legacy posts-based storage and the new custom order tables.

= Can I filter orders before exporting? =

Absolutely. The visual query builder includes smart filters: date range, order status (processing, completed, refunded, etc.), product category, customer role, payment method, and more. Only matching orders appear in your Excel or CSV report.

= Does it work with large stores? =

Yes. The engine handles large datasets efficiently. For very large stores, processing runs in the background so your browser stays responsive.

= Is this plugin free? =

The free version includes full functionality for orders, products and customers with the visual query builder. The Pro version adds scheduled reports, Google Sheets integration, calculated columns and email delivery.

= Where can I get support? =

Use the [WordPress.org support forum](https://wordpress.org/support/plugin/rawtype-order-exporter-woocommerce/) for free plugin support. Pro users receive priority support at [rawtype.dev](https://rawtype.dev/).

== Screenshots ==

1. Choose what to export — orders, products, customers, or cross-entity queries. Each card shows available fields and record counts.
2. Pre-built export templates let you download common reports with one click — no configuration needed.
3. Filter orders by date range using quick presets or custom calendar selectors. A live counter shows matching records.
4. Select, search, and reorder export columns with drag-and-drop. Category tabs group fields by order, billing, shipping, and more.
5. Preview up to 10 rows of real data before exporting. Verify columns and values are correct without downloading a file first.
6. Compare Free and Pro plans side by side. The free version includes all essential export features with no time limit.

== Source Code ==

The full, human-readable source for the bundled admin JavaScript (`build/admin/index.js`) is shipped inside this plugin under the `src/admin/` directory. The build tooling required to regenerate the bundle is also included:

* JS sources: `src/admin/` (React components, hooks, utilities — plain `.js` / JSX, no minification)
* Build config: `webpack.config.js`, `package.json`
* Build command: `npm install && npm run build` (uses `@wordpress/scripts`)

The compiled output lives in `build/admin/` and is generated 1:1 from the files in `src/admin/`. No obfuscation is applied.

== Changelog ==

= 1.1.0 =
* Performance: Excel (XLSX) exports now stream to disk row by row instead of building the whole spreadsheet in memory. Exports of tens of thousands of records that previously exhausted PHP memory now complete with a flat memory footprint (verified: 50,000 rows under a 64 MB limit).
* Performance: Large exports no longer time out. The export loop now extends the time limit and clears the WooCommerce object cache between batches, and raises the memory limit for the run.
* Performance: Exporting products with variations expanded loads variations in batches instead of one query per variation, removing an N+1 slowdown on large catalogs.
* Performance: Row counting for expanded exports no longer scans the whole dataset twice before exporting.
* Fix: The "Exporting…" button could stay stuck forever if the server was slow; exports now have a client-side timeout and a clear message, and the UI recovers cleanly on errors.
* Fix: Saving an export profile now shows an inline error and lets you retry instead of leaving the dialog stuck on "Saving…".
* Fix: Product search in filters no longer shows stale results from an earlier keystroke.
* Fix: The data preview no longer briefly flashes "No results" while loading.
* Fix: SKU "contains" filters treat `%` and `_` as literal characters instead of wildcards.
* Fix: Order ID resolution for product/total filters now sorts deterministically, preventing duplicated or missing rows when an export reaches its limit.
* Security: The preview endpoint now caps the sample size it will return, so a single request can no longer ask the server to load the entire store.
* Security: Forced custom-field re-scans are rate limited to protect large stores from repeated heavy queries.
* Dev: Replaced the in-memory XLSX engine (PhpSpreadsheet) with a lightweight built-in writer (requires the PHP zip extension), removed dead code, and standardized HPOS detection and error handling. No changes to exported file formats.

= 1.0.8 =
* Compatibility: Tested up to WordPress 7.0 and WooCommerce 10.8 (verified on PHP 7.4). No functional changes.

= 1.0.7 =
* Fix: XLSX export failed in production with "Unable to create the export file." The Strauss build did not rewrite vendor namespace references in plugin source, so PhpSpreadsheet class checks always returned false against the prefixed `RawTypeOE\Vendor\` namespace. Enable Strauss `update_call_sites` so call sites in `includes/` and `admin/` are updated at build time.
* Fix: Repair Strauss-prefixed `vendor-prefixed/` references where the rewriter collapsed self-named packages (e.g. `\ZipStream\ZipStream`) to a single segment. Without the trailing class name the return type resolved relative to the current namespace and XLSX writes failed at runtime with `TypeError`.
* Performance: Custom-fields scanner now runs a single grouped scan with `COUNT(*)` instead of `COUNT(DISTINCT)` plus a separate sample query. On large stores (100k+ orders) the previous shape blocked the REST request long enough for the browser to give up; the new query stays on the meta_key index and returns in well under a second.

= 1.0.6 =
* Dev: Ship the React/JSX sources (`src/admin/`) and build tooling (`webpack.config.js`, `package.json`) inside the plugin ZIP so the bundled admin JavaScript is fully reproducible from public source, per WordPress.org guideline #4.
* Dev: Update Plugin URI to `https://rawtype.dev/rawtype-order-exporter-woocommerce` (now publicly resolvable).
* Dev: Drop the vendored PhpSpreadsheet documentation file whose name contained a space (cross-filesystem compatibility).

= 1.0.5 =
* Dev: Ship a phpcs.xml.dist at the plugin root so IDE linters pick up the correct text domain (`rawtype-order-exporter-woocommerce`) and stop reporting spurious TextDomainMismatch errors.

= 1.0.4 =
* Security: harden Content-Disposition header (RFC 6266) and strip CR/LF in download responses to prevent header injection.
* Security: drain all output buffers before streaming downloads so binary files cannot be corrupted by stale buffers.
* Security: reject null bytes and leading `../` segments in download path resolution.
* Security: neutralize spreadsheet formula injection in CSV and XLSX exports — cells starting with `=`, `@`, tab, or non-numeric `+`/`-` are written as literal text, while negative prices stay numeric.
* Fix: order/product/stock status codes are now translated in exported files (matching the preview) instead of leaking raw slugs like `wc-processing`.
* Fix: customer export resolves the most recent order via a single batched query (was one query per customer) and skips the lookup entirely when last-order columns are not selected.
* Fix: order pagination now sorts by ID instead of `date_created`, so chunks remain stable when multiple orders share the same timestamp (no more duplicated/missing rows).

= 1.0.3 =
* Fix: Clean release packaging for WordPress.org by excluding development-only files from the distributable plugin.
* Fix: Harden custom field scanner queries and customer metric filters for better Plugin Check compatibility.
* Fix: Improve test/bootstrap stubs used during development to avoid false positives in preflight checks.

= 1.0.2 =
* Fix: Resolve all Plugin Check warnings — proper SQL prepare() usage and phpcs annotations.
* Fix: Include composer.json in build ZIP to satisfy Plugin Check vendor directory requirement.

= 1.0.1 =
* Fix: Minor improvements and compatibility checks.

= 1.0.0 =
* Initial release of RawType Order Exporter — Spreadsheet & CSV for WooCommerce.
* Visual query builder for orders, products and customers.
* Excel (.xlsx) and CSV formats.
* Smart filters: date range, order status, categories, customer roles.
* WooCommerce HPOS compatibility.
* Translations for 10 languages included.

== Upgrade Notice ==

= 1.0.4 =
Security and correctness release: header-injection hardening, CSV/XLSX formula-injection mitigation, accurate exported status labels, batched customer last-order lookup, and stable order pagination. Recommended for all users.

= 1.0.3 =
Recommended update for WordPress.org submission cleanup and query compatibility improvements.

= 1.0.0 =
First release — export Woo orders, products and customers to Excel or CSV with a visual query builder.
