=== OpsAssist Data Bridge for WooCommerce — POS, Inventory & Membership Sync ===
Contributors: opsassistrsa
Tags: woocommerce, openpos, inventory, point-of-sale, memberships
Requires at least: 5.6
Tested up to: 6.9
Requires PHP: 7.0
Stable tag: 1.4.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect WooCommerce to the WC-Manager dashboard. Sync POS, multi-location stock, wallet balances and memberships the REST API hides.

== Description ==

**Turn the data your WooCommerce store already collects into decisions.** OpsAssist Data Bridge is the free companion plugin that securely links your store to the [WC-Manager dashboard](https://wc-manager.com) by Ops Assist — a powerful analytics, inventory and point-of-sale management app built for WooCommerce shops.

A lot of valuable data lives in your store but stays locked away: OpenPOS outlets and registers, per-location stock counts, digital-wallet (TeraWallet/WooWallet) balances, and WooCommerce Memberships. The **standard WordPress REST API can't see most of it.** This lightweight plugin adds a small set of authenticated, **read-only** endpoints that surface that data safely, so your WC-Manager dashboard can read it without giving away the keys to your store.

Install it once, activate, and your dashboard detects it automatically — no WordPress Application Password, no copy-pasting feeds, no maintenance. Just your existing WooCommerce API key.

= Why store owners install it =

* **See your whole business in one place.** Bridge the POS, inventory and membership data WooCommerce normally hides, and view it all from one dashboard.
* **Manage stock across multiple outlets.** Surface OpenPOS per-location inventory so you can track and transfer stock between warehouses and registers.
* **Look after your members at the till.** Cashiers can pull up a customer's active WooCommerce Memberships right inside the OpenPOS terminal.
* **Faster, more accurate stock takes.** Count inventory category-by-category at the register and have it sync straight to the web app.
* **Secure by design.** Every endpoint is read-only and requires an authenticated user with the `manage_woocommerce` capability. Nothing is exposed publicly.
* **Zero performance cost.** Endpoints only run when requested and wallet results are cached — your storefront stays fast.

= What the WC-Manager dashboard does with this data =

Once your store is connected, WC-Manager turns the bridged data into tools that help you sell more and stock smarter:

* **AI Insights** — a plain-English summary of your sales, customers and POS data, with an action list and an estimated business valuation.
* **AI product descriptions** — generate SEO-ready short and long copy in your chosen tone and push it back to WooCommerce in one click.
* **Sales, profit & customer reports** — revenue and profit broken down by month or by year, quantities of every product sold, an order-timing heatmap, repeat-buyer rates and lifetime value.
* **Multi-location inventory** — per-warehouse stock, multi-item stock transfers between locations, and a stock-by-location overview that breaks out variations. Built-in warehouses sync with OpenPOS outlets when mapped.
* **Supplier prices & purchase orders** — assign suppliers and prices to products, auto-fill purchase orders, set the PO date, add products and variations as line items, receive into specific OpenPOS outlets, and return-to-supplier with automatic stock reversal. Supplier prices sync to the OpenPOS cost price when OpenPOS is installed.
* **Restock Predictor** — velocity-based reorder forecasts so you never run out of your best sellers.
* **Order management** — review orders and change order status without leaving the dashboard.
* **Membership management** — list every member, filter by plan and by status (active, cancelled, expired and more), and flag placeholder or invalid email addresses.
* **Spreadsheet product editing** — bulk-edit prices, stock, supplier prices and custom meta fields like a spreadsheet.
* **Category stock takes** — count at the OpenPOS register or on the web, with variance analysis and CSV export.
* **Team access & audit log** — role-based access for your whole team and a full before/after activity trail.
* **Refer a friend** — earn account credits when a store you refer subscribes.

The dashboard is a separate product at [wc-manager.com](https://wc-manager.com) (free plan available); this plugin is the secure connector that makes it work with your store.

= What's free and what's paid? =

**This plugin is 100% free** — install it, connect your store, and use it at no cost, forever.

The WC-Manager dashboard it connects to has a **Free plan** and an optional **Pro plan**:

**Free — forever (no credit card):**

* Store overview, orders and customer list
* Change order status from the orders page
* Full product catalogue (read-only)
* Supplier directory and purchase orders (build + receive flow)
* Refer a friend and earn account credits
* AI product descriptions — 1 free generation per week

**Pro:**

* AI Insights — your sales and customers summarised in plain English with an action list and business valuation
* Reports — profit by month or year, quantities of every product sold, Order Clock, Product Chemistry, Spend Spectrum, Revenue Pulse and customer LTV
* Multi-location inventory — stock by location, multi-item stock transfers and warehouses
* Membership management — list and filter members by plan and status
* Restock Predictor — velocity-based reorder forecasts
* Spreadsheet product editing — bulk price, stock, supplier price and custom meta changes
* Supplier prices that auto-fill purchase orders (and sync to the OpenPOS cost price)
* Category stock takes with CSV export
* Full activity audit log
* Team access control with unlimited seats
* Priority support

AI features (Insights and Descriptions) run on credits: the Pro plan includes a weekly allowance and you can top up anytime — credits never expire. See [wc-manager.com](https://wc-manager.com) for current plans and pricing.

= Works great with =

* **OpenPOS** — outlets, registers and the in-terminal Members & Stock Take panels.
* **WooCommerce Memberships** — read plans and per-customer memberships.
* **TeraWallet / WooWallet** — read store-credit balances.

= REST endpoints =

All endpoints require the caller to authenticate as a user with the `manage_woocommerce` capability.

* `GET /wp-json/woo-manager/v1/openpos-outlets` — OpenPOS outlets (`_op_warehouse` posts)
* `GET /wp-json/woo-manager/v1/openpos-registers` — OpenPOS registers (`_op_register` posts)
* `GET /wp-json/woo-manager/v1/terawallet/balances` — users with a non-zero TeraWallet balance
* `GET /wp-json/woo-manager/v1/terawallet/balance/{user_id}` — a single user's TeraWallet balance
* `GET /wp-json/woo-manager/v1/memberships/plans` — WooCommerce Memberships plans
* `GET /wp-json/woo-manager/v1/memberships/user/{user_id}` — a user's memberships

= OpenPOS panels (optional) =

* **Members** — cashiers can look up a customer at the register and see their active WooCommerce Memberships.
* **Stock Take** — run a category-by-category stock count at the register; counts auto-save and sync to the WC-Manager web app.

= External service =

The Stock Take panel communicates with the WC-Manager web app at **https://wc-manager.com** to load and save stock takes for your organisation. It authenticates with a per-organisation "plugin token" you paste into the plugin's settings page (WooCommerce → WC-Manager Stock Take). No data is sent until you configure that token and use the Stock Take panel. WC-Manager's terms and privacy policy: [https://wc-manager.com/terms](https://wc-manager.com/terms) and [https://wc-manager.com/privacy](https://wc-manager.com/privacy).

The REST endpoints, the Members panel, and TeraWallet/membership reads make no external requests — they only respond to authenticated requests into your own site.

= Privacy =

This plugin does not collect, store, or transmit personal data on its own beyond the Stock Take sync described above, which only sends the stock-count data you create to your own WC-Manager account. See [https://wc-manager.com/privacy](https://wc-manager.com/privacy).

= Note on trademarks =

WooCommerce is a registered trademark of Automattic Inc. This plugin is an independent companion plugin and is not affiliated with or endorsed by Automattic. OpenPOS and TeraWallet are products of their respective owners. WC-Manager is a separate product by Ops Assist.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install via the WordPress plugin installer.
2. Activate the plugin through the *Plugins* menu in WordPress.
3. Sign in to your WC-Manager dashboard — the bridge is detected automatically.
4. (Optional) To use the Stock Take panel, go to *WooCommerce → WC-Manager Stock Take* and paste your plugin connection token from WC-Manager.

== Frequently Asked Questions ==

= Is the plugin free? =

Yes. The OpsAssist Data Bridge plugin is completely free. The WC-Manager dashboard it connects to has a free plan plus an optional paid Pro plan; you can start on the free plan.

= Does this plugin require a WC-Manager account? =

The REST endpoints and the OpenPOS Members panel work for any authenticated user with the `manage_woocommerce` capability. To get the most out of the bridge — dashboards, reports, inventory and the Stock Take sync — connect a WC-Manager account (free plan available).

= How do I view my OpenPOS sales and outlets outside the POS terminal? =

Install this plugin and connect WC-Manager. The bridge surfaces your OpenPOS outlets and registers so the dashboard can report on per-outlet activity and stock from anywhere — no need to be at the till.

= Can I manage WooCommerce inventory across multiple locations? =

Yes. The plugin exposes OpenPOS per-location stock so WC-Manager can show stock by location, move inventory between warehouses, and keep counts in sync.

= Does it work with WooCommerce Memberships? =

Yes. It adds read-only endpoints for membership plans and per-customer memberships, and the OpenPOS Members panel lets cashiers look up a customer's active memberships at the register.

= Does it work with OpenPOS, TeraWallet and WooWallet? =

Yes. It reads OpenPOS outlets/registers and TeraWallet/WooWallet store-credit balances. It works on stores without these too — it simply exposes whatever WooCommerce data is present.

= Is my store data safe? =

Yes. Every endpoint is read-only and requires an authenticated user with the `manage_woocommerce` capability. The plugin makes no public endpoints and sends nothing externally except the stock-take counts you choose to sync to your own WC-Manager account.

= Will this plugin slow down my store? =

No. The REST endpoints only run when requested, and the wallet-balances result is cached for one minute. The OpenPOS panels only load inside the OpenPOS terminal.

= How do I uninstall? =

Deactivate and delete via WordPress *Plugins*. The only stored option is your Stock Take plugin token; no database tables are created.

== Screenshots ==

1. The Members panel inside the OpenPOS terminal.
2. The Stock Take panel inside the OpenPOS terminal.

== Changelog ==

= 1.4.3 =
* Added a custom-header authentication method (X-WC-Manager-Key / X-WC-Manager-Secret). Some sites run a Basic-Auth or security plugin that intercepts the standard Authorization header and rejects non-WooCommerce REST routes as a failed login. The custom headers bypass that cleanly, survive redirects, and keep credentials out of the URL/access logs. The dashboard uses them automatically when available.

= 1.4.2 =
* Fixed authentication on servers where the Authorization header is consumed by PHP (most Apache mod_php and many FastCGI setups). The endpoints now read the WooCommerce consumer key/secret from PHP_AUTH_USER/PHP_AUTH_PW and REDIRECT_HTTP_AUTHORIZATION as well, matching how WooCommerce's own REST API authenticates. This resolves the dashboard reporting the plugin as "not detected" even when it is active.

= 1.4.1 =
* Hardened the plugin loader: if an upload is incomplete and an internal file is missing, the plugin now shows an admin notice and stops loading instead of triggering a fatal error. This prevents a partial update from taking a site down.

= 1.4.0 =
* The woo-manager/v1 endpoints now authenticate with your existing WooCommerce REST consumer key/secret — no WordPress Application Password needed. Store setup is just the API key plus this plugin.
* Added `/ping` (authenticated handshake + companion-plugin detection), `/media` (image upload), and `/cashiers` (user name resolution) endpoints so the dashboard can do everything through this plugin with one credential.

= 1.3.0 =
* Restructured into a multi-folder plugin.
* Added WooCommerce Memberships REST endpoints (`/memberships/plans`, `/memberships/user/{id}`).
* Merged the standalone "WC-Manager: Members" and "WC-Manager: Stock Take" companion plugins into this plugin as optional OpenPOS terminal panels. They load only when OpenPOS is present.
* Added the Stock Take settings page (WooCommerce → WC-Manager Stock Take). Existing tokens from the standalone Stock Take plugin are read automatically.
* Removed the self-hosted updater from the merged plugins — updates now come through WordPress.org.

= 1.2.0 =
* Renamed plugin to "OpsAssist Data Bridge for WooCommerce".
* Function prefix renamed to `oadb_*`.
* No changes to the REST endpoints or response shapes.

= 1.1.0 =
* Added a one-minute cache around the wallet-balances query.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.4.3 =
Recommended if your dashboard reports the plugin as "not detected" despite being active — adds a custom-header auth method that bypasses Basic-Auth/security plugins which block the standard Authorization header.

= 1.4.2 =
Important fix for "plugin not detected" — the endpoints now authenticate on servers that strip the Authorization header, the same way WooCommerce's own REST API does.

= 1.4.1 =
Recommended update. Adds a safety guard so an incomplete upload can never cause a fatal error on your site.

= 1.4.0 =
You can now remove the WordPress Application Password from your WC-Manager store connection — the plugin authenticates with your WooCommerce API key alone.

= 1.3.0 =
Adds membership endpoints and merges the Members and Stock Take OpenPOS panels into one plugin. If you used the standalone "WC-Manager: Members" or "WC-Manager: Stock Take" plugins, deactivate them after upgrading — their functionality now lives here.
