Retrieving order recipient

I am writing a script to generate csv files for open orders (since there is no export button on the orders page for whatever reason :confused:) I’m pulling all the data using Order objects described below and have filtered for only SHIPMENT type orders.
orders_api = squareconnect.OrdersApi(api_client)
response = orders_api.search_orders(body=query_params)
orders = response.orders
I’ve found that some orders (especially those from square online) don’t have a customer_id or the related info, and I need these shipping details (name, address, etc.). Since I can’t get this from the customer API, I have tried using “recipient = order.fulfillments[0].shipment_details” but am getting an AttributeError: ‘OrderFulfillment’ object has no attribute ‘shipment_details’. This seems to be because the fulfillment stage is PROPOSED. Printing the OrderFulfillment object, I get [{‘pickup_details’: None, ‘state’: ‘PROPOSED’, ‘type’: ‘SHIPMENT’}]. Where else can I access this recipient object to retrieve name/address details (when a customer_id is not present for the order)? Should I just set the fulfillment stage to RESERVED? I assume this would alert the customer and I would rather not do this.
Any help is appreciated :slight_smile:

Do you have an example order_id that we can look into? :slightly_smiling_face:

Here are a few: wem0Ans1P9dRmx62Xl5zChGdTCJZY, 0mlg9UtXg6fqlKav2NTheB0bNSDZY, YAxW6s1v4wOYSGksFSqPmE3WlxWZY
It looks like almost all orders before 2022-11-02 have no customer_id associated with them when using the API, although I can look up these customers manually and see that the order is in fact attached to a customer. All my orders have no attribute fulfillments[0].shipment_details although I have found the same orders in the squareup gui and can see “Shipment details” with fields like recipient, contact, ship to, etc. just can’t seem to pull the same info with the API.
For the vast majority of our shipment orders (with the exception of some data entry inconsistencies), there are both customer information and recipient information, although recipient information seems like a more fool proof way to pull this information since its a required field for this order type. I’m open to any other ways to access the same information - address, name, contact info.

I just checked all those orders and they all have shipment_details in the API response. If you call RetrieveOrder with our API Explorer do you see the shipment_details? :slightly_smiling_face:

Yep, I see shipment_details when using Retrieve order but not when using Search order. I assume these are just different lookup methods to retrieve the same order objects, are they not? with Search order I seem to be getting less data. I’ve attached my full script for reference. I’m not much of a programmer so I’m sorry if its a bit messy. (accidentally shared my access token on the last comment lol)

They’re in the SearchOrders results. I just checked the order samples you provided. RetrieveOrder and SearchOrders return the same results. :slightly_smiling_face:

Hmm this is strange, I keep getting [{‘pickup_details’: None, ‘state’: ‘PROPOSED’, ‘type’: ‘SHIPMENT’}] for order.fulfillments[0]. As I mentioned I’m not a programmer by trade so I’m honestly a little out of my depth. Is order.fulfillments[0].shipment_details not a viable way to retrieve this data or am I doing something differently than you are? What path are you using to get to shipment_details using the order object?