Closed simofacc closed 7 years ago
HI @simofacc
Currently this is not possible because it's not implemented.
You can paginate by page like this
$params = [
'per_page' => 20,
'page' => 1
];
Woocommerce::get('orders', $params);
I will implement the getRequest()
and getResponse()
methods until the end of the week so you can request the X-WP-Total
and X-WP-TotalPages
headers like this
Woocommerce::get('orders');
$total = Woocommerce::getResponse()->getHeaders()['X-WP-Total'];
$totalPages = Woocommerce::getResponse()->getHeaders()['X-WP-TotalPages'];
Now you can get the last page of your result like this
$params = [
'per_page' => 20,
'page' => $totalPages
];
Woocommerce::get('orders', $params);
To wrap this in a Laravel-style-like API will take some more time ;-)
Thanks for pointing this out. Useful feature I will add to this library so it will stay functional
In the new release v2.3.0 pagination is now available. https://github.com/pixelpeter/laravel5-woocommerce-api-client/releases/tag/v2.3.0
For detailed usage instructions please have a look at the README https://github.com/pixelpeter/laravel5-woocommerce-api-client#pagination
Hi,
How is it possible to get the response headers after using
Woocommerce::get('orders')
I need to get the pagination Link header information to show next and previous buttons.
Thanks!