=== Hostious Cost Price and Margin for WooCommerce ===
Contributors: hostiousio
Tags: woocommerce, cost of goods, profit, margin, product management
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.10.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Add a cost price to simple products and variations, then see estimated profit and gross margin directly in the WooCommerce product editor.

== Description ==

Hostious Cost Price and Margin for WooCommerce adds a cost-price field to the WooCommerce product editor for simple products and individual variations.

The plugin displays two read-only estimates beside the cost price:

* Estimated profit: selling price excluding tax minus cost price.
* Gross margin: estimated profit as a percentage of the selling price excluding tax.

The selling price is converted to a tax-exclusive amount using your WooCommerce tax configuration. Cost prices saved by earlier versions are still read and are moved to the new storage key the next time the product is saved.

The plugin does not alter product prices, create orders, add storefront output, send data to external services, or include tracking.

== Installation ==

1. Install and activate WooCommerce.
2. Upload the plugin ZIP through Plugins > Add New Plugin > Upload Plugin, or install it from the WordPress.org Plugin Directory when available.
3. Activate the plugin.
4. Edit a simple product or product variation and enter its cost price excluding tax.
5. Save the product to refresh the estimated profit and gross margin.

== Frequently Asked Questions ==

= Does the cost price include tax? =

No. Enter the cost price excluding tax. The plugin asks WooCommerce for the selling price excluding tax before calculating the estimate.

= Does the plugin change my product prices? =

No. It only stores the cost price and displays calculations in the product editor.

= Does it support variable products? =

Yes. Each variation can have its own cost price, estimated profit, and gross margin.

= Where is the cost price stored? =

It is stored as product metadata under the `_hostious_cpm_cost_price` key. Values saved by versions before 1.10.0 under `_kostpris` are still read and are moved to the new key when the product is saved.

= Is any data sent outside my website? =

No. The plugin has no external service, telemetry, advertising, or tracking.

== Screenshots ==

1. Cost price, estimated profit, and gross margin for a simple product.
2. Close-up of the pricing, cost price, estimated profit, and gross margin fields.

== Changelog ==

= 1.10.1 =

* Declared compatibility with WooCommerce High-Performance Order Storage (HPOS) and the cart and checkout blocks. The plugin was listed as incompatible with WooCommerce features on stores with HPOS enabled. It does not read or write orders.

= 1.10.0 =

* Changed: all functions, form fields and the product-meta key now use the unique `hostious_cpm_` prefix.
* Cost prices saved under the previous `_kostpris` key are still read and are moved to `_hostious_cpm_cost_price` when a product or variation is saved.
* Tested with WooCommerce 11.2.

= 1.9.0 =

* Prepared the plugin for WordPress.org distribution.
* Added capability, nonce, unslashing, and decimal sanitization checks when saving cost prices.
* Use WooCommerce tax configuration instead of assuming a fixed VAT rate.
* Preserve the existing `_kostpris` metadata for backwards compatibility.
* Add WordPress.org metadata, documentation, and GPLv2-or-later licensing information.

== Upgrade Notice ==

= 1.10.0 =

Existing cost prices keep working. They move to a new, prefixed storage key the next time each product is saved.

= 1.9.0 =

Existing cost prices are preserved. Profit calculations now follow the store's WooCommerce tax configuration.
