GraphQL Filtering Orders by sales_channel

Solved
BradKrane
Shopify Partner
44 4 11

I'm trying to filter orders by date and sales channel with GraphQL. When I omit the field sales_channel from the query I get the orders on the date specified the number of which matches that expected. However, when I include the sales_channel field I get 4 orders which is far from the expected number of ~150. I'm using the GraphQL query below with admin API 2021-04

 

{
  orders(query: "processed_at:=2019-07-06 sales_channel:Point of Sale") {
    edges {
      cursor
      node {
        id
      }
    }
    pageInfo {
      hasNextPage
    }
  }
}

 

 

What am I missing here? The 4 orders returned don't appear to differ in any way from the other POS orders that day.

Thanks for the help!

Accepted Solution (1)

Accepted Solutions
awwdam
Shopify Staff
Shopify Staff
241 40 30

This is an accepted solution.

Hey @BradKrane,

After some digging I wasn't able to locate sales_channel as a confirmed query parameter specifically. However in the Order resource documentation the source_name property can return pos as a parameter (as well as webshopify_draft_orderiphone, and android) I might suggest retrying the query but instead filtering by this property, and have included an example below as a starting point!  

-  Cheers!

 

{
  orders(first: 150 query: "processed_at:2019-07-06 source_name:pos") {
    edges {
      cursor
      node {
        id
        processedAt
        publication {
          name
        }
      }
    }
    pageInfo {
      hasNextPage
    }
  }
}

 

 

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 8 (8)
awwdam
Shopify Staff
Shopify Staff
241 40 30

This is an accepted solution.

Hey @BradKrane,

After some digging I wasn't able to locate sales_channel as a confirmed query parameter specifically. However in the Order resource documentation the source_name property can return pos as a parameter (as well as webshopify_draft_orderiphone, and android) I might suggest retrying the query but instead filtering by this property, and have included an example below as a starting point!  

-  Cheers!

 

{
  orders(first: 150 query: "processed_at:2019-07-06 source_name:pos") {
    edges {
      cursor
      node {
        id
        processedAt
        publication {
          name
        }
      }
    }
    pageInfo {
      hasNextPage
    }
  }
}

 

 

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

BradKrane
Shopify Partner
44 4 11

@awwdam That does the trick, thanks!

sales_channel is listed as a supported filter parameter of orders in the GraphiQL explorer.  I was guessing a value as there is little available in the doc about all the supported filters in the Orders API doc

few_meaning
Shopify Partner
11 2 0

Looking to do the same thing, I stumbled across this question. I found sales channel is also listed as a filter in the documentation here: https://shopify.dev/api/admin-graphql/2022-01/queries/orders#argument-orders-query

few_meaning_1-1643686294862.png

Additionally, sales_channel is used in the admin portal when filtering by "App", e.g. `sales_channel:"580111"` is apparently "Online store" while `sales_channel:"129785"` is "POS" for the store I'm looking at. A bit fishy that it's used and documented, but not enough to be usable.

global_dbanks
New Member
7 0 0

How did you find the numeric value of the sales channel? Im not seeing the sales channel values. 

few_meaning
Shopify Partner
11 2 0

If you select one of the sales channel filters:

few_meaning_0-1648565656505.png

you should be able to see the URL update accordingly:

few_meaning_1-1648565781915.png

Or you can inspect the HTML:

few_meaning_2-1648565909817.png

global_dbanks
New Member
7 0 0

Thanks for the reply. I was able to find it. Have you experience no results returned when only using the numerical value as the source name? 

few_meaning
Shopify Partner
11 2 0

"source_name" in the GraphQL API is not the numerical value, it's the "name" (the words). See https://community.shopify.com/c/shopify-apis-and-sdks/get-order-s-sales-channel-name/td-p/324784 for some more context.

global_dbanks
New Member
7 0 0

Ahh thanks, looks like I need to create some sort of mapping since the 3rd party sale channels don't have names. Thanks for your help

 

 Screen Shot 2022-03-29 at 11.45.35 AM.png