=== Margin Leak Guard for WooCommerce ===
Contributors: kindplugins
Tags: woocommerce, profit, margin, cost of goods, pricing
Requires at least: 6.2
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 1.1.7
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Scans your WooCommerce catalog and tells you which products are losing money right now: below cost, below minimum margin, or missing cost data.

== Description ==

Margin Leak Guard is a small, focused WooCommerce plugin that answers one question: **which products are losing you money right now?**

It is not another analytics dashboard. It runs a scan across your catalog and shows a short, prioritised list of problems you can act on:

* Products **priced below cost**.
* Products where the **sale price** dropped below cost.
* Products **below your minimum margin**.
* Products **missing cost data**, so you can't even tell.

= Free features =

* Set the cost of goods directly in the product editor's General pricing section, with an optional per-product minimum margin override.
* Scan simple and variable products (variation-aware).
* Reads cost from its own field and from common cost-of-goods meta keys used by other plugins.
* One-click margin scan with a clean, prioritised results table.
* Works with WooCommerce High-Performance Order Storage (HPOS).
* Shows a calm notice (never a fatal error) when WooCommerce is not active.
* Language: source strings are English (default). Ships with ready translations for Polish, German, Spanish, French, Italian and Portuguese — the plugin automatically follows your WordPress site language.

= Pro features =

* Automatic scans on the selected WP-Cron frequency: hourly, twice daily, daily, or weekly.
* Email summary alerts after scans when the issue threshold is reached.
* CSV export of the current issue list.
* Bulk cost screen for editing wholesale costs across many products at once.
* Reads cost from common COGS meta keys, with product-level minimum margin overrides.

Part of [KindPlugins](https://plugins.courselabz.com) — small WooCommerce plugins that catch expensive operational mistakes.

== Installation ==

1. Upload the `margin-leak-guard` folder to `/wp-content/plugins/`, or install the ZIP from Plugins → Add New → Upload Plugin.
2. Activate the plugin.
3. Make sure WooCommerce is active.
4. Open **WooCommerce → Margin Leak Guard**.
5. Set your global minimum margin under **Settings**, add cost of goods to your products, then run a scan.

== Frequently Asked Questions ==

= Does it need WooCommerce? =

Yes. Without WooCommerce it shows a calm notice instead of scanning. It never triggers a fatal error.

= Where does it read product cost from? =

By default it reads (and writes) `_mlg_cost`, and also reads common keys such as `_wc_cog_cost` as fallbacks, so cost you already entered in another plugin is picked up automatically. You can edit the list of keys under Settings.

= Does it change my prices? =

No. It only reads your catalog and reports problems. It never edits prices.

= Is it HPOS compatible? =

Yes. It declares compatibility with WooCommerce High-Performance Order Storage.

== Screenshots ==

1. Overview with prioritised margin issues.
2. Settings: margin rules and email alerts.
3. License: activate Pro to unlock CSV export, automatic scans, and alerts.
4. Cost of goods field in the product editor's General pricing section.

== Changelog ==

= 1.1.7 =
* Change: bulk wholesale-cost editor is now a Pro feature (per-product cost field stays free in the product editor).

= 1.1.6 =
* Fix: per-product Cost of goods field was missing from the product editor (registration fired too early). Now always shown under the price fields.

= 1.1.5 =
* Fix: bulk product cost editor rendered raw HTML in product names and variation rows were not clickable.
* Add: plugin icon on the WordPress updates screen and details popup.

= 1.1.4 =
* Moved the cost of goods field into the main WooCommerce General pricing section so it is visible next to regular and sale price.

= 1.1.3 =
* Added the KindPlugins logo asset to the admin header.

= 1.1.0 =
* Self-hosted one-click updates from plugins.courselabz.com (no wp.org needed).
* Redesigned HTML email alerts matching the KindPlugins look.

= 1.0.0 =
* Initial release: catalog margin scan, cost fields, Pro license unlock for CSV export, email alerts and daily scans, HPOS support, Polish + English.

== Upgrade Notice ==

= 1.1.0 =
Adds self-hosted updates and restyled email alerts.

= 1.0.0 =
First release.
