• Resolved totallywp

    (@panatapattu)


    Hi,
    I want to get all WooCommerce orders from given date range. I can retrieve all orders at once. But I am confusing with passing the date range via API URL.

    Can anybody help me with this? I know it’s something like this but can’t figure out the exact way to do it.

    Here is my route:

    add_action('rest_api_init', function() {
        register_rest_route('woo/v2', 'woocommerce/order_summary_by_date/(?P<start_date>/<end_date>)', array(
            'methods' => 'GET',
            'callback' => 'woocommerce_orders_by_dates'
        ));
    });

    This is the function to access:

    function woocommerce_orders_by_dates($start_date, $end_date) {
        $start_date = $start_date['start_date'];
        $end_date = $end_date['start_date'];
    
        return $start_date . $end_date;
    }

    URL is: https://example.com/wp-json/woo/v2/woocommerce/order_summary_by_date/?start_date=2021-09-01&end_date=2021-09-30

    Any help highly appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Sol J. a11n

    (@solstudioim)

    Hey @panatapattu

    Sorry for the delay getting back to you!

    I want to get all WooCommerce orders from given date range. I can retrieve all orders at once. But I am confusing with passing the date range via API URL.

    Can anybody help me with this? I know it’s something like this but can’t figure out the exact way to do it.

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution and the above resources for developers were helpful to you. If you have further questions, please feel free to open a new topic.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to create WordPress custom end point with multiple parameters?’ is closed to new replies.