Orders API only returning Register orders, not online

I am upgrading from V1 to V2. The orders API is only returning my in person orders taken on Register. I would like the API to return both my Register orders and my Online orders (pickup). My json is here:

$json = '{
	"return_entries": false,
	"location_ids": [
      "'.$api['sqLid'].'"
    ],
   "query":{
      "filter":{		  
		  "date_time_filter":{
            "closed_at":{
               "start_at":"'.$date.'T00:00:00-08:00",
               "end_at":"'.$endOfDay.'T00:00:00-08:00"
            }
         },
         "state_filter":{
            "states":[
               "COMPLETED"
            ]
         }
      },
      "sort":{
         "sort_field":"CLOSED_AT",
         "sort_order":"DESC"
      }
   }
}';

:wave: Are the online orders that you are looking for in a COMPLETED state? If not they won’t be in that query and you would need to add the state that the orders are currently in. :slightly_smiling_face:

I don’t think my staff always remembers to mark the orders as done when they are picked up. Although they always are. I don’t want to rely on my staff remembering to get accurate reports, what’s the best technique here: remove the filter altogether?? I think it’s required. Are these orders really “open”?? They are fully paid for and I don’t think they are editable???

State filter isn’t required in the Query, I don’t think. I do a very similar Orders search using the .NET SDK and the only thing I put in the Query is a DateTimeFilter for the CreatedAt time. The only thing that’s required as far as I know is at least one Location ID. Someone from Square will correct me if I’m wrong, I’m sure. :slight_smile:

If you are using the sort_field CLOSED_AT the state_filter is required. However as @cbstl pointed out you can query for the created_at without a state. This all depends on how far in advance your orders are being created and time to completion. :slightly_smiling_face:

1 Like

Thanks for the correction @Bryan-Square - I had wondered in the back of my mind if there were conditional requirements like that. Sounds like one approach would be to make the call multiple times with the State set differently to accumulate the total set of closed orders for the specified time window.

Yeah, that is definitely one approach. :slightly_smiling_face:

@Bryan-Square . I have everything working by querying by created_at and including open orders, but now I got the idea to auto-complete any orders sitting in the queue that are past their pickup times. It looks like the API only allows you to change the status of orders that were created via the API?? Can you confirm?

James