How to get all orders together?
Getting only 10 orders at a time. How can I get all the orders together? I am using below code:
<?php
require_once( 'lib/woocommerce-api.php' );
$options = array(
'debug' => true,
'return_as_array' => false,
'validate_url' => false,
'timeout' => 30,
'ssl_verify' => false,
);
try {
$client = new WC_API_Client( 'https://your-store-url.com', 'ck_enter_your_consumer_key', 'cs_enter_your_consumer_secret', $options );
$data = $client->orders->get( null, [ 'per_page' => 100 ] );
?>
You can do that by setting the limit filter like so: $data = $client->orders->get( NULL , array ( 'filter[limit]' => 100 ) );
Or, if you want to work with date intervals you can, for example, use the updated_at_min and updated_at_max filters: $data = $client->orders->get( NULL , array( 'filter[updated_at_min]' => '2016-01-01' , 'filter[updated_at_max]' => '2017-01-01' ) );
You can use this to get all the orders in the filter criteria without paging.
$result = $client->orders->get('', array('filter[limit]' => '-1' , 'status' => 'Processing' , 'filter[created_at_min]' => '2016-01-01' , 'filter[created_at_max]' =>'2017-01-01') );