How profit and margin are calculated
A report is a set of decisions about what to count. Here are all of ours, in the order they affect the figure on the screen, with a worked example on the same demo data the screenshots use.
Updated
Revenue
The net line total of the goods sold, after discounts, excluding tax and excluding shipping.
Tax is not your money, so it is left out. Shipping is left out because WooCommerce records no cost for a shipping line: counting the shipping charge as revenue with no cost against it would make every margin look better than it is.
Coupons are already applied. WooCommerce stores line totals after discounts, so a 20% coupon shows up as lower revenue, not as a separate deduction.
Cost of goods
The sum of the costs recorded on the sold items, read from the order lines, not from today’s product records.
This is the part that makes the report worth building: WooCommerce writes the cost onto the order line at the moment of sale, so an order from last March reports what the goods cost last March. It can still be overwritten: issuing a refund, or recalculating an order’s totals, makes WooCommerce recalculate the cost from today’s product cost. That is core behavior, explained separately.
Gross profit
gross profit = revenue on items with a known cost − cost of those items
Note the first half. Profit is calculated only on items whose cost is known. An item with no recorded cost still counts toward revenue, but it never enters the profit calculation as if the goods had been free.
Treating a missing cost as zero would produce a bigger, friendlier, and completely false profit figure. It is the easiest way for a profit report to mislead you.
Margin
margin = gross profit ÷ revenue on items with a known cost
Profit divided by revenue, not markup on cost. A product bought for 60 and sold for 100 has a 40% margin here. Its markup is 66.7%, and suppliers usually quote that one—the margin and markup calculator converts between them.
Coverage—how much of the revenue has a known cost
coverage = revenue on items with a known cost ÷ total revenue
Printed at the bottom of the summary panel as a sentence rather than a badge:
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.
Coverage is not a score to push to 100%. A store that gives away free samples stays below 100%, and so does any period from before you entered your costs. That is the correct answer, not a defect.
A worked example
The demo store on the sample report, over twelve months:
| Figure | Value | Where it comes from |
|---|---|---|
| Revenue | $4,078,050.78 | all counted order lines |
| Revenue with a known cost | $3,054,055.76 | revenue minus the uncovered part |
| Revenue with no cost recorded | $1,023,995.02 | the 25% |
| Cost of goods | $1,579,544.48 | costs recorded on those lines |
| Gross profit | $1,474,511.28 | 3,054,055.76 − 1,579,544.48 |
| Margin | 48.3% | 1,474,511.28 ÷ 3,054,055.76 |
| Coverage | 75% | 3,054,055.76 ÷ 4,078,050.78 |
Margin is calculated on covered revenue, not on total revenue. Otherwise it would drop by a quarter for a reason that has nothing to do with your prices. And profit is smaller than “revenue minus cost” for the whole store would suggest, because a quarter of the revenue is left out of the calculation.
Which orders are counted
Completed, processing, and refunded. Cancelled, failed, pending payment, draft, and on-hold orders are not counted at all. They are not zero-profit sales. They are simply left out.
Refunded belongs on that list for a reason that is easy to miss: a full refund flips the original
order to refunded, so excluding that status would delete the sale while keeping the refund, and
the order would count as minus its own value. The whole
argument.
Refunds
A refund counts as a negative amount in the period it was issued, not in the period of the original sale. A September sale refunded in November leaves September’s revenue exactly as it was.
Both sides move: the refund reduces revenue and recorded cost together, so a fully refunded order nets to zero rather than to minus its own margin.
What is deliberately left out
- Shipping income and shipping cost. No cost field exists for a shipping line.
- Payment and gateway fees. They are not in the order data in any standard form.
- Orders in another currency. Named in a warning and excluded, with no exchange rates applied. Why.
- Anything other than the goods themselves—rent, salaries, ads. This is a gross profit report, and gross profit is a real, useful number precisely because its boundary is clear.
Categories overlap on purpose
A product in three categories is counted in all three, so the category rows can add up to more than the summary. WooCommerce has no primary category, so the alternative would be inventing one. The details.
How far back it reaches
There is no time limit. The report counts the dates you pick. The shortcuts go back 12 months at most, but a custom range accepts any two dates, back to your oldest order, and the two date fields always show the days actually counted.
What ends the history is the cost data rather than the range: revenue reaches back to the oldest order, while profit and margin reach back only to the day costs started being recorded. How far back the report reaches.
Where these numbers come from in the database
For anyone who wants to check the arithmetic against their own SQL:
- product cost —
_cogs_total_valuein postmeta, pluswc_product_meta_lookup.cogs_total_value, which isNULLwhen no cost is entered; - order line cost —
_cogs_valueinwoocommerce_order_itemmeta, the same table under HPOS and classic storage; - order total cost —
_cogs_total_valueinwc_orders_metaunder HPOS, in postmeta otherwise; - line revenue—the line item’s net total, from the same order items tables.
The report is calculated by your own database and never leaves your server. If a figure here doesn’t match what you get by hand, email us. A wrong number is the only real failure this kind of product can have.