• Resolved fortif3

    (@fortif3)


    Hi,

    I’m trying to find a way to consistently retrieve a daily sales report using the Woocommerce REST API. From the documentation, I can see that the period parameter has a week, month, last_month and year option. Right now, I’m using the week option and looking at the daily breakdown, but it doesn’t appear to properly factor in refunds.

    There are the date_min and date_max parameters as well but I think I’d need to manually adjust them daily, so I don’t think they are what I need.

    Is it possible for me to get just a daily report for total sales figures?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Shaun Kuschel a11n

    (@shaunkuschel)

    Automattic Happiness Engineer

    Hey @fortif3,

    Yeah, what you described is expected behavior- as the order totals do not take refunded orders into account (just the combined totals of the orders placed).

    There was actually a discussion about this on WooCommerce’s public Github repo- related to a fairly similar-sounding situation. This conversation took place a few years ago, but I think the info may still be helpful for you:

    https://github.com/woocommerce/woocommerce/issues/14569

    Regarding the daily report, I believe that the current day is the default and the week, month, etc, are the other options that can be specified.

    Thread Starter fortif3

    (@fortif3)

    Hi Shaun,

    Thanks so much for your response.

    Ah yes, that makes sense in regards to the refunds.

    As for the daily report, I can see that the documentation states that today’s date is the default, but I’m unsure how to run the default get request. It seems to always want me to specify one of the options – week, month, last month, year. I’m using Python, by the way.

    Please excuse me if I’m missing something obvious, I’m very new to all of this.

    Thanks again.

    Plugin Support Shaun Kuschel a11n

    (@shaunkuschel)

    Automattic Happiness Engineer

    Hey @fortif3,

    I’m somewhat familiar with the REST API but still very much learning myself, so no worries! ??

    I did a quick test using Postman with the following request:

    GET https://[SITEURLHERE]/wp-json/wc/v3/reports/sales?total_sales

    I didn’t have any sales from today on that test site when I ran that request initially, so I placed an order and ran it again- which did work the 2nd time and showed the order info from the purchase I made today.

    I didn’t specify anything in my request except total_sales and the output appears to have used the default period (today’s date), as along with the total sales info, the following was also shown:

    
            "totals_grouped_by": "day",
            "totals": {
                "2021-03-25": {
    
    Plugin Support Shaun Kuschel a11n

    (@shaunkuschel)

    Automattic Happiness Engineer

    Since it’s been a while since the last update, I’m going to go ahead and mark this thread as resolved. Though, if you run into any other issues, feel free to create a new post (and link to this one). Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Daily Sales Report REST API’ is closed to new replies.