Why is the exported data still showing the original values after editing an order and removing a line item or decreasing the quantity?

When you edit an order via the Shopify Admin and remove a line item or decrease the quantity, you'll notice that the order export still shows the original values.  You'll see the same behavior in Shopify's CSV export as well.

What happens on the Shopify backend is they instead "refund" these line items (though the payment status doesn't change to "partially refunded" probably because no payment was actually refunded and they also don't show up in the order's transaction data).

In EZ Exporter, there's a pre-computed field called line_items.current_quantity you can use which already has the refunded quantity subtracted.

You can then use the Custom Filters > Shopify Fields section and add this filter below to exclude those line items where the current quantity is 0:

  • Lineitem Current Quantity is greater than 0

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.

There's also a field called line_items.fulfillable_quantity (the remaining quantity to be fulfilled) which also already takes the refunded quantity into account. So if you're only exporting unfulfilled orders, you might want to use this field instead of the line_items.quantity field to get the actual quantity that needs to be fulfilled.

The other issue is the total_price field is also not adjusted.  Since there's no actual transaction, the refund transaction data is empty in the Shopify API so we can't just subtract the refund transaction amount.

Shopify had recently added additional fields in the API, however, which will give the current values of the different price fields at the order level.  The values for these fields will reflect order edits and refunds:

  • current_total_price
  • current_subtotal_price
  • current_total_discounts
  • current_total_tax

Related post from the Shopify forums: https://community.shopify.com/c/Shopify-APIs-SDKs/API-is-serving-deleted-removed-order-line-items/m-p/716942


Related Articles:


App: EZ Exporter

Tags: shopify order editing