Re: Shopify Flow: advanced query filter for Get Customer Data action

Solved

Shopify Flow: advanced query filter for Get Customer Data action

Ed_Graham
Excursionist
17 1 0

I am trying to combine two conditions with a logical AND in an advanced query in the Get customer data action in my workflow.  My customers have the tag  EdTest and live in the UK; so I would expect the following expression to evaluate to FALSE:

 

tag:EdTest AND default.defaultAddress.country:NotACountry

 

However, this evaluates to TRUE for all customers with the EdTest tag (as if the AND were in fact an OR).  I've also tried a variation of the query syntax without the leading "default.":

 

tag:EdTest AND defaultAddress.country:NotACountry

 

but the result is the same.  (See images below.)

 

How can I filter my customers based on a property of their address?

 

Shopify7.pngShopify8.png

Accepted Solution (1)
paul_n
Shopify Staff
1729 189 399

This is an accepted solution.

You can't query by city or town. So if you want that, then segments is probably better. 

 

Start here

https://help.shopify.com/en/manual/customers/customer-segmentation/create-customer-segments

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

View solution in original post

Replies 3 (3)

paul_n
Shopify Staff
1729 189 399

Query filters don't allow you to use "." to specify the filter name, with the exception of metafields, so this is invalid and thus ignored by the API: 

default.defaultAddress.country:NotACountry

Also, I'm not sure where you got "NotACountry" but that is unlikely to work in any situation. 

 

The list of available query filters are here:

https://shopify.dev/docs/api/admin-graphql/2024-04/queries/customers#argument-query

 

There is a "country" filter. I'm not sure if it filters by default address or some other address. I'll note that the filter is also deprecated in favor of segments. So you may want to instead create a segment and use Segment Joined/Left triggers in conjunction with the segment. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Ed_Graham
Excursionist
17 1 0

Thanks Paul - that's helpful.  How can I filter my customers according to the town or city in which they live (as specified in their default address)?  Should I use segments instead?  I've never heard of those, so if you could point me to some examples, that would be very helpful.

paul_n
Shopify Staff
1729 189 399

This is an accepted solution.

You can't query by city or town. So if you want that, then segments is probably better. 

 

Start here

https://help.shopify.com/en/manual/customers/customer-segmentation/create-customer-segments

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.