Get orders after a certain order number from customers with a given tag

Shopify Partner
12 0 0

Is there a way with the API to select a subset of orders? Basically, I need orders greater than a certain order number. And the orders are placed by customers that have a given tag. Of course I can get the entire list of orders after a certain order number & date and then filter.

Thanks,
Mike

0 Likes
Shopify Partner
8 0 0

Hi Mike,

We have done this by adding since_id

our example below

 

"orders.json?query=tag:blue,fields=created_at,id,name,total-price,order_number,currency,line_items,shipping_address,customer,note,since_id=1004

 

regards

 

Jason

0 Likes
Shopify Partner
8 0 0

An Update, sorry typos above

we are limiting the fields coming back,

orders.json?fields=created_at,id,name,total-price,order_number,currency,line_items,shipping_address,customer,note&since_id=1004

 

or just

orders.json?since_id=1004

 

 

0 Likes
Highlighted
Shopify Partner
12 0 0

Thanks Jason, but either this doesn't work or I'm missing something.

I understand the since_id (though this seems to use not the order_number but the "id").

The thing I NEED is I want only orders where the customer object has been tagged, like "RETAILER." 

The application here is a orders for retailers where such orders are fulfilled from a warehouse rather than individuals, where the orders are small and handled within the office.

I know I can get all the orders and filter on the client-side, just hoping there is an easier way to make the returned data smaller and only what I need.

0 Likes
Shopify Partner
219 0 13

Hey Mike,

Query parameter does not work with the Order API so you will have to bring a big chunk of orders and filter them on your server side then decide what to do with that. That been said I suggest you use created_at_max and created_at_min to delimit the number of orders you bring, to be sure how many pages you must pull I suggest using the /orders/count.json?created_at_max=&created_at_min to see how many orders you need to pull. divide it by 250 (which is the max amount you can get per page.) and just loop the get orders.json api to pull only the info you need. and filter on your side. Its a hassle but for now its the only way I think. I wish you the best of lucks :D 

Cheers!

Entrepreneur, Developer, Geek, Gamer and very passionate about WEB development! :P

Need help with your Shopify Store? Contact me: jfeuchter@gmail.com :D
0 Likes