WooCommerce-REST-API-Client-Library icon indicating copy to clipboard operation
WooCommerce-REST-API-Client-Library copied to clipboard

How to get all orders together?

Open ddhara opened this issue 8 years ago • 2 comments

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 ] );

?>

ddhara avatar May 24 '17 12:05 ddhara

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' ) );

Robert-Held avatar May 28 '17 16:05 Robert-Held

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') );

itzRamkumar avatar Jan 04 '18 10:01 itzRamkumar