简体   繁体   中英

Shopify API: Get Orders In Shopify by Date

Why fetching Orders from Shopify Store by date and limits always returns the orders of latest date? like: if I make a query for getting 5 orders from 1 august 2012 using this query: /admin/orders.json?status=open&created_at_min=2012-08-01 12:00&limit=5

As I have 5 orders in 20 August 2012 and 5 orders in 31 August 2012 but this will returns 5 orders of latest date (31 August 2012).

The Shopify API returns orders from Most Recent to Oldest.

When you submit your query Shopify will first create an array of your ten orders; the first five are from 31 August, the last 5 are from 20 August.

Then, by limiting it to five orders, Shopify gives you the first five.

As far as I'm aware, there is no way to specify your own sort order in the Shopify API. You'll need to get all the orders with created_at_min= 2012-08-01 then, using whatever language you're writing in, get the last 5 items in the array.

它没有记录,但是您可以通过在查询中添加: order=processed_at+asc来实现。

&created_at_max=2012-08-01 11:59 does the trick

shopify order api

Shopify API is specifically working on the EST/EDT time. So first convert your timezone time to EDT, So you can mark the exact time as per the EDT timezone.

Let's understand the example: Currently, I'm in JST (TOKYO/ASIA) timezone, now I want the records for 2021-10-20 from order API as per the japan timings. So I need to make this kind of request parameter:

API:

orders.json?status=any&limit=250

Valid Parameter as per the date 2021-10-20 (JST)

  1. If the requirement is for updated_at date

    &updated_at_min=2021-10-19T11:00:00-04:00&updated_at_max=2021-10-20T11:00:00-04:00

  2. for created_at date

    &created_at_min=2021-10-19T11:00:00-04:00&created_at_max=2021-10-20T11:00:00-04:00

Here, We have actually converted the date of the JST (+09:00) format to EST(-04:00) for making sure that the data which I'm getting from the API should be only for 2021-10-20 date (From 2021-10-20 00:00:00 to 2021-10-21 00:00:00 [JST]).

Similarly, you can create the dates (EDT) format according to your timezone.

在两个日期之间

/admin/orders.json?created_at_min=2012-08-01 12:00&limit=2012-08-01 12:00

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM