=== BigBad Store Toolkit for WooCommerce ===
Contributors: sofrustrate
Tags: woocommerce, cogs, cost of goods, inventory, scheduled sales
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.1.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Modular WooCommerce toolkit with COGS tracking, shared variation inventory, and extensible addon architecture.

== Description ==

**BigBad Store Toolkit** is a modular WooCommerce toolkit that gives store owners powerful tools for cost tracking and inventory management -- all under one unified admin panel.

Each feature is a self-contained addon that you can enable or disable independently. The free version ships with essential tools, and Pro unlocks advanced addons individually or as a bundle.

= Free Addons =

**COGS -- Cost of Goods Sold**

* Per-product cost input field in the product editor
* Per-variation cost tracking for variable products
* Category-level cost defaults (set once, apply to all products in a category)
* Global fallback cost in settings
* Cost and margin columns on the Products list table (sortable)
* Quick Edit support for fast cost entry

**Shared Variation Inventory**

* Define a shared stock pool for variable products
* Each variation draws a configurable number of units from the pool per sale
* Automatic stock deduction on order completion
* Automatic stock restoration on cancellation/refund
* Low stock warnings when the shared pool runs low
* Shared pool stock column on the Products list table
* Frontend low stock / out of stock notices

**Settings Panel**

* Toggle addons on/off from a central dashboard
* Configure COGS defaults (display column, global fallback cost)
* Shared inventory low stock threshold
* Data cleanup option on uninstall

= Pro Addons (available separately or as a bundle) =

* **COGS Analytics** -- Margin reports, cost trends over time, category-level profitability dashboards
* **Advanced Inventory Rules** -- Low-stock alerts on shared pool, reorder-point thresholds per product
* **Bulk Operations** -- CSV import/export of COGS data, bulk category cost assignment
* Additional addons released over time

= Why BigBad Store Toolkit? =

* **Modular** -- Only enable what you need. No bloat.
* **WooCommerce native** -- Uses standard WooCommerce hooks, meta fields, and admin patterns.
* **HPOS compatible** -- Fully compatible with WooCommerce High-Performance Order Storage.
* **Extensible** -- Pro addons integrate seamlessly. Developers can register custom addons.
* **Lightweight** -- No external API calls, no tracking, no unnecessary JavaScript libraries.

== Installation ==

1. Upload the `bigbad-store-toolkit` folder to `/wp-content/plugins/`.
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. Navigate to WooCommerce > BigBad Store Toolkit to configure settings and manage addons.
4. WooCommerce must be installed and active.

== Frequently Asked Questions ==

= Does this require WooCommerce? =

Yes. BigBad Store Toolkit requires WooCommerce 7.0 or later.

= How does the COGS cost hierarchy work? =

The plugin checks for cost in this order: per-product cost > parent product cost (for variations) > category default cost > global default cost from settings. The first value found is used.

= How does Shared Variation Inventory work? =

When enabled on a variable product, you set a total pool stock quantity. Each variation has a "unit size" (defaults to 1). When a customer buys a variation, its unit size multiplied by the quantity ordered is deducted from the shared pool.

= Will my data be deleted if I deactivate the plugin? =

No. Deactivating the plugin does not delete any data. Data is only removed if you uninstall (delete) the plugin AND have enabled "Delete Data on Uninstall" in the settings.

= Is this compatible with HPOS (High-Performance Order Storage)? =

Yes. The plugin declares HPOS compatibility and uses standard WooCommerce APIs.

= Can I add my own addons? =

Yes. Developers can register custom addons using the `bbetk_register_addons` action hook. See the documentation for details.

== Screenshots ==

1. Overview dashboard - active addons and store-health cards (products without COGS, low-stock shared pools, out-of-stock pools, and negative-margin products).
2. COGS margin dashboard - cost, margin, and effective margin (after overhead and processing fees) with Top 10 and Bottom 10 margin tables.
3. Settings - COGS column and default cost, shared-inventory low-stock threshold, scheduled-sales discount ceiling / duration / generator range, and data cleanup on uninstall.
4. Getting Started - guided first-run walkthrough from a fresh activation to a working setup.
5. How It Works - per-addon documentation for COGS, Shared Variation Inventory, and Scheduled Sales, plus developer hooks.

== Changelog ==

= 1.1.2 =
* Fix: the COGS, Margin and Shared Pool columns on the Products list were 0 px wide at 1280 px with WooCommerce's default columns. The toolkit's stylesheet (which sizes them) now loads on the Products list and product edit screen, not only on the toolkit's own pages.
* Fix: Shared Inventory > Activity was always empty. WooCommerce hides order notes from ordinary comment queries; the tab now reads them the way WooCommerce does, and its order links work with HPOS.
* Fix: a variable product with a cost on every variation was counted as "missing COGS" (COGS overview and the dashboard). Variable products are now judged by their variations; the Products list shows their cost and margin range, and a product with some variations uncosted is still flagged.
* Fix: Bulk Apply forgot your scope, categories, mode, value and filters after "Preview Match Count"; they are now kept so "Apply Now" applies exactly what you previewed.
* Fix: generated sales are flagged as generated before WordPress's save hooks run, and a new `bbetk_sale_generated` action fires once each sale is fully written, so Pro's approval queue catches them.
* Fix: the per-product low-stock threshold filter (`bbetk_shared_inventory_low_stock_threshold_for_product`) is now applied to the storefront notice, the Products list column, All Pools, the low-stock admin notice and the dashboard (it was never called).
* Fix: the dashboard's "negative margin" count now uses the same cost rules as the COGS addon (variation, category and global default costs).
* Copy: Pro upsell text now lists only what Pro ships (removed forecasting, per-sale analytics, margin guardrails, period comparisons, randomization seed, and an unbuilt "coming next" list).

= 1.1.1 =
* Removed incorrect trial offer; upgrade notice now links to the plugin's page.
* The Pro notice now shows only on the Plugins screen and this plugin's own admin pages, and stays dismissed once dismissed.
* Fix: the dashboard Pro panel described features Pro does not have; it now lists what Pro actually adds, and its links open the plugin's page instead of the homepage.

= 1.1.0 =
* New: **Getting Started** admin page - a guided first-run walkthrough from a fresh activation to a working setup.
* New: a dismissible Pro notice for shop managers/admins (hidden once Pro is active). No Pro code ships in the free plugin.
* Docs: refreshed the screenshot set (Overview, COGS margin dashboard, Settings, Getting Started, How It Works).
* No changes to the COGS, Shared Variation Inventory, or Scheduled Sales engines.

= 1.0.0 =
* Initial release
* COGS addon: per-product cost, category defaults, margin display, quick edit support
* Shared Variation Inventory addon: shared pool stock, per-variation unit deduction
* Settings panel: addon toggles, COGS configuration, shared inventory threshold
* Admin dashboard with addon overview and pro upgrade CTA
* uninstall.php with opt-in data cleanup
* Full i18n support
* WooCommerce HPOS compatibility declared

== Upgrade Notice ==

= 1.1.2 =
Fixes the 0 px COGS/Margin/Shared Pool columns, the empty Shared Inventory Activity tab, variable products counted as missing COGS, and Bulk Apply forgetting your choices after Preview.

= 1.1.1 =
Removes an incorrect trial offer from the Pro notice and fixes Pro links. No changes to how the plugin works; safe upgrade.

= 1.1.0 =
Adds a Getting Started guide. No changes to the addon engines; safe upgrade.

= 1.0.0 =
Initial release of BigBad Store Toolkit for WooCommerce.
