=== Tendforge Margin Lens for WooCommerce — Profit & COGS Reports ===
Contributors: tendforge
Tags: woocommerce, profit, cogs, reports, analytics
Requires at least: 6.5
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

See your real profit, not just revenue. Gross profit dashboard, per-order profit and margins, built on WooCommerce's native Cost of Goods Sold.

== Description ==

WooCommerce 10.3 added Cost of Goods Sold (COGS) to core — but it ships with **no reports**. You can record what every product costs you, yet there is nowhere to see what you actually earn.

**Margin Lens fills that gap.** It turns WooCommerce's own COGS data into the profit dashboard your store is missing:

* **Profit dashboard** — revenue, cost of goods, gross profit, margin %, and profit per order for any date range, with comparison against the previous period
* **Daily profit chart** — revenue vs. profit over time, so you spot expensive weeks at a glance
* **Top products by profit** — find out which products make you money and which only make you busy
* **Profit column on the orders list** — see each order's profit and margin without opening it
* **Cost column + filter on the products list** — instantly find products that still have no cost set, and update costs right from Quick Edit
* **Profit from day one** — new orders record their cost automatically. (Margin Lens Pro can backfill costs onto your existing orders.)
* **One-click setup** — enables WooCommerce's COGS feature for you and walks you through the rest

= Built the right way =

* Uses **WooCommerce's native COGS fields** — no duplicate cost database, no lock-in. Your data stays in WooCommerce even if you remove this plugin.
* **HPOS compatible** — works with High-Performance Order Storage and legacy storage alike.
* **Fast** — reports read from WooCommerce's indexed analytics tables with caching; nothing runs on your storefront.
* **Light** — no ads, no admin-wide notices, no tracking.

= Margin Lens Pro =

Free shows your **gross** profit. **Pro shows your real, bottom-line profit — and what's eating it:**

* **True net profit** — gross profit minus payment-gateway fees, shipping costs and handling, per order
* **Net after marketing** — log your ad spend by channel and date; Pro prorates it to the report range and subtracts it, so you see what you actually pocket
* **Low-margin product alerts** — automatically flags products earning below a margin threshold you set, on the dashboard and in your email report, so you know exactly what to reprice or drop
* **Customer depth** — top customers by profit *with lifetime value*, plus a new-vs-returning breakdown
* **CSV exports** — products, customers and daily figures for your accountant or spreadsheet
* **Scheduled email reports** — a weekly or monthly profit summary, including low-margin products, straight to your inbox

Everything stays on your own site — no monthly SaaS fee, no sending your sales data to a third party.

= Requirements =

* WooCommerce 9.5 or newer (10.3+ recommended, where COGS is a stable feature)

== Installation ==

1. Install and activate the plugin. Requires WooCommerce to be installed and active.
2. In the WordPress admin, open **WooCommerce → Profit** (the "Profit Reports" screen).
3. Set your product costs (Margin Lens can enable WooCommerce's Cost of Goods Sold feature in one click, then each product gets a "Cost of goods" field) so margins are accurate. The report then shows revenue, cost of goods, gross profit and margin per order and per product for any date range.
4. Use the Settings tab to record payment, processing and shipping fees, low-margin alert thresholds and marketing/ad spend, export your figures to CSV, and turn on the optional scheduled email profit summary.
5. (Optional) Upgrade to Pro for net profit after fees, shipping and ad spend, new-vs-returning customers and top customers.

== Frequently Asked Questions ==

= Where do I enter my product costs? =

Once the COGS feature is enabled (Margin Lens offers a one-click button), every product gets a "Cost of goods" field in Product data → General. WooCommerce's CSV importer also supports the cost column for bulk updates.

= My past orders show no profit. Why? =

WooCommerce captures cost at checkout time, so orders placed before you enabled COGS have no cost data — those are shown without profit rather than guessed at. New orders are tracked automatically from here on; **Margin Lens Pro** can backfill costs onto your existing orders in one pass.

= Does it work with refunds? =

Yes. Refunded items are subtracted from cost and revenue, matching WooCommerce's own calculation.

= Does it support variable products? =

Yes. Costs can be set per variation (or inherited from the parent product), exactly as WooCommerce core implements it.

= Will this slow down my store? =

No. The plugin loads only in the admin, and report queries run against WooCommerce's indexed lookup tables with a short cache.

== Screenshots ==

1. The free profit dashboard: gross-profit KPIs, revenue vs. profit chart, top products by margin.
2. (Pro) True net profit after ad spend, and customer lifetime value.
3. (Pro) Settings: historical cost backfill, low-margin alerts, scheduled email reports.

== Third-Party Libraries ==

This plugin bundles the following third-party library. It is included unmodified and is not loaded from any external service:

* **Chart.js** v4.5.1 — renders the report charts in the admin screen.
  * License: MIT
  * Project: https://www.chartjs.org
  * License text: https://github.com/chartjs/Chart.js/blob/v4.5.1/LICENSE.md
  * Unminified source: https://cdn.jsdelivr.net/npm/chart.js@4.5.1/dist/chart.umd.js

== Changelog ==

= 1.2.0 =
* Renamed from Profit Lens to Margin Lens (no functional change) to avoid conflict with a third party's registered trademark on "ProfitLens" in the same product category.
* Updated the bundled Chart.js library to v4.5.1 and fixed a dead link in the third-party library notice below.

= 1.1.3 =
* Initial public release: a WooCommerce profit dashboard built on native Cost of Goods Sold, showing per-product and per-order profit and margin, top products by profit, order-list and product-list cost columns, with Pro adding net profit after fees, shipping and ad spend, low-margin alerts, CSV export, scheduled email summaries and customer insights.
