Costs

Cost of goods sold for online stores: the COGS formula and how to calculate it

COGS is what the products you sold cost you: units sold times unit cost, less units back in stock. The formula, a worked month, and where Shopify keeps it.

The short answer

Cost of goods sold (COGS) is what the products you sold cost you. For an online store it is the units sold in a period times their unit cost, less the cost of refunded units that came back to stock or never shipped. It also equals opening stock plus purchases minus closing stock. Sales minus COGS is gross profit.

Cost of goods sold, COGS for short, is what the products you sold in a period cost you to buy or make. The formula for an online store is units sold times their unit cost, less the cost of refunded units that came back to stock or never shipped; counted from the stockroom, the same figure is opening stock plus purchases minus closing stock. Sales minus COGS is gross profit, the first margin on any P&L. Below: both methods worked on one month of a small store, what goes into the unit cost and what does not, which day each cost counts on, where Shopify keeps the figure, and what a COGS percentage has to leave room for.

In short

  • COGS counts the goods only: shipping, packaging, payment fees and ads are costs of their own.
  • A unit's cost counts on the day it was sold, at the cost that applied that day.
  • A refund gives the cost back only for units that came back to stock or never shipped.
  • A product with no unit cost is a gap to fill, never a cost of zero.

The COGS formula, two ways

There are two ways to arrive at the same number. The first works order by order, which is how an online store's sales arrive: every unit sold, at its unit cost, less the units refunded that went back on the shelf. The second works from the stockroom, which is how an accountant closes a year: what was in stock at the start, plus what was bought, minus what is in stock at the end. If the stock records are right the two agree; where they differ, the gap is shrinkage, damage or a count that was wrong, and finding which is worth an afternoon.

MethodFormulaUse it when
Per orderunits sold x unit cost - (units back in stock or never shipped) x unit costyou want COGS for a day, a product or a month as it happens
Inventoryopening stock + purchases - closing stockyou close a year or check that the stock records hold
The two COGS formulas and when each one is the right tool.

Worked example: October 2026 at a small apparel store

The store sold 1.120 units in 740 orders, at a unit cost of €22,00: €24.640,00 of goods. During the month 110 units were refunded. 80 of them came back to stock, so their cost comes back too, €1.760,00. The other 30 were shipped and refunded without coming back, lost parcels and goodwill refunds, and their cost stays spent. COGS for the month is €24.640,00 minus €1.760,00, which is €22.880,00.

Against €60.000,00 of net revenue, sales after returns and without VAT, that is a COGS share of 38,1% and a gross profit of €37.120,00. The stockroom gives the same answer. The month opened with 2.400 units, €52.800,00 at cost; 1.200 units were bought for €26.400,00; the count at the end found 2.560 units, €56.320,00. €52.800,00 plus €26.400,00 minus €56.320,00 is €22.880,00.

StepPer orderInventory
Start€24.640,00 of units sold€52.800,00 opening stock
Add or take off- €1.760,00 of units back in stock+ €26.400,00 of purchases
Take off- €56.320,00 closing stock
COGS€22.880,00€22.880,00
October 2026, both ways.

What goes into the unit cost, and what does not

The unit cost is what one unit cost to get onto your shelf: the supplier's price, plus the inbound freight, the duty and the currency conversion that came with it. That figure is the landed cost, and on imported goods it can sit well above the invoice price. Using the invoice price instead understates COGS on every unit, by the same share, every month.

What does not belong in it is everything that happens after the unit leaves the shelf. Shipping to the customer, pick and pack, the box and its packaging fees are logistics. The payment provider's cut is a transaction cost. Ads are marketing. Each has its own line further down the statement, and folding any of them into COGS makes gross profit look smaller and the costs below it look cheaper than they are, which hides exactly the line that needs attention.

Which day a cost counts on

A unit's cost counts on the day it was sold, at the unit cost that applied on that day. A supplier price that rose in April prices April's sales at the new cost and leaves March at March's, so a closed month stays closed. That needs costs with dates, which a single cost field per product cannot hold, as historical COGS on Shopify sets out.

A refund counts on the day it was issued, and it gives the cost back only when the unit came back to stock or never shipped at all. A unit that was shipped and refunded without coming back, a goodwill refund, a lost parcel, a damaged return thrown away, keeps its cost, because the goods are gone. A chargeback takes the money back and returns nothing, so its goods keep their cost as well. The credit for a returned unit is valued at its original cost, not at today's, which is why when a refund credits COGS matters more than it sounds.

Where to find COGS in Shopify

Shopify keeps one Cost per item for each product and variant, entered in the Price section of the product page. Shopify's help page on cost per item says the cost is recorded on an order when the order is created, and that a new cost is not applied to orders created before the change (checked 15 Nov 2026). Shopify's profit reports then show gross profit by product, by variant and by POS location, the profit margin of each order and the average margin by market, and report profit only for items that had a cost recorded when they were sold.

So a product sold before its cost was entered drops out of the profit figures rather than showing a cost, and the report stops at gross profit: what Shopify's COGS report leaves out covers the rest. Anyone pulling COGS for a month from Shopify should check first that every product sold carried a cost on the day it sold.

What is a good COGS percentage?

There is no figure that fits every store, because what matters is what the rest has to pay for. COGS as a share of net revenue is good when the margin left after it still covers shipping, payment fees, marketing and running costs with room to spare. In the example month those took €28.233,35, 47,1% of net revenue, so the store breaks even at a COGS share of 52,9%. At its actual 38,1% it kept 14,8% as EBITDA. A store with cheaper parcels or a smaller ad budget can carry a higher COGS share; one that buys its customers expensively needs a lower one.

Sales minus COGS

Sales minus COGS is gross profit, and as a share of sales it is the gross margin. On a nouz P&L it is CM1, the first contribution margin: net revenue minus COGS, €37.120,00 in the example month, 61,9%. It is the right first question, whether the goods make money, and the wrong last one, because three more families of cost still come off below it. The monthly P&L template carries the whole month line by line, and the profit margin formula in Excel shows the same subtraction for one product, cell by cell.

In nouz, COGS is line 17 of the statement, and what COGS means on a Shopify P&L comes down to four rules: every unit is priced at the cost that applied on its order date, a refund gives the cost back only for units back in stock or never shipped, each cost is entered once per variant with the day it starts, and Shopify's Cost per item is the starting value where it exists. A variant with no cost is flagged by name rather than counted as free, so the margin never looks better than it is.

Questions

Questions, answered.

What is a good COGS percentage?
One that leaves enough after the goods to pay for shipping, payment fees, marketing and running costs. In the example month those took 47,1% of net revenue, so any COGS share above 52,9% meant a loss; at 38,1% the store kept 14,8%.
Where do I find COGS?
In Shopify, each product's cost sits in its Cost per item field, and the profit reports show gross profit for the items that had a cost when they sold. For a whole month, add up units sold times their unit cost and take off the units that came back to stock, or count stock at both ends of the month.
What is sales minus COGS?
Gross profit. Divided by sales it is the gross margin. In the example month net revenue of €60.000,00 minus COGS of €22.880,00 left €37.120,00 of gross profit, 61,9% of net revenue.
What is the calculation for the cost of goods sold?
Units sold times their unit cost, minus the cost of refunded units that came back to stock or never shipped. From the stockroom it is opening stock plus purchases minus closing stock. Both give the same figure when the stock records are right.
Is shipping part of COGS?
Inbound freight is: it is part of what a unit cost to get onto the shelf. Shipping an order to the customer is not; it is a logistics cost with its own line, together with pick and pack and packaging.

Run these numbers on your own store.

Install nouz in minutes from the Shopify App Store. It imports every order your store has ever taken and builds the full P&L from your own costs, every day. Cancel anytime.

Your trialToday
14 days of nouz, every feature$0
Card needed to startNone
Access to your storeRead-only
Due today$0