• I am putting a request that pulls a list of orders via the API in PHP.
    I am having a lot of difficulty in accessing the X-WP-TotalPages in the header.
    Is there anyone who can point me in the right direction!
    Thanks

    Here is the code I am using at the moment;

    require($_SERVER["DOCUMENT_ROOT"] . "/vendor/autoload.php");
    
    use Automattic\WooCommerce\Client;
    
    $woocommerce = new Client(
        'http://example.com',
        '*****************************',
        '*****************************',
        [
            'wp_api' => true,
            'version' => 'wc/v1',
        ]
    );
    $endpoint = 'orders';
    $options = ['filter[limit]' => '200', 'filter[period]' => 'year', 'filter[order]' => 'ASC', 'status' => 'processing'];
    
    $result = $woocommerce->get($endpoint, $options);

    I need something like this;

    print_r(get_headers($result));
    Bu that is just not working or any number of variations I have tried!

    https://wordpress.org/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    There are some pretty good docs for the wc api here: http://woothemes.github.io/woocommerce-rest-api-docs/

    I can’t help much beyond that, as this is pretty custom. You may need to hire another dev for further help:

    http://jobs.wordpress.net/
    https://codeable.io/
    https://woocommerce.com/experts/?project-scope%5B0%5D=1819

    Thread Starter memerance

    (@memerance)

    Hey Caleb,
    Thanks for the response, unfortunately no part of any version of the Woo API does it cover the headers and how to access them, well apart from the obvious X-WP-TotalPages.
    I have found a work around for now using a bit of jquery to paginate the pages and a bit of clever maths in PHP to make it work together.

    If someone does come across a solution for accessing response headers via the API I would really appreciate it.

    To give some context, I have built an Admin Site for collecting and combining data, orders to be processed, sales reports and other useful bits from multiple Woocommerce stores into one easy to use platform.

    The pagination was a bit slow so I wanted to cut out some of the math and extra code… Anyway…

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘API Response Headers’ is closed to new replies.