=== Margin Lens ===
Contributors: yodsira
Tags: woocommerce, profit, margin, cost of goods, reports
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 1.1.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Real profit reports for WooCommerce: revenue minus the frozen cost of goods, for any period, with top products and categories.

== Description ==

WooCommerce shows you what you *sold*. Margin Lens shows you what you *earned*.

Set the cost of goods on your products once. Every time an order moves to
Processing or Completed, Margin Lens freezes that cost into the order - so
later price changes never corrupt your history. The report page then shows
revenue, cost, profit and margin for the last 7/30/90 days or any custom
range, with your top 5 products and top 5 categories by profit.

= How profit is calculated =

* Revenue = order line totals, net of coupons, excluding tax.
* Cost = the frozen per-order snapshots of your product costs.
* Refunds subtract the refunded revenue and return the refunded cost
  (the goods are back on your shelf).
* Profit = Revenue − Cost − Refunded revenue + Refunded cost.

= Highlights =

* Cost field right in the product editor (General tab, next to pricing),
  for simple products and every variation.
* Quick Edit and Bulk Edit in the products list; Bulk Edit leaves values
  untouched unless you type a new cost.
* Automatic cost snapshots on paid orders; the snapshot is written once
  and never rewritten.
* Report rendered in the clean Yodsira report style; works with
  WooCommerce High-Performance Order Storage (HPOS).
* 100% local: Margin Lens sends nothing anywhere. No accounts, no clouds,
  no telemetry.

= Margin Lens Pro =

The Pro companion adds a monthly profit dashboard with CSV export, manual
store expenses (rent, ads, salaries) with categories, a margin threshold
with Telegram alerts and a customer profitability (LTV) report.
Learn more: https://yodsira.com/en/product/margin-lens/

== Installation ==

1. Install the plugin through the WordPress plugins screen (Plugins ->
   Add New -> Upload Plugin) and activate it.
2. WooCommerce must be active.
3. Open Products -> edit any product and fill in "Cost of goods".
4. Open WooCommerce -> Margin Lens to see your profit report.

== Frequently Asked Questions ==

= Where do I enter the cost of a product? =

Products -> edit -> the General tab -> "Cost of goods" under the price.
For variable products you can set a cost per variation; a variation
without its own cost falls back to the parent product's cost.

= I changed the cost of a product. Will old orders change? =

No. The cost is frozen into every order at the moment it was placed -
that is the whole point. New orders pick up the new cost.

= What happens to orders placed before the plugin was installed? =

They show up as orders without cost data in the report and are counted
as revenue only. Fill in the product costs; new orders are covered
automatically. (Historical recalculation is a Pro feature.)

= Does it work with WooCommerce HPOS? =

Yes. Margin Lens declares full HPOS compatibility and reads order items
through the shared items tables, which work in both storage modes.

= Is anything sent to third parties? =

No. Margin Lens works entirely on your site and sends nothing anywhere.
The Pro Telegram alerts use the Telegram Bot API - only with your own
bot token, only if you turn the feature on.

== Screenshots ==

1. The Margin Lens report: revenue, cost, profit and margin cards for the chosen period.
2. Product editing with the "Cost of goods" field next to the price.

== Changelog ==

= 1.0.0 =
* First release: product cost field (simple + variations, quick/bulk edit),
  automatic cost snapshots on paid orders, profit report with period
  selector, top 5 products and categories, refund handling, HPOS support.

== Privacy & Data ==

Margin Lens stores the product costs you enter and the per-order cost
snapshots in your own WordPress database. Nothing is sent to any external
service. Uninstalling removes the plugin settings; the "delete data"
option in the report screen also removes all costs and snapshots.
