Query recently shipped orders

Hi, I’m trying to get a list of recently shipped orders. I’ve been using the Orders query with these filters:
customer_account_id, warehouse_id, updated_from (yesterday’s date), fulfillment_status: “fulfilled”

But we have come across multiple false positives (orders returned that weren’t yet shipped and had no tracking) - is there a better or more correct approach I should be using?
Thank you!

Hello Raj!

Would this solve your workflow?

https://developer.shiphero.com/webhooks#shipment-update-webhook

It will trigger automatically every time something is shipped. However, it only contains the order_number, not the order_id.

Another way would be to check shipments this way:

query{
  shipments(date_from:"ISODateTime"){
    request_id
    complexity
    data(first:10){
      edges{
        node{
          order_id
        }
      }
    }
  }
}

This way, you can get the order ids from the shipments created in the requested timeframe.

Bear in mind that if you have orders partially shipped, you might have a shipment in both cases, but the order won’t be as fulfilled yet, until the remaining line items are shipped.

Please, let me know if this doesn’t help.

Kind regards,
TomasFD

Hey @tomasfd!
Thank you for that… I do need the order_number though, not the order_id, but using a webhook is not possible for me at the moment.

Does the ‘shipments’ query you suggested give me order_number too?

Also, could you pls help me understand what was wrong with my original approach and why was it giving me false positives? And is it possible to repair that query somehow?

Thank you again!

Hello @Raj!

You could do something like this:

query{
  shipments(date_from:"ISODateTime"){
    request_id
    complexity
    data(first:10){
      edges{
        node{
          order{
            legacy_id
            order_number
          }
        }
      }
    }
  }
}

Could you share any order ID returning as a false positive now?

Kind regards,
TomasFD

Thank you @tomasfd! I’m going to try your suggestion now.
And here are two of the order numbers that were reported to me as false positives:
CS192556
CS192557

If you’re able to shed any light on what exactly went wrong, that would be great! Usually my method works very well, but recently I’ve been notified of this problem and I have no idea why it would happen…

Hello @Raj!

I thought you had already shared a req ID so I can go over the query,do you happen to have one?

And on the second hand, that order is already fulfilled, is there any that is returning wrong as of now?

Kind regards,
TomasFD

No @tomasfd, I’m sorry I don’t have those… and it’s usually after a delay of a couple days that I hear about a problem order. But I’ve just asked our client in case they have a new case - I’ll report back to you as soon as they tell me about one.
Thank you!

Hey @tomasfd, Just wanted to mention that your example seems to have solved my problem perfectly! So far I have only done dry runs and have asked to let me know in case any issues are still noticed, but I think the problem should be gone.
Just to add, I made some slight tweaks so that I can extract order status (fulfilled or not) and client name from the same query:

			  edges{
				node{
				  order{
					order_number
					shop_name
					fulfillment_status
				  }
				}
			  }
			  pageInfo{
				endCursor
				hasNextPage
			  }

Excellent news, @raj!

Glad to hear it’s sorted out.

Great update. I didn’t want to send you all fields, so I don’t occupy the whole screen XD.

Have a great weekend, and please let me know if any new concerns arise,

Cheers,
TomasFD

Hey @tomasfd, So the client just let me know about two new ‘false positive’ shipments, that were processed using the new code we were discussing.
CS198871
CS199980
Could you pls look into these and suggest what’s happening and how to resolve?
Thank you!

Hello @Raj!

CS198871 → This one is partially fulfilled, so it will show a shipment even if it is not in fulfilled status.
CS199980 → Right now this order is fulfilled so it will return a shipment. Did you by any chance save the req ID and response of these calls? I’d like to see exactly what is showing you (the response).

Kind regards,
TomasFD

Hey @tomasfd,
CS198871 - Yes showing shipment is correct, but in my code I’m checking if order status = fulfilled
If (j["data","shipments","data","edges",key,"node","order","fulfillment_status"] = "fulfilled")
And even though right now the status returned is “Unfulfilled FAZE”, it must’ve been returned as ‘fulfilled’ at some point.
Is there any way to find the issue by looking at the Order History:

Because that query is made hundreds of times each day and it’d be impractical to save all that info on an ongoing basis till someone tells me there’s a fresh false positive - I’d have to save output of each call and each page for days to be able to find which order in which particular instance had returned the bad output.

Thank you!

Hello @Raj!

Unfortunately, orders won’t show as Fulfilled until they are 100% fulfilled. Even if you ship part of it, the order itself won’t get the fulfilled status until all line items are fulfilled. You will see which line items are fulfilled, though, but that is all.

Yes, I completely understand, wasn’t aware how many you were generating. We only store the request, not the response, so at this point, there is not much we can do to track what and how we sent it. Could you share the whole payload with me? I will at least try to run it from my end and see if I can generate any false positives.

On the other hand, does what I explained in my first paragraph render the whole query unusable for you?

Kind regards,
TomasFD

Hey @tomasfd ! Sorry I didn’t receive a notification and didn’t see your reply sooner…

orders won’t show as Fulfilled until they are 100% fulfilled. Even if you ship part of it, the order itself won’t get the fulfilled status until all line items are fulfilled.

Actually this is perfect - that’s how I need it to be, but the problem I’m facing is that sometimes the order that is not fully fulfilled is reported as fulfilled - that’s my understanding based on what I query and an unfulfilled order number being returned.

Here’s my query:
image

And here’s how I look for fulfilled orders only:

Do you see anything wrong that I need to fix?
Thank you!

Hi @tomasfd, did you get a chance to look at my query above? Did you notice anything off?
Thank you

They just told me the problem is getting much worse.
Some latest examples that were reported as false positives by SH:
CS205075
CS205074
CS205068
CS205062

Hey @raj!

Please check your inbox!

Best
TomasFD