I'm a developer and one of our users asked for a feature to iterate through all sales channels similar as from the admin page (similar as shown in the below screenshot).
However, I couldn't find ways to retrieve this from the Orders API. It seems the "Order" object has "source_name" and "app_id" fields but they only have values within a fixed enum set ("web" and "shopify_draft_order"). Anyone knows if there's a way to get the "real" sales channel of an order or it's still not a live feature yet? Thanks!
Solved! Go to the solution
If you look at the Shopify GraphQL API reference (https://shopify.dev/docs/admin-api/graphql/reference/object/order?api[version]=2020-07) you will see a publication field. This should link back to the sales channel that brought in the order I believe.
As for the REST API endpoint for orders, the app_id has hard-coded integer values that translate to the sales channel that the order was created through. Actually in the Shopify web admin, you can filter orders by sales channel and see the app_id values in the URL. These app_id values don't change once the shop has installed the sales channels. See below.
If this doesn't suffice, hopefully the GraphQL route will automatically perform the mapping as to the real sales channel names...
Look at my screen shot I provided up above. It shows in the Shopify web admin where if I select a sales channel in the GUI, the ID appears in the URL in the address bar. That's a quick way to map which ID goes with which sales channel name. While you might be able to get at this programmatically using the GraphQL API or something, if you don't have a lot of sales channels and since the ID mappings don't change, this is a quick and easy way to do this
Hi @Greg_Kujawa sorry I didn't make my question clear. I meant would it be possible to give a simple GraphQL example for this? Since I'm an app developer it's not quite likely to access our user's admin dashboard to read ID-name mappings of their sales channels.
This is super helpful and relevant to me as well. I'm trying to retrieve orders data to build a database - I was using the REST APIs before realizing the GraphQL APIs will probably serve me way better to retrieve orders at bulk. However, since I had imported my orders data using REST APIs, I was extracting app_id to track the sales channel. What's the equivalent in the GraphQL API? Is orders[i].app_id in the REST API the same thing as orders.publication.app in the GraphQL API? Or would I need to go one level deeper in the GraphQL API - orders.publication.app.id?