I want to save the order track number in my app. I find the value in each fulfillment on the order from the tracking_number field, but only if the tracking_company has a certain value.
This works in some cases, but in other cases I have no track value in the app, but when I look at the order in Shopify, the track number is there. Any suggestions as to why I can only extract the track number for some, but not all orders?
I can see all webhook updates in my log - in the most recent webhook update there is no track number or company. When I look at the order in Shopify, the track number is there, and when I use postman to fetch the given order from Shopify, the track number and company is there.
So there is a difference in the fields received on an order via webhook, or via querying the API for the order directly.
So I guess I need to register the fulfillment webhook - assuming that it will call my app with the track number.
But it is really inconvenient because I still need the order webhooks for other data. As a fulfillment change will probably result in both an order and fulfillment webhook being called at the same time, this can lead to database update errors in my app, when updates are attempted at the same time. One webhook update will be rejected, but Shopify will keep calling until it succeeds, so the update will happen later. But then there is a race between the two webhooks - the order webhook has incorrect data in the track number field, the fulfillment webhook (hopefully) has the correct track number.
It would be really nice if Shopify would determine whether it is a bug or not that the order webhook does not have valid track numbers / or alternatively that the order webhook is not called when only the track number changes on an order.