COGS & Accounting

FIFO vs LIFO vs Weighted Average Cost on Shopify: Worked Examples

FIFO vs LIFO for ecommerce, worked through with numbers. One mug, three purchase lots, three months of sales, and the COGS, ending inventory and gross margin each method gives you on Shopify.

GrowStack team11 November 202611 min read
costing methodsfifo vs lifoweighted average costcogsinventoryshopify

Say you run a small ceramics shop, and your bestseller is a $24 mug. Your supplier put the price up twice this quarter, from $8.00 to $9.00 to $10.50 a mug, and you sold 290 of them.

So what did those 290 mugs cost you? $2,570, $2,602.35 or $2,665. All three answers are correct.

Which one your books show depends on your costing method, and this quarter that choice moves gross profit by $95 on a single product. Let's run the numbers all three ways.

The short answer

FIFO, LIFO and weighted average cost (WAC) are three ways to decide what each unit you sell cost you, when you bought the same product at different prices.

  • FIFO (first in, first out) costs each sale at your oldest purchase price first.
  • LIFO (last in, first out) costs each sale at your newest purchase price first.
  • Weighted average costs each sale at the average price of everything on the shelf.

Whichever method you pick, you spent the same cash on stock. The method decides how that spend is split between cost of goods sold (COGS) this month and the inventory still on your shelf. That split moves your reported gross margin, and sometimes your tax bill.

The rest of this post runs the mug shop through all three methods, sale by sale.

The worked example

The mug sells for $24.00. Over one quarter you buy three lots from your supplier, and the price goes up each time.

Purchase lots

LotDate receivedUnitsUnit costLot total
A01/01/2026100$8.00$800.00
B01/02/2026150$9.00$1,350.00
C01/03/2026100$10.50$1,050.00
Total350$3,200.00

Sales

PeriodUnits sold
January80
February120
March90
Total290

Each month's lot arrives on the first of the month, before that month's sales. Revenue is 290 × $24.00 = $6,960.00, and you end the quarter with 60 mugs in stock.

Every method below starts from these same lots and sales. We cost each month's sales as they happen, the way an inventory app would.

FIFO: oldest cost first

FIFO uses up Lot A before it touches Lot B, and Lot B before Lot C.

SalesUnits taken fromCost
January (80)80 from A at $8.00$640.00
February (120)20 from A at $8.00, 100 from B at $9.00$1,060.00
March (90)50 from B at $9.00, 40 from C at $10.50$870.00
COGS$2,570.00

Ending inventory: 60 units, all from Lot C at $10.50 = $630.00.

Check: $2,570.00 + $630.00 = $3,200.00, which is everything you bought.

LIFO: newest cost first

LIFO takes from the most recent lot on hand at the moment of each sale.

SalesUnits taken fromCost
January (80)80 from A at $8.00 (the only lot so far)$640.00
February (120)120 from B at $9.00$1,080.00
March (90)90 from C at $10.50$945.00
COGS$2,665.00

Ending inventory: 20 from A at $8.00, 30 from B at $9.00 and 10 from C at $10.50 = $535.00.

Check: $2,665.00 + $535.00 = $3,200.00.

LIFO is often worked out once at year end for tax, instead of sale by sale. If you did that here, all 290 sales would come from the newest lots first, and COGS would be $2,720.00. Same direction, wider gap.

Weighted average: blend the cost on every delivery

Weighted average cost recalculates one unit cost each time stock arrives:

New average = (units on hand × current average + units received × their cost) ÷ (units on hand + units received)

StepUnits on handAverage unit costCost of sales
Receive A100$8.00
Sell 80 in January20$8.00$640.00
Receive B: (20 × $8.00 + 150 × $9.00) ÷ 170170$8.8824
Sell 120 in February50$8.8824$1,065.88
Receive C: (50 × $8.8824 + 100 × $10.50) ÷ 150150$9.9608
Sell 90 in March60$9.9608$896.47
COGS$2,602.35

Ending inventory: 60 × $9.9608 = $597.65.

We worked these figures at full precision and show the average to four decimal places. Multiply by the rounded $8.8824 and you get $1,065.89 for February and $2,602.36 in total, a cent out. Round to cents at every step and those small errors pile up over a year of deliveries, so keep as much precision as your spreadsheet allows.

Side by side

FIFOWeighted averageLIFO
Revenue$6,960.00$6,960.00$6,960.00
COGS$2,570.00$2,602.35$2,665.00
Gross profit$4,390.00$4,357.65$4,295.00
Gross margin63.1%62.6%61.7%
Ending inventory$630.00$597.65$535.00

Same mugs, same sales, same cash out of the bank. FIFO reports $95 more gross profit than LIFO for the quarter. On one product, that's small. Across a few hundred products and a full year of price rises, it adds up fast.

Notice where the "missing" $95 went. Under FIFO it sits in ending inventory, valued at the newest price. Under LIFO it was expensed this quarter, and the shelf is valued at older, cheaper prices.

What happens when supplier prices fall

Now flip the lots. Lot A costs $10.50, Lot B $9.00 and Lot C $8.00. The units and sales stay the same.

FIFOWeighted averageLIFO
COGS$2,720.00$2,696.47$2,640.00
Gross profit$4,240.00$4,263.53$4,320.00
Gross margin60.9%61.3%62.1%
Ending inventory$480.00$503.53$560.00

The order reverses. When costs fall, FIFO gives the highest COGS and the lowest margin, and LIFO gives the lowest COGS.

So the rule of thumb:

  • When costs rise, FIFO shows higher profit and LIFO shows lower profit.
  • When costs fall, it flips: FIFO shows lower profit and LIFO shows higher profit.
  • Weighted average lands between the two when prices move steadily in one direction, as they do here, and it moves more slowly. If prices jump up and down, it can land outside that range.

None of this changes your real cash profit over the life of the stock. Once every mug is sold, all three methods have expensed the same $3,200. The method only decides which period the cost lands in.

When to use each method

Your accountant gets the final say on the method in your books. Here's how we think about the choice for a Shopify store.

Weighted average

Our default suggestion for most stores that sell interchangeable stock, like apparel in a given size and color, packaged goods or accessories.

  • It needs one running number per variant, not a list of lots.
  • It smooths out a one-off price spike from a single expensive shipment.
  • It's what Stocky, Shopify's retired inventory app, used, so lots of merchants already think in average cost.

FIFO

FIFO fits stock that goes out in date order: food, cosmetics, supplements, anything with a best-before date.

  • It usually matches how you physically pick stock.
  • Your ending inventory sits close to what it would cost to replace today.
  • It needs lot-level records: which units arrived when, and at what cost.

LIFO

LIFO is mostly a US tax decision rather than an operations one. Read the next section before you consider it.

  • When costs are rising, it reports lower profit, which can mean lower US taxable income.
  • It rarely matches how stock physically moves.
  • It comes with extra rules and record-keeping.

LIFO is mainly a US option

The international accounting rules, IFRS (International Financial Reporting Standards), don't allow LIFO. Their inventory standard, IAS 2, permits only FIFO or weighted average for interchangeable stock. The IAS Plus summary of IAS 2 covers it in plain terms. Some national rules outside IFRS do allow LIFO, so check which rules your books follow.

In the US, LIFO is allowed, but it's a formal choice. A business elects it with the IRS on Form 970, filed with the tax return for the first year it uses LIFO.

It also comes with a catch called the conformity rule. If you use LIFO on your US tax return, you generally have to use it in the financial statements you give owners and lenders too, with a few exceptions such as internal management reports. In practice, you can't easily report LIFO to the IRS and FIFO to your bank. The IRS walks through the rule in a LIFO conformity training document.

Switching methods later is a formal change with the IRS too.

This section is general information, not tax or accounting advice. The rules have exceptions and depend on your business, where you're based and how you report. Talk to an accountant before you choose or change a method.

Why Shopify's cost per item can't do this on its own

Shopify gives each product variant a single cost per item field. Shopify's own Help Center says this cost stays fixed when you receive a purchase order or transfer. It doesn't average, and it doesn't track lots. See Shopify's Stocky migration guide, under "Track inventory costs and reconcile received stock".

For the mug shop, that plays out three ways:

  1. Weighted average is out. If you set the mug to $8.00 in January and never touch it, every sale in the quarter is costed at $8.00. Shopify would show COGS of $2,320.00 and a 66.7% margin, against 61.7% to 63.1% under the three methods.
  2. So are FIFO and LIFO. One number can't remember that 20 units cost $8.00 and 30 cost $9.00. Lot methods need a record of each delivery, and the field doesn't hold one.
  3. The product keeps no cost history. If you type in $10.50 when Lot C arrives, every later sale is costed at $10.50, including the cheaper units still on the shelf. Shopify records the cost on each order when the order is created, so past orders keep their earlier cost (Shopify Help Center: cost per item). But the product keeps no log of what it cost on a given date, so you can't look one up later or recost past sales if a cost was wrong.

You can keep a weighted average by hand. Recalculate it in a spreadsheet after each delivery, then paste the new number into cost per item. That works for a handful of products. FIFO and LIFO by hand mean a lot ledger for every variant and working out which lot each sale came from. Few stores keep that up for long, and we don't blame them.

What to do now

  1. Pick one method and use it for every product, every period. Write down which one and why, because your accountant will ask.
  2. Record every delivery with its date, units and landed cost (product cost plus freight and duty).
  3. If you use weighted average in a spreadsheet, recalculate after every delivery, not once a month.
  4. Keep a dated copy of your costs before you change them in Shopify.
  5. Each quarter, check your COGS against your supplier invoices.

Your costing method is a choice, and it shows up in every margin you report. Make it on purpose.

That lot ledger is the job we're building CostSync to take over. It tracks your product costs over time and works out COGS and margin with weighted average, FIFO or LIFO. CostSync is coming soon, and you can join the waitlist from the CostSync page. The CostSync plans page lists what each plan includes.

Related articles