Cost of Goods Sold in WooCommerce—how to switch it on and fill in your costs
Since version 10.3, WooCommerce can record the cost of goods sold on every order. The feature is off by default, nothing is filled in backward, and three things about it are genuinely surprising. Here is the whole picture on one page.
Updated
What the field is, and why it arrived so late
WooCommerce has always known what you sold. Until late 2025 it had no idea what those goods cost you, which is why “how much did I actually earn” was a question you answered in a spreadsheet, or paid a monthly subscription for.
In WooCommerce 10.3, released on October 22, 2025, after a beta period, the cost of goods sold became part of core. It does two things, and the second one is what matters:
- on the product, you can store a cost—a single net figure per item;
- on every order line, WooCommerce stores the cost as it stood at the moment of sale.
That second one is the part no plugin could retrofit properly. A cost stored on the order is a historical fact: an order from March still says what the goods cost in March, even after your supplier has raised prices twice. A cost looked up from today’s product record is just today’s guess applied to last year’s sales.
The feature is opt-in, and it does nothing at all until you switch it on.
Step one—switch the feature on
WooCommerce → Settings → Advanced → Features → Cost of Goods Sold.
Check the box and click Save changes. The checkbox changes no data by itself, and it is a WooCommerce setting, not part of any reporting plugin. If the entry is not in that list, your store is on a version older than 10.3—check WooCommerce → Status and update first.
Leaving it off has a price that is paid silently: while the feature is disabled, new orders record no cost at all, and that gap cannot be filled in later. Six months of orders taken with the switch off are six months for which no report will ever have the real cost.
Step two—enter the cost on a product
The field sits in the General tab of the product editor, right under the price fields, and it is called Cost of goods. Three details matter:
- enter it net, without tax, even if you enter your prices with tax. WooCommerce stores the number exactly as you type it;
- it is per item, not per order line;
- zero and empty are the same. WooCommerce saves a 0 on a product as an empty field. A good report treats an empty field as “we do not know” instead of quietly assuming the goods were free.
Enter the cost you actually pay for the goods. Whether you include inbound shipping, customs, or packaging is your decision, but make the same decision for every product. A margin computed from two different definitions of cost is not comparable to anything.
Step three—let the orders come in
From the moment the cost is on the product, every new order records it. Orders already in the database keep whatever they recorded at the time, which for older orders means nothing at all.
There is no backfill, and this is deliberate rather than an omission. It also means the useful question after setting this up is not “why is my history empty” but “which period do I have complete data for”.
Filling in costs without clicking through 500 products
You do not have to open each product. With the feature on, Quick Edit in Products → All Products has a Cost field. Bulk Edit has one too, but it gives every selected product the same cost. For different costs on many products, use WooCommerce’s own product CSV import: export your products, fill in the Cost of goods column, and import the file back with Update existing products checked.
You do not need every product first. Sort your catalog by revenue and start at the top. In many stores a few dozen products bring in most of the sales, so one evening of typing can cover most of your revenue. That share, the coverage, is what makes the rest of the report worth reading.
The cost is also scriptable. From WP-CLI, one call per product:
wp eval '$p = wc_get_product( 123 ); $p->set_cogs_value( 41.50 ); $p->save();'
To drive it from a spreadsheet, export id,cost as CSV and loop over it in a small script
calling the same two methods. The REST API carries the same value as a cost_of_goods_sold
object on products and variations, if you would rather work over HTTP.
Both routes, the CSV import and a ready script with a dry run, are explained step by step in filling in costs in bulk.
All of these write to your store, so make a backup before any bulk change. Merchgain only reads your data and deliberately cannot fill in costs for you.
Variable products—inherit, replace, or add
A variation inherits its parent’s cost unless it has one of its own. In the product editor, leave a variation’s Cost field empty and it uses the parent’s cost; enter a cost and it replaces the parent’s.
WooCommerce also has a third mode the editor doesn’t show: a variation cost added to the parent’s. A shirt with a cost of 24 and an additive variation at 3 costs 27, which suits a surcharge such as embroidery or an oversized print. There is no switch for it in the admin; it can be set only through the REST API or in code.
One trap comes with it: WooCommerce’s lookup column stores the entered value, not the effective one, so a variation that simply inherits the parent’s cost looks like a variation with no cost at all. Any list of “products with no cost” that ignores the parent will be full of false alarms. The details are in costs on variable products.
Three traps the documentation does not mention
All three are in the WooCommerce source, and all three change the numbers a report shows. Know them before you build a spreadsheet on top of this data. The full version, with the line of code behind the first two, is in three traps in WooCommerce cost data.
A cost of zero is stored as no cost at all
When an order line’s cost is saved as zero, the core deletes the value instead of storing a zero. So a free sample and a product nobody has costed are the same absence in the database, and no plugin can tell them apart. The product field works the same way: a 0 typed into it is saved as empty. Freebies will always show up on a missing-cost list. The full explanation.
A refund rewrites the recorded cost of the whole order
Creating a refund makes WooCommerce recalculate the cost of every line on the original order using each product’s cost as it is today. If your buying price has changed in the meantime, the stored history changes with it—and if the cost was cleared, the recalculation produces zero, which deletes the value for good. Why historical profit changes.
Switching the feature off leaves a gap that never fills
Turning the feature off deletes nothing. Orders you edit or refund while it is off keep the costs they recorded, because WooCommerce skips the cost save entirely while the feature is off. The trap is the gap: orders taken while it is off record no cost, and nothing fills them in when you switch it back on. Until November 3, 2026, this page said that saving an order with the feature off could delete its cost. That was wrong. What switching it off does.
What a report can do with it
The core records the cost and stops there. WooCommerce 10.3 shipped no COGS reports at all, and the release post told developers they could build reporting tools on it. WooCommerce Analytics does not read it either—why the cost is not in Analytics. Outside the store, Google’s automated discounts for Shopping ads want the same cost in your product feed—what that setup needs. This is what Merchgain does with the same data:
Gross profit, revenue, cost of goods and margin for the period—the same numbers per product and per category further down the screen—and, under them, the line that decides whether any of it is usable:
Cost is known for 75% of revenue. Profit and margin above are calculated on that part only; $1,023,995.02 of revenue has no cost recorded.
That sentence is the difference between a report you can act on and a precise-looking report that is quietly wrong by a quarter. You can see the whole screen with demo data before installing anything.
When the feature is still off, a report has nothing to show, and saying so beats four zeros:
The short checklist
- WooCommerce 10.3 or newer—check WooCommerce → Status.
- Switch on Settings → Advanced → Features → Cost of Goods Sold.
- Decide once what “cost” includes for you, and write it down somewhere.
- Enter costs top-down by revenue, not alphabetically.
- For variations, pick one convention per product—inherit, replace, or add.
- Do not expect history to fill in. Judge the report on the period after the costs went in.
- Export a CSV at the end of each month. Refunds and recalculated orders can rewrite recorded costs; a monthly export is the only record nothing else can change.
If something here doesn’t match what you see in your own store, email us—every message is read, and the answers on this site get corrected when they turn out to be wrong.