skip to Main Content

I’m using the Woocommerce Rest API to grab orders using the following:

https://example.com/wp-json/wc/v3/orders?consumer_key=ck_xxx&consumer_secret=cs_xxx

How can I grab the completed orders for the current day?

2

Answers


  1. According to the documentation, you can add GET parameters like "before", "after", and "status" to the retrieve order GET endpoint.
    I’d combine those and see what response you get.
    I can’t test at the moment, but I assume for the completed orders of 2021-12-01, your URL would look like this:

    https://example.com/wp-json/wc/v3/orders?consumer_key=ck_xxx&consumer_secret=cs_xxx&status=completed&after=2021-11-30&before=2021-12-02

    Login or Signup to reply.
  2. I’ve encountered the same issue today, and the dates need to be in the following ISO8601 compliant format:

    after=2022-12-30T00:00:00
    
    before=2022-12-31T00:00:00
    

    So this is how the link should look like:

    https://example.com/wp-json/wc/v3/orders?consumer_key=ck_xxx&consumer_secret=cs_xxx&status=completed&after=2021-11-30T00:00:00 &before=2021-12-02T00:00:00 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search