Search for Orders by customAttribute using API

Search for Orders by customAttribute using API

akto-sam
Shopify Partner
4 1 3

Hi

 

Is it possible to search for a collection of Orders by a value in a customAttribute (i.e. their key/value pairs)? I've tried a number of approaches across all the API that I could experiment with, but to no avail.

 

I'm hoping that I've missed something and that one of the API support it (maybe I just couldn't find the correct docco), otherwise I'd be keen to hear of there's a workaround (like leveraging a Saved Search, or some other means).

 

The GraphQL API looked to be the most promising, but I notice that the QueryRoot.OrderConnection supports filtering on the following properties (not including custom attributes):

 

  • cart_token
  • channel_id
  • chargeback_status
  • checkout_token
  • created_at
  • credit_card_last4
  • customer_id
  • discount_code
  • email
  • financial_status
  • fraud_protection_level
  • fulfillment_status
  • location_id
  • processed_at
  • reference_location_id
  • risk_level
  • sales_channel
  • source_name
  • status
  • tag
  • test
  • updated_at

 

On top of that, the individual Order object's customAttributes collection is not searchable (at that level) in graphql.

 

I'll greatly appreciate suggestions to help me work this out.

 

Cheers,

 

Sam

Replies 5 (5)

KarlOffenberger
Shopify Partner
1873 184 902

Hello!

 

Unfortunately the greeting above will be the only good news - filtering by order_notes (as they're called in REST API) or customAttributes (as they're called in GraphQL API) isn't possible no matter how you slice and dice the APIs.

buildpath
Shopify Partner
59 11 20

@KarlOffenberger do you know if this has changed since your reply here in 2019? I'm trying to query GraphQL to get the first: 5 orders that have a specific customAttribute

Ecom entrepreneur since 2004 | Shopify App developer since 2021 | Shopify merchant and theme developer since 2016
darrenhundt
Shopify Partner
8 0 6

I am also looking for a way to do this without pulling every order in the store every time i want to run a report.

 

jdeanwallace
Shopify Partner
1 0 0

@KarlOffenberger - Is this still true in 2023?

RobFarmLink
Shopify Partner
43 2 38

Really need the ability to query orders by attribute or metafield value.