Guides · 15 October 2026
How to calculate cost of goods sold (COGS) for a Shopify store
Cost of goods sold (COGS) is what the products you actually sold cost you. It’s the number that turns your sales into real profit, and it’s the one most often understated, because freight, duty and fees get left out.
The formula
COGS = opening inventory + purchases during the period − closing inventory
All three numbers must be at landed cost: the supplier’s price plus freight, duty, brokerage and other charges to get stock to you. See how to calculate landed cost.
Worked example: one month, in USD
| Line | Amount |
|---|---|
| Opening inventory (value of stock at the start of the month) | $20,000 |
| + Purchases received during the month (landed cost) | $12,000 |
| − Closing inventory (value of stock at the end of the month) | $18,500 |
| = COGS | $13,500 |
If the month’s sales were $30,000:
| Line | Amount |
|---|---|
| Sales | $30,000 |
| − COGS | $13,500 |
| = Gross profit | $16,500 |
| Gross margin | 55% |
Gross profit is before payment fees, shipping to customers, returns, advertising and overheads, so it is not your take-home profit. It’s the starting point.
What happens if you leave freight and duty out
Suppose $1,800 of that month’s $12,000 purchases was freight, duty and brokerage, and you only counted the supplier invoices ($10,200):
| With landed cost | Supplier invoices only | |
|---|---|---|
| COGS | $13,500 | $11,700 |
| Gross profit | $16,500 | $18,300 |
| Gross margin | 55.0% | 61.0% |
The same month, six points of margin that don’t exist. Pricing and discount decisions made on the higher number will be too generous.
Per-product cost: how to value stock
You need a cost per unit to value inventory. The usual method for small retailers is a weighted average: each time new stock arrives, blend it with what you hold.
(units on hand × current cost + units received × landed cost) ÷ total units
For example, 40 units at $14.00 plus 100 units received at $15.86 gives (40 × $14.00 + 100 × $15.86) ÷ 140 = $15.33 per unit.
Practical tips
- Count stock at the end of every period, not just at year end. A monthly count makes COGS reliable.
- Record shipments as they arrive, with every invoice that belongs to them, even ones that arrive weeks later.
- Keep a history of cost changes so you can explain a shift in margin.
- Ask your accountant which inventory method and rules apply where you operate. Tax rules differ by country.
Make it automatic
- Landrio records each shipment’s freight, duty and fees, keeps Cost per item up to date in Shopify with a weighted average, and gives your accountant monthly reports and stock valuations.
- Try the numbers first in the free landed cost calculator.