How do I export the last successful fulfillment update of a Shopify order?

EZ Exporter already has a pre-computed field to export the created_at timestamp of the last successful fulfillment record.  This field is labeled fulfillments.last_successful_fulfillment.created_at (Last Successful Fulfillment Date) in the app.

Normally as line items get fulfilled in the order, a new fulfillment record will be created in the Shopify API data.  

However, depending on how fulfillment is handled on your store, an existing fulfilment record might be updated instead of a new record getting created.  In this case, you might want to export the most recent updated_at timestamp from the list of successful fulfillments in the Shopify order instead.

You can use the formula below in the Calculated Fields section of the Data Settings to do this:

max(to_list(get_attribute_value({{ fulfillments.successful_fulfillments }}, "updated_at", recursive=False))) if get_attribute_value({{ fulfillments.successful_fulfillments }}, "updated_at", recursive=False) else ""

The above formula will return the last successful fulfillment update for the entire order.  If you need the last update at the line item level, you can use this other formula below:

max([i.updated_at for i in load_json_data({{ fulfillments.successful_fulfillments }}) if int({{ line_items.id }}) in [int(li.id) for li in i.line_items]]) if [i.updated_at for i in load_json_data({{ fulfillments.successful_fulfillments }}) if int({{ line_items.id }}) in [int(li.id) for li in i.line_items]] else ""

Please note that the updated_at field might also get updated as the shipment status changes.


Related Articles:


App: EZ Exporter

Tags: advanced features, fulfillments, fulfillment data