How can I determine which line items in the order were exchange items for a return?
When a return is created, there's an option to add exchange items. These exchange items will be added to the order as new line items.
To figure out which line items were exchange items for a return, you can use the formula below under the Calculated Fields section of the Data Settings:
"Yes" + " (" + ",".join([r.name for r in load_json_data({{ returns }}) if {{ line_items.admin_graphql_api_id }} in [li.line_item.id for li in r.exchange_line_items]]) + ")" if {{ line_items.admin_graphql_api_id }} in [li.line_item.id for sublist in [r.exchange_line_items for r in load_json_data({{ returns }})] for li in sublist] else "No"
This will export "Yes (Name of Return)" if a line item is an exchange item, and "No" otherwise.
Here's a sample output:
Related Articles:
App: EZ Exporter