ETLMCPData Conveyance Works
Log in Start free
Guides

Shopify discounts: order-level, line-level and after returns

Which Shopify field holds an order's full discount, why line-item sums come up short, and how etlmcp's discounts column is measured.

Coming This connector is coming.

To get an order's full Shopify discount, read the order's own total, not its line items. In the Admin GraphQL API, Order.totalDiscountsSet holds the discounts on the whole order before returns, and Shopify's reference says it counts both order-level and line-level discounts. Order.currentTotalDiscountsSet is the same figure after returns and refunds. A total built by adding up line-item discount fields comes out short whenever an order carried a discount on the whole order, and some of those fields also miss code-based discounts. When the Shopify connector is available, etlmcp's discounts column is the before-returns total, with tax taken out.

Why line-item sums miss discounts

Shopify's LineItem object has several discount fields, and each one leaves something out:

Field What it leaves out
discountedUnitPriceSet Order-level discounts and code-based discounts
totalDiscountSet Order-level discounts
discountedTotalSet Order-level discounts, and code-based discounts unless you pass its withCodeDiscounts argument

If a customer used a code for 10% off the cart, or an automatic discount on the whole order, a sum of totalDiscountSet across the line items falls short of the order's discount total. Shopify's reference does not say whether totalDiscountSet counts code-based discounts, so do not rely on it for them. Treat line-item fields as a per-product split, not as the order's total.

Which discounts were applied, and in what amount

Order.discountApplications lists the discounts applied to an order, but it leaves out order edits and refunds. It tells you which discounts were applied, not how much discount is left after a later change. For the whole-order part alone, cartDiscountAmountSet is the cart-wide discount when the order was created, and currentCartDiscountAmountSet is that discount after returns, refunds, edits and cancellations.

Before or after returns

Pick one and use it in every report:

  • Before returns (totalDiscountsSet): what was given away at checkout. It does not move when an item comes back.
  • After returns (currentTotalDiscountsSet): what is left once returned items take their share of the discount with them.

Shopify's finance reports keep the two apart. Their discounts show as negative amounts on the date the order was placed, and returns appear separately as sales reversals, also negative, on the date the return was processed. Net sales there is gross sales minus discounts minus sales reversals, and a product's discount includes its proportional share of any cart-wide discount.

What etlmcp's discounts column holds

When the Shopify connector is available, each daily row carries a discounts figure built this way:

  • It is the sum of totalDiscountsSet over the day's counted orders, so it is order and line discounts before returns. etlmcp's orders query does not ask for currentTotalDiscountsSet.
  • etlmcp keeps the amount's sign as the API returns it, a positive number. Shopify's reports show the same money as a negative, so flip the sign before you compare.
  • It excludes tax. If the store's prices include tax, etlmcp takes the tax out of the discount at the order's own average tax rate on goods. An order discounted to nothing keeps its discount as Shopify states it, because no tax is left to derive a rate from.
  • It counts on the day the order was placed, in the store's time zone.
  • Test orders and cancelled orders are left out.

net_sales in the same row is measured after discounts, returns and order edits. Because the discount stays at its checkout value while net sales falls with each return, gross_sales minus discounts equals net_sales for orders nothing happened to after checkout, and the two drift apart once an order is returned or edited. Do not use the refunds column to close the gap: it is money given back, shipping and tax included.

When the connector is available, each routine sync pulls the last 58 days again, so returns and edits inside that window reach net_sales on the order's own day. For the full column list, see the Shopify connector reference; for the sync itself, see how a Shopify sync runs.

Matching Shopify's own numbers

To reconcile etlmcp with a Shopify finance report for the same days:

  1. Use the store's time zone and the order date on both sides.
  2. Compare etlmcp's discounts with the report's discounts as a positive number.
  3. On a store whose prices include tax, remember that etlmcp states discounts without tax. Shopify's finance report page does not say whether its discounts carry tax, so check one order by hand first.
  4. Compare returns separately: Shopify dates them on the day of the return, etlmcp folds those inside its re-pulled window into net_sales on the order's day.

Related

Sources

  1. Order - GraphQL Admin — shopify.dev, checked
  2. LineItem - GraphQL Admin — shopify.dev, checked
  3. Finance reports — help.shopify.com, checked