MarginLine

Sample shop, real formula.

These rows are what the embedded Shopify admin shows in a Polaris table. The numbers come from the same profit module, not a mockup. Card fee is 2.9% + $0.30. Shipping cost is a flat $6.50 on orders that had something to ship.

ProductSKUUnits soldNet salesRefundsCOGSPayment feesShipping costNet profitMarginFlags
Sticker sheetSTKR-SET4$32.00$0.00—$1.23$0.00——Cost missing
Wool blanket · GreyBLKT-GRY1$38.00$0.00$39.00$1.40$2.16-$4.56-12.0% Losing money
Canvas tote · NaturalTOTE-NAT2$66.00$22.00$15.00$1.84$6.50$20.6647.0% Profitable
Ceramic mug · WhiteMUG-WHT3$54.00$0.00$15.00$2.36$10.84$25.8047.8% Profitable

Orders behind the table

#1042 · 2 Mar

Two white mugs at $18 with a $4.50 cost, and one grey blanket at $42 with a $4 discount and a $39 cost. Shipping charged $9.

#1048 · 5 Mar

Three natural totes at $24, with $6 of discounts. One was refunded and restocked ($22). Cost was $7.50. Shipping charged $9.

#1051 · 6 Mar

Four sticker sheets at $8. No unit cost was on the inventory item. Nothing to ship.

#1055 · 8 Mar

The supplier raised the mug cost to $6. This order keeps $6. The March 2 mugs stay at $4.50. Shipping charged $8.

#1030 · voided

A voided checkout. It is stored and ignored.

#1060 · EUR

A presentment-currency order. Shop-currency reporting skips it instead of converting.

How a row is calculated

Units sold are units still on the order after refunds and edits. A voided or expired order is ignored.

Net sales are the unit price times the quantity that stayed on the order, minus discounts allocated to the line, including order discounts. Refunds are not folded into this number.

Refunds are the money returned on that line, before tax. A partial refund reduces units sold and this column, not the original price.

COGS is the unit cost captured when the order was imported, times units that did not come back into inventory. A later supplier cost change does not rewrite that snapshot. Returned units that were restocked drop out of COGS. Refunds marked not restocked still carry the cost. A missing cost hides profit instead of counting as zero. An explicit zero cost is a real cost.

Payment fees start with your shop rule: your percent of the order total still collected, including tax and shipping, plus the fixed fee once per order that collected money. A variant fee per unit replaces that line’s share. If the variant has none, a product fee per unit is used. Lines with an override are left out of the shop fee pool. What remains of the shop fee, after those per-unit amounts, is split by kept product revenue across lines that still use the shop rule. If every line has an override and those amounts are smaller than the shop fee, the difference is not forced onto a product. If the overrides are larger, they are kept and the other lines are not charged a fee. Gift cards are not rows.

Shipping cost starts with your shop rule: a flat amount on each order that had something to ship, or a percent of shipping still charged after shipping refunds. A variant shipping cost per unit replaces that line. If the variant has none, a product shipping cost per unit is used. Override lines are left out of the shop shipping pool, and the full shop amount is split only across shippable lines that still use the shop rule. If every shippable line has an override, the shop flat or percent is not added on top. If every shippable unit was refunded and the lines still use the shop rule, the flat amount stays.

Net profit is net sales minus refunds, COGS, payment fees, and shipping cost. Margin is net profit divided by net sales minus refunds. Margin is blank when that revenue is zero or a cost is missing.

Amounts are shop currency only. A presentment currency such as the customer’s checkout currency is not converted.

Product type and vendor filters hide other rows after fees and shipping have already been split across the order. Totals add up the rows still on screen. A missing cost stays blank.

Ad spend is off until you turn it on. Shop-wide spend in the date range is split by kept product revenue. Spend tied to a variant, product, or SKU is added only to those rows. Spend with no matching product is unallocated and does not create a row. Net profit subtracts ad spend only while the column is on and the row already has a cost. A missing cost stays blank. Amounts are shop currency.