kloon / WooCommerce-REST-API-Client-Library

A PHP wrapper for the WooCommerce REST API
GNU General Public License v3.0
356 stars 175 forks source link

How to get all orders together? #222

Open ddhara opened 7 years ago

ddhara commented 7 years ago

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

?>
Robert-Held commented 7 years ago

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

itzRamkumar commented 6 years ago

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