Reliable COGS (Cost of Goods Sold) Calculations for Shopify Stores
Explore efficient ways to calculate COGS in Shopify ecommerce and understand why accurate costing is essential for identifying true business profitability.
Cost of Goods Sold (COGS) is a key metric in the e-commerce industry and plays a significant role in determining the profitability of an online store.
In short, COGS is the direct cost incurred by a store to sell its products. And it’s not just the cost of the product itself, but also the material, production, and labor expenses associated with those products you’re selling.
To help online merchants navigate through this tough territory, we’ll first look at the different costs involved in calculating COGS, and then the formula which is the most appropriate for ecommerce stores.
COGS Formula for Ecommerce Resellers
Typical online retailers (aka “resellers”) who rely on multiple wholesale suppliers for their products can calculate COGS using the formula below. It can be used to determine the cost per unit of all merchandise purchased from wholesale suppliers.
But first, we need to look at the different costs associated with determining COGS:
Product cost -The cost to purchase products from your supplier.
Freight in - The cost to have the purchased items delivered to your location.
Maintenance - The cost associated with assembling, storing and maintaining products until they’re sold.
And any other costs involved in getting your products to the warehouse. Now let’s look at how to calculate COGS using the above.
COGS = Product Cost + Shipping Cost (Freight in) + Maintenance
Here’s an example:
Imagine you start selling branded tennis shoes, and you source your products directly from Nike.
The wholesale product cost to purchase each pair of Nike shoes is $25.
The shipping cost for each unit is $5.
The maintenance cost for each unit is $10.
That brings the total cost of the good to $40.
Now if you retail this product at $100 and 150 units get sold in a month, then the total revenue is $15,000.
The total cost of goods sold for 150 units is $6,000.
With revenue and COGS calculated, you can now find the gross profit earned.
Gross Profit = Net Revenue - Cost of goods sold
Gross Profit = $15,000 - $6,000 = $9,000.
You can also calculate your gross margin with these numbers,
Gross Margin = ((Revenue - Cost of Goods Sold) / Revenue) X 100
Gross Margin = (($15,000 - $6,000) / $15,000) X 100 = 60%
That’s how you can calculate COGS and your gross margin using the above formulas.
Formula to Calculate COGS for D2C Shopify Sellers
This is a standard COGS formula used by most D2C merchants and manufacturers:
Cost Of Goods Sold (COGS) = (Beginning Inventory + Purchases) - Ending Inventory
Here, beginning Inventory refers to existing in-hand inventory at the start of the month.
Purchases refers to any new inventory bought or manufactured during the month.
Ending Inventory refers to remaining inventory after product sales in the month.
Let’s consider a quick example.
Imagine you’re a leather bag manufacturer, and you had 100 units of inventory at the beginning of the month. Each unit costs you $60 to manufacture, and you sell them for $200 each.
During the middle of the month, you manufactured a new batch of 40 products.
At the end of the month, you sold a total of 80 products. So that’ll leave you with 60 products as ending inventory.
Now let’s analyze our final COGS based on the above illustration.
COGS = Beginning Inventory + Additional Purchases - Ending Inventory.
Beginning Inventory: 100 units X $60 = $6,000
+ Additional Purchases: 40 Units X $60 = $2,400
- Ending Inventory: 60 Units X $60 = $3,600
COGS = $6,000 + $2,400 - $3,600 = $4,800.
If your retail selling price for each leather bag is $200, then total monthly revenue (80 units sold) is $16,000.
Now we can find gross profit and gross margin.
Gross profit = $16,000 (total revenue) - $4,800 (COGS) = $11,200
Gross Margin = (($16,000 - $4,800) / $16,000) X 100 = 70%
And that’s how you calculate your COGS and gross profit using the ideal formula for D2C merchants!
How to Calculate Cost of Good Sold (COGS) using FIFO and LIFO Accounting Methods?
Both FIFO and LIFO are cost accounting methods that can lead to very different numbers when calculating COGS and gross profit.

The First in First Out ( FIFO) accounting method assumes that the oldest products in your inventory were sold first; whereas Last in First Out (LIFO) assumes that the latest units were sold first.
It's understood that as a business owner, the upward trajectory of your sales chart is more important to you than which SKU is sold first, unless you're selling perishable or fast moving food products. Nevertheless, by accurate analysis of your stock depletion, you can make necessary buying decisions when purchasing inventory. That’s where you’d need the help of one of these accounting methods.
Assume that Baby Toys Inc. is building its inventory during the first quarter of the year.
In January, they purchased 100 units at $5 per unit. During February, they bought 200 units at $6 per unit. For March, another 100 units were purchased at $7 per unit.

For both FIFO and LIFO, the total purchases made is 400 units at an average of $6 per unit. This results in $2,400 inventory costs for the first quarter.
However, in April Baby Toys Inc. sold 50 units. For inventory valuation as well as determining cost of goods sold, it’s important to understand the cost per unit for those 50 units sold in April.
Remember: It’s always critical to utilize the same number of units for COGS as you’ve indicated for revenue.
Always use the the same number of units when calculating COGS and revenue
Let’s look at how it is calculated.
FIFO (First In First Out)
With FIFO, we assume that the oldest inventory gets sold first. For our above example, this means the first toy inventory sold is based on Baby Toys Inc’s January purchase.
Revenue in April: 50 units x $10 (retail price) = $500
COGS (assumed from January Inventory): 50 units x $5 = $250
Inventory remaining at the end of April from the January purchase is 50 units. The inventory from February and March purchases remain in full.
So Total FIFO Ending Inventory: 350 x $6.14 (weighted average unit) = $2100
An increase of the weighted average unit cost from $6 previously.
If we prepare the income statement for April, revenue is 50 units x $10 = $500, Cost of Goods Sold (COGS) is 50 units x $5 = $250, and Gross Profit is $250.
LIFO (Last In First Out)
With LIFO, we assume that the newest inventory gets sold first. In other words, Baby Toys Inc. depletes units based on its most recent March purchase activity..
So Revenue = 50 units x $10 = $500
COGS = 50 units x $7 (March purchase price) = $350
This leaves Baby Toys Inc with a Gross Profit of $150.
The total inventory remaining at the end of April are the entire 100 units from the January purchase, all200 units from the February purchase, and the balance of 50 units from the March purchase.
To summarize: 350 units at a total purchase of $2,050, averaging $5.86 cost per unit.
When we apply the Cost Of Goods Sold formula alongside FIFO and LIFO:

Using COGS to Calculate Gross and Net Profit
Phew! We made it to the other side of all those equations. For those of you who don’t have a background in accounting, that probably felt like drinking from a firehouse.
If you do not fully understand each calculation method, go back and read very slowly. Even better, try to plug in some of your own numbers so the concepts really sink in.
Once you have COGS, you can unlock a whole host of other insightful metrics such as gross and net profit.
Simply plug your data into these formulas:
Gross profit = Net Revenue - COGS
Net profit = Gross Profit - (Fulfillment Cost + Ad Spend + Operating Expenses)
The ultimate goal of calculating and consistently tracking COGS, even when it fluctuates, is to understand the true profitability of your business. Since COGS sits at the top of the financial funnel when deriving net profit, maintaining accuracy becomes very important.
Conclusion
Although calculating COGS may seem simple at first, it often changes because of the many factors involved in manufacturing, sourcing, and procurement. This makes the process demanding, and failing to track it correctly can become expensive. When COGS is not accurate, many things can go wrong, such as:
• Setting the wrong product price
• Getting incorrect profit margins
• Overspending on other operations like marketing, fulfillment, and logistics
Accurate COGS tracking is more than a financial task. It is the foundation for better pricing, stronger margins, and long term business growth.
Now, go ahead and calculate your COGS with confidence. Congratulations on taking the step toward profitable selling.







