How do I exclude deleted line items from my Shopify order export?

When you remove a line item during an order edit, what Shopify does on the backend is "refund" this line item (more info here).

The Shopify Order API doesn't have a field to identify whether an order was edited and a line item was removed.  What we can do instead, however, is parse the "refunds" data and calculate how many of each line item was refunded.  If the entire original quantity was refunded, then we can assume that the line item was deleted.

In EZ Exporter, we've added a pre-computed field called line_items.current_quantity (Lineitem Current Quantity) that already subtracts the refunded quantity from the original quantity.  So to exclude those removed/refunded line items, all we have to do is add a Custom Filter where the value of this field is greater than zero.

In the Data Settings, just go to the Custom Filters section > Shopify Fields and add this filter shown below:

We have a pre-built template called "Orders Excluding Removed/Refunded Line Items (Last 30 Days)" you can use that already has this configured and can be customized further.

One caveat is there's currently no way to differentiate between an actual line item refund and a line item deletion from an order edit.

You may also want to use the price fields below in this case which reflect order edits and refunds:

  • current_total_price
  • current_subtotal_price
  • current_total_discounts
  • current_total_tax

Related Articles:


App: EZ Exporter

Tags: advanced features, refunds, order edit