How do I get the order's sales channel?
Is it related to the source_name field?
The documentation states the following about the source_name field:
Orders created through official Shopify channels have protected values that cannot be assigned by other API clients during order creation. These protected values are: "web", "pos", "iphone", and "android"
So a customer checkouts on an iphone but using the web browser, will it show 'iphone'? Or will it only say 'iphone' if you process an order with the iphone shopify app?
I would expect the sales channel to be things like 'web', 'amazon', 'facebook, etc... Is that not available?
In some cases, the source_name will be set to a reserved value such as web or pos to denote that the order originated from Shopify Online Store or Shopify POS.
For any third-party sales channels, the value is set to the app id of the sales channel. If you know the app id of the Amazon channel (by inspecting a known order), for example, you could build a mapping service on your end.
Hope this helps.
Thanks Jamie. That's an interesting idea. And these ids will be constant across shops?
However, thinking about the last case I was looking at, it was an order processed with the buy button, but the source_name was web. If I understand correctly, the buy button is a sales channel in it own right so it should have been an id instead, right? Or maybe sales channels built by Shopify behave differently?
I will definitely look into the mapping solution a bit more. Is there a way for you to dig the mapping list from the Shopify systems and publish it here? I think it could be very useful and it would be much easier :)
I would like some information on this topic as well, especially as Shopify promotes the GraphQL API over the REST API, and the GraphQL API does not have the source_name field. The alternative in GraphQL seems to be the publication, but I just found out that the publication is null for a given order, maybe due to a bug, or maybe it is null because it originates from a draft order, but I am not yet sure of this.
@LullI think Publication is what Shopify calls "availability" in the admin interface. I don't think it relates to orders at all, but to Products and Channels. Channels are like, Online, Draft Order, POS, Facebook, Amazon, etc. Published would be if it's possible to see/sell that product in that Channel. So a store owner could have a product in your system but not have it available for purchase in any channel.
From what I understand, what a Sale should have is an OriginLocation. An OriginLocation is specifically where a sale was made. Most channels only have a single OriginLocation, whereas a channel like POS would have multiple since a store could have multiple POSs. Like, maybe the Shopify Store has multiple physical stores. All sales from a physical store would be from the POS channel but different OriginLocations.
OriginLocations also usually have an associated Location, but there is no association in the API. :( So, like, you know, the online channel fulfills from a Location and each POS also fulfill from a Location. But the API doesn't make that connection readable.