COGS Calculator

Work out cost of goods sold for a period from beginning inventory, purchases, freight in and ending inventory, set up for online stores.

Describe the result you need. AI will set up the tool and ask for any missing details.

Configure with AI

Enter to submit · Shift + Enter for a new line

Sent to AI. Leave out passwords and private customer data.

Your numbers

Inventory
$
$
Purchases
$

Inbound shipping and import duty belong in cost of goods, not operating expenses.

$
$
Revenue (optional)

Add this to also see gross profit and gross margin.

$

Your result · updates as you type

Cost of goods sold

$93,400

Beginning inventory plus purchases (with freight in, minus returns) leaves $125,400 of goods available. Subtracting ending inventory of $32,000 gives $93,400 of cost of goods sold.

Goods available for sale
$125,400

On Shopify, set Cost per item on each product so your reports match this figure. In WooCommerce, turn on the core cost feature at WooCommerce → Settings → Advanced → Features → Cost of Goods Sold, which adds a cost field to each product's General tab.

Breakdown

Beginning inventory
$28,000
Purchases
$95,000
Freight and duty in
$4,200
Purchase returns and allowances
−$1,800
Goods available for sale
$125,400
Ending inventory
−$32,000
Cost of goods sold
$93,400

The COGS formula

Cost of goods sold = beginning inventory + purchases + freight in − purchase returns and allowances − ending inventory

Example: the default numbers

Beginning inventory + purchases + freight in
$28,000 + $95,000 + $4,200 = $127,200
Less purchase returns and allowances
− $1,800 = $125,400 goods available
Less ending inventory
− $32,000

Cost of goods sold = $93,400 for the period.

Freight and duty to bring inventory in belong here, in cost of goods, not in your operating expenses. Leaving them out understates COGS and overstates gross margin.

Tracking cost per item in your store

  1. 01

    Shopify

    Set Cost per item on each product's pricing details, so Shopify's reports track cost and profit alongside sales.

  2. 02

    WooCommerce

    Turn on the core cost feature at WooCommerce → Settings → Advanced → Features → Cost of Goods Sold, which adds a cost field to each product's General tab.

  3. 03

    Matching this calculator

    This calculator works at the period level (beginning/ending inventory and purchases), which matches how your accountant or P&L reports COGS, rather than per unit.

Questions people ask

What is cost of goods sold?

The direct cost of the inventory you actually sold in a period: what you started with, plus what you bought (including inbound freight and duty), minus what you ended with.

Should shipping to my customers be included in COGS?

No, only freight and duty to bring inventory in. Outbound shipping to customers is usually a separate cost, not part of COGS.

Why does ending inventory reduce COGS?

Because it wasn't sold. Goods available for sale includes everything you had access to; subtracting what's left over isolates what actually left as sales.

How is this different from gross margin?

COGS is a cost figure. Gross margin is revenue minus COGS, as a dollar amount or a percentage of revenue. Enter your revenue here to see both.

Want this builtinto your store?

I'm Emmanuel, a Shopify and WooCommerce developer. If this tool pointed at something you'd rather have fixed for you (a faster store, cleaner product data, a migration, a custom feature), send me a note.

Emmanuel Asika

Emmanuel Asika

Shopify & WooCommerce developer, Dublin

I build and fix online stores: new builds, migrations, speed, SEO and the custom bits apps can't do.

hello@emmanuelasika.com

Last reviewed 30 September 2026.

Sources: WooCommerce docs: Cost of Goods Sold (COGS)