Costs

Weighted average cost vs FIFO in Shopify, step by step

Same three purchases, same two sales. FIFO gives $2,480.00 of cost of goods sold and a running weighted average gives $2,586.67. Every step is shown.

The Binly team11 min read
A neat row of identical cardboard boxes on the left and a tray of jumbled mixed boxes on the right, with a blank card between
In this article

With purchases at $10.00, $12.00 and $14.00 and two sales in between, FIFO reports $2,480.00 of cost of goods sold and a running weighted average reports $2,586.67. FIFO assumes the oldest units sold first. A weighted average blends old and new units into one cost. Both are ways to say what the units you sold cost you.

The difference is $106.67, and it comes from nothing but the method. Here is every step, so you can redo it with your own numbers.

The purchases and the sales#

One product, one supplier, no freight (landed cost is a separate topic, see our landed cost example). Say the store buys the same item three times and sells it twice, at $20.00 each.

Three purchases and two sales. The supplier price rises each time.
DayEventUnitsUnit cost or price
1Buy100$10.00
10Buy100$12.00
15Sell120$20.00
20Buy100$14.00
28Sell100$20.00

Totals first, because both methods must agree on them.

Units bought = 100 + 100 + 100 = 300
Money spent  = 1,000 + 1,200 + 1,400 = 3,600
Units sold   = 120 + 100 = 220
Units left   = 300 - 220 = 80
Revenue      = 220 x 20.00 = 4,400

Every method must split the $3,600.00 you spent into two parts: the cost of the 220 units sold, and the value of the 80 units still on the shelf. The methods differ only in where they draw that line.

FIFO, step by step#

FIFO stands for first in, first out. The IRS describes it in its Publication 538 as assuming that the items you bought first are the first ones you sold (IRS Publication 538, checked 15 Oct 2026). It does not claim your hands pick up the oldest box. It is a way of costing.

Keep a list of layers: each purchase, with how many units remain in it.

Day 1:  layer A = 100 units at 10.00 = 1,000.00
Day 10: layer B = 100 units at 12.00 = 1,200.00
        On hand: 200 units, 2,200.00
Day 15: sell 120. Take 100 from A and 20 from B.
        Cost = 100 x 10.00 + 20 x 12.00 = 1,000.00 + 240.00 = 1,240.00
        Left: layer B, 80 units at 12.00 = 960.00
Day 20: layer C = 100 units at 14.00 = 1,400.00
        On hand: 80 x 12.00 + 100 x 14.00 = 960.00 + 1,400.00 = 2,360.00
Day 28: sell 100. Take 80 from B and 20 from C.
        Cost = 80 x 12.00 + 20 x 14.00 = 960.00 + 280.00 = 1,240.00
        Left: layer C, 80 units at 14.00 = 1,120.00
FIFO cost of goods sold = 1,240.00 + 1,240.00 = 2,480.00
FIFO ending inventory   = 1,120.00
Check: 2,480.00 + 1,120.00 = 3,600.00

The 80 units left all come from the newest purchase, so they are valued at $14.00.

Weighted average, step by step#

A weighted average gives every unit on the shelf the same cost, the average of what was paid. Shopify's retail guide describes it as the average cost of your inventory per unit, and says it suits cases where tracking what each individual unit cost is too complicated (Shopify Retail: weighted average cost method, checked 15 Oct 2026).

There are two versions. The one below recalculates the average at each delivery, which is called a running or moving average. It is the version a cost field in an inventory system can hold, because it needs only one number per product at any moment. The whole-period version comes later.

Day 1:  100 units, value 1,000.00. Average = 1,000.00 / 100 = 10.00
Day 10: add 100 units at 12.00. Units = 200, value = 1,000.00 + 1,200.00 = 2,200.00
        Average = 2,200.00 / 200 = 11.00
Day 15: sell 120 at the average. Cost = 120 x 11.00 = 1,320.00
        Left: 80 units, value 2,200.00 - 1,320.00 = 880.00 (still 11.00 each)
Day 20: add 100 units at 14.00. Units = 180, value = 880.00 + 1,400.00 = 2,280.00
        Average = 2,280.00 / 180 = 12.6667
Day 28: sell 100 at the average. Cost = 100 x 12.6667 = 1,266.67
        Left: 80 units, value 2,280.00 - 1,266.67 = 1,013.33
Weighted average cost of goods sold = 1,320.00 + 1,266.67 = 2,586.67
Weighted average ending inventory   = 1,013.33
Check: 2,586.67 + 1,013.33 = 3,600.00

Notice what happened on day 20. The 80 old units were worth $880.00, the 100 new ones $1,400.00, and the blend landed at $12.67, between $11.00 and $14.00.

The rounding trap#

A cost field holds cents, so you cannot store 12.6667. Round the average to $12.67 and the sums drift.

Day 28: 100 x 12.67 = 1,267.00
Ending: 80 x 12.67 = 1,013.60
Total:  1,320.00 + 1,267.00 + 1,013.60 = 3,600.60

That is 60 cents more than you spent. It is small, and it repeats at every delivery. Any system that reads the stored cost back for the next blend carries the rounding forward. Keep the unrounded average in your own sheet and compare it with the stored value now and then.

The two answers side by side#

Gross profit is revenue of $4,400.00 minus cost of goods sold. Gross margin is gross profit divided by $4,400.00.
MethodCost of goods soldEnding inventoryGross profitGross margin
FIFO$2,480.00$1,120.00$1,920.0043.6%
Running weighted average$2,586.67$1,013.33$1,813.3341.2%

Same stock, same sales, same cash spent. FIFO shows $106.67 more profit and $106.67 more stock on the shelf. That is the same $106.67 seen from two sides, and it is why the choice matters at year end: ending inventory goes on your balance sheet, and cost of goods sold goes against your income.

The IRS notes that when prices rise, LIFO (last in, first out) gives a larger cost of goods sold than FIFO. We leave LIFO out here. Our own numbers show the same pull: costs rose from $10.00 to $14.00, so FIFO keeps the newest and dearest units in stock, while an average spreads their price over the units already sold.

Now run it the other way. Say the three costs were $14.00, $12.00 and $10.00 instead, with the same sales.

Costs fall instead of rise. FIFO now reports the higher cost of goods sold.
MethodCost of goods soldEnding inventory
FIFO$2,800.00$800.00
Running weighted average$2,693.33$906.67

When costs rise, FIFO reports more profit. When they fall, it reports less. If your supplier prices barely move, the two methods stay close and the argument is not worth much of your time.

A third answer: one average for the whole period#

Some accountants average the whole period at once instead of at each delivery.

Average = 3,600.00 / 300 = 12.00
Cost of goods sold = 220 x 12.00 = 2,640.00
Ending inventory   = 80 x 12.00 = 960.00

That makes three answers for cost of goods sold: $2,480.00, $2,586.67 and $2,640.00. The running version moves with each delivery, so a sale on day 15 uses only the stock bought by day 15, while the whole-period version uses a delivery that had not yet arrived. Ask which one your accountant uses before you copy any formula from a website, including ours.

What Shopify's Cost per item field can hold#

Shopify's cost field holds one number per variant. Its help center says the field is static, so profit reports reflect cost at a point in time, and that profit is reported only for variants with a cost recorded when they sold (Shopify help: profit reports, checked 15 Oct 2026). It cannot hold a list of layers. That rules out true FIFO inside the field. A running average fits, because it is one number.

A common mistake is a third method that looks like neither. The team types the newest purchase cost into the field at every delivery and calls it FIFO. Run our example that way:

Day 15 sale: cost field shows 12.00 (set on day 10). Cost = 120 x 12.00 = 1,440.00
Day 28 sale: cost field shows 14.00 (set on day 20). Cost = 100 x 14.00 = 1,400.00
Total = 1,440.00 + 1,400.00 = 2,840.00

That is $2,840.00 of cost of goods sold, $360.00 above FIFO. The field still shows $14.00 at the end, so ending stock is valued at 80 x 14.00 = $1,120.00. Add them: $2,840.00 + $1,120.00 = $3,960.00, against $3,600.00 actually spent. The books do not close. Using the newest cost is a shortcut, not a method, and it overstates cost whenever prices are rising.

Which method to use, and who decides#

Your accountant and your tax rules decide. Methods that are allowed, and the paperwork to change them, differ by country and business type. In the US, for example, the IRS says a business that wants to change its inventory method must file Form 3115. We cannot advise you on yours.

Within the options you are allowed, our view is practical. If you keep this by hand, a running average is far less work than FIFO, which needs a layer list for every product. If your goods are dated, perishable or batch-tracked, FIFO matches how they really move and the extra work pays. If your costs hardly move, either is fine.

Pick one before the year starts, apply it to every product and keep it. Switching because one looks better this month is the surest way to produce numbers nobody trusts.

Keeping the cost field honest#

Whatever you choose, three habits keep the field close to the truth.

Book deliveries the day they arrive (our page on receiving purchase orders shows the step). A running average uses the units on hand at the moment you book, so a late booking blends against too few units and the result drifts.

Record freight and duty before you set the cost, or the field holds a price that is too low.

Keep a dated note of the method and any change. If an accountant asks why last year's numbers differ from this year's, the note is the answer.

Frequently asked questions#

Does Shopify use FIFO or weighted average cost?

Neither by itself. Shopify's Cost per item field holds one value per variant, and its profit reports use the cost recorded at the time of sale. Whatever number you or an app keep in that field is the cost Shopify uses. If you want FIFO or an average, something outside the field has to calculate it and write it in.

How do I calculate weighted average cost?

Add the value of the units on hand to the value of the units you just bought, then divide by the total units. With 80 units at $11.00 and 100 units at $14.00, that is (80 x 11.00 + 100 x 14.00) / 180 = $12.67 after rounding. Recalculate at each delivery.

Which method gives a higher profit?

When your costs are rising, FIFO reports the lower cost of goods sold and so the higher profit. When costs are falling, it is the other way round. In our example, with costs of $10, $12 and $14, FIFO shows $1,920.00 of gross profit and a weighted average shows $1,813.33.

Can I switch from one method to another?

That is a question for your accountant, because tax authorities can require approval or paperwork. The IRS, for example, says a US business that wants to change its inventory method must file Form 3115. Choose one method before the year starts and keep it.