source_identifier and reference in Order API

Ruslan_Starikov
Tourist
9 0 5

Hello. 

Source_identifier and reference keys in the order object are not documented. They are also set to null in all of the orders that I have ever encountered. What is their purpose? Can they be set with our own identifiers, by using the new order api call?

Thanks

Ruslan

Replies 7 (7)

Busfox
Shopify Staff (Retired)
628 49 110

Hi there,

Source_identifier and reference are used internally for orders placed through Shopify POS. AFAIK, they can't be set through the API.

Cheers,

To learn more visit the Shopify Help Center or the Community Blog.

Krecik
New Member
5 0 0

If they are not documented, are they safe to use and rely on?
We are currently working on an app where we would like to distinguish orders by POS device and location. So the source_identifier field seems just perfect for this.
Otherwise we would have to extract the POS device id from order.name, but for this, one needs to know the order prefix and suffix settings (which cannot be retrieved through the API) or one has to rely on guesswork (which might sometimes yield ambiguous results). But this undocumented field would give us exactly what we want.

I hope this API will remain stable as is, so we can use it in our app and rely on it. Can someone confirm that we can use this as is without problems in the forseeable future?

Busfox
Shopify Staff (Retired)
628 49 110

The source_name field on Orders should be what you need. POS orders will have the value of pos. It's documented, so is safe to use an rely on.

To learn more visit the Shopify Help Center or the Community Blog.

Krecik
New Member
5 0 0

> The source_name field on Orders should be what you need.
How so? Have you read what I wrote?
The source_name field only says only "pos" or "web" or whatever one might set in a custom created order through the API.

But we want the info about the POS device id and its location, in the case of a POS order (that is, when source_name == 'pos'). This info seems conveniently stored only in the undocumented "source_identifier" field like this:

order.source_identifier = `${order.location_id}-${order.pos_device_id}-${order.pos_order_number}`

where the 'pos_device_id' and 'pos_order_number' (the separately incrementing number for orders only from that specific POS device; separate from the global 'order_number' counter) fields are not separately accessable existing fields, but only encoded here and in 'order.name'. They can be extracted unambiguously from here, and only from here (from source_identifier).
They are also encoded in 'order.name', but not in a way that they can be extracted unambiguously without further knowledge.
The 'order.name' field takes the form

order.name = `${order_prefix}${order.pos_device_id}-${order.pos_order_number}${order_suffix}`

The only other way to extract the 'order.pos_device_id' from this one unambiguously is by knowng 'order_prefix' and 'order_suffix' settings of the store (which are not accessible through the API).
So, the problem once again in summary is: It would be good to have a field like 'source_identifier' to rely on to extract this information without ambiguity. The only other place it's stored is in 'order_name', but not in a way that it can be extracted unambiguously.
 

Busfox
Shopify Staff (Retired)
628 49 110

Hi again,

Apologies for misreading your last post. Looking at what is serialized within the order object, I believe you're looking for the device_id, which will include the pos_device_id, and location_id, which is the id for that device's location. Location can also be accessed through the Location API.

You can also continue using source_identifier if it better suits your needs. Just note that it's unsupported and subject to change without notice.

To learn more visit the Shopify Help Center or the Community Blog.

Krecik
New Member
5 0 0

Oh, thank you very much, device_id, I had not seen that one before. That seem to be even better to use. However, that one is undocumented as well.

 

Jiri_Hacmac
Shopify Expert
10 0 10

Hello,

any update on this Topic?

We would also need to identify (since couple of years) the source iPad where the Order/Refund has been placed.

moving primates GmbH • https://www.movingprimates.de