How can I export the refund IDs at the line item level from a Shopify order?

In EZ Exporter, we have a preset field called refunds.id, which is a comma-separated list of refund IDs for the entire order.

If you need the refund IDs at the line item level, you can use the formula below to match them up by line item:

",".join([str(r.id) for r in load_json_data({{ refunds }}) if str({{ line_items.id }}) in [str(li.line_item_id) for li in r.refund_line_items]])

This is a pretty complex formula due to the way the refunds data is returned by the API, where all the refunds are combined together in one field and then have nested subfields that we have to traverse to figure out which refund object is associated with which line item.


Related Articles:


App: EZ Exporter

Tags: advanced features, refunds