skills/catalog-inventory/cogs-tracking-allocation/SKILL.md
Track cost of goods sold and landed costs using your platform's built-in tools or accounting integrations to compute accurate gross margin per order
npx skillsauth add finsilabs/awesome-ecommerce-skills cogs-tracking-allocationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Tracking Cost of Goods Sold (COGS) tells you the actual gross margin on every order — revenue minus what you paid for the products you sold. Most platforms let you enter a cost price per product, and accounting integrations (QuickBooks, Xero) use that to generate COGS entries automatically. Landed cost allocation (freight, customs, duties) requires either a dedicated app or manual allocation in your accounting software. Only build a custom COGS system if your platform cannot meet your costing method requirements (FIFO, weighted average).
| Platform | Recommended Approach | Why | |----------|---------------------|-----| | Shopify | Enter cost per variant in Admin; use Shopify Analytics or connect QuickBooks/Xero for COGS reporting | Shopify stores cost price per variant; profit reports use this for margin calculation | | WooCommerce | Enter purchase price per product; connect WooCommerce Bookings + accounting plugin or Metorik for margin reports | WooCommerce stores cost price natively; Metorik provides profit analytics | | BigCommerce | Purchase cost field per product; connect to QuickBooks via built-in integration | BigCommerce has a cost price field; the QuickBooks integration auto-posts COGS | | Custom / Headless | Build a cost ledger with FIFO/weighted-avg logic and accounting journal entries | Required when none of the above integrations meet your costing method or reporting needs |
Before any COGS reporting is possible, every product variant needs a cost price.
For bulk cost updates: use Matrixify (App Store) to import a CSV with cost per SKU — the column is Variant Cost.
Popular COGS plugins for WooCommerce:
The cost price field alone only enables reporting inside the platform. For your P&L and balance sheet, connect an accounting integration that posts COGS when orders are fulfilled.
A2X is strongly recommended for Shopify + Xero — it handles currency conversion, refunds, fees, and COGS automatically.
Landed costs (freight, insurance, customs, duties) must be added to the product cost before the first sale to get accurate COGS.
For most merchants (manual method):
(Product value / Total shipment value) × Total landed cost ÷ Units receivedFor Shopify merchants with frequent imports:
For accounting software users:
Once cost prices are entered and accounting is connected:
For headless storefronts needing perpetual inventory costing with FIFO, build a cost ledger:
// Cost layer model — one row per purchase order receipt
interface InventoryCostLayer {
variantId: string;
receiptDate: Date;
quantityReceived: number;
quantityRemaining: number; // Decrements as units are sold
unitCostCents: number; // Purchase price per unit
landedCostCents: number; // Allocated freight/duties per unit
}
// FIFO cost assignment when an order is fulfilled
async function assignCogsFifo(variantId: string, locationId: string, quantity: number, orderId: string) {
let remaining = quantity;
let totalCostCents = 0;
return db.transaction(async tx => {
// Consume oldest cost layers first (FIFO)
const layers = await tx.inventoryCostLayers.findAll({
where: { variantId, locationId, quantityRemaining: { gt: 0 } },
orderBy: { receiptDate: 'asc' },
});
for (const layer of layers) {
if (remaining <= 0) break;
const units = Math.min(remaining, layer.quantityRemaining);
const totalUnitCost = layer.unitCostCents + layer.landedCostCents;
await tx.inventoryCostLayers.update(layer.id, {
quantityRemaining: layer.quantityRemaining - units,
});
await tx.cogsEntries.create({
orderId, variantId, quantity: units,
unitCostCents: totalUnitCost,
costingMethod: 'fifo',
});
totalCostCents += units * totalUnitCost;
remaining -= units;
}
if (remaining > 0) throw new Error(`Insufficient cost layers for ${variantId}`);
return { totalCostCents };
});
}
// Allocate landed costs to a received shipment (by value)
async function allocateLandedCostsByValue(shipmentId: string, totalLandedCostCents: number) {
const layers = await db.inventoryCostLayers.findByShipment(shipmentId);
const totalValue = layers.reduce((s, l) => s + l.unitCostCents * l.quantityReceived, 0);
for (const layer of layers) {
const share = (layer.unitCostCents * layer.quantityReceived) / totalValue;
const perUnitLanded = Math.round((share * totalLandedCostCents) / layer.quantityReceived);
await db.inventoryCostLayers.update(layer.id, { landedCostCents: perUnitLanded });
}
}
| Problem | Solution | |---------|----------| | Gross margin reports show 100% for some products | Cost price is missing for those variants; Shopify and WooCommerce silently treat missing cost as $0 | | COGS in QuickBooks doesn't match the platform's profit report | The accounting integration may be using a different COGS account or ignoring refunds; check the integration mapping settings | | Landed costs not reflected in COGS | Landed costs must be entered before the first sale; entering them after requires adjusting the cost layer manually in your accounting software | | Cost price includes VAT but shouldn't | Enter the ex-VAT cost price; tax is a separate line in your P&L, not part of COGS | | Weighted average cost goes stale | Recalculate weighted average dynamically from current inventory layers — never cache it as a static field |
tools
Let shoppers save products to a wishlist, share it with friends, and get notified when saved items come back in stock or drop in price
development
Build a themeable storefront with design tokens and CSS custom properties that supports white-labeling, multi-brand variants, and dark mode
development
Speed up product discovery with instant search suggestions, fuzzy typo matching, and category-aware results powered by Algolia or Elasticsearch
development
Build a mobile-first storefront with thumb-friendly navigation, sticky add-to-cart buttons, and touch-optimized components for high mobile conversion