Order a CusomterSavedSearch by created_at, or query by created_at date

Highlighted
New Member
1 0 0

Hello,

 

Im using CustomerSavedSearch to grab all customers who have `accepts_email_marketing` set to true. I want to either order these customers by their created_at date, or even better limit the query to only return customers created on a given date. Is this currently possible with the api?

 

Thanks

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1129 82 168

Hey there, 

 

It doesn't look like this is currently possible, which is interesting considering you can filter based on the customer creation date within the Shopify admin. I'm not sure of the reasoning behind that, but it strikes me as more of an oversight than an intentional decision. I'll report this internally in hopes we can get that added for you! 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1129 82 168

Hey again! 

 

Good news - this actually is possible after all. The query value is just named differently when setting it with the API. 

 

You can pass  "query": "customer_date:last_month" when creating a CustomerSavedSearch for example, and that'd give you only customers created within the past month.

 

You can also pass the following: last_week, past_week, last_month, past_month, last_3_months, past_quarter, last_year, past_year. Dates in the format of 'yyyy-mm-dd' also look like they work with < and > symbols before them if required.

 

 

0 Likes