How to fetch all orders together in woocommerce using WooCommerce REST API PHP Client Library

Using WooCommerce REST API PHP Client Library to manage external order system. The code am using is as below:

<?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();

?>

This code returning only 10 orders but I need all the records together as I want to show it in bootstrap datatable. I have searched and got one solution from here

$client->get_orders( array( 'filter[limit]' => 50 ) );

but it’s generating error

Call to undefined method WC_API_Client::get_orders()

Why get_orders() is undefined? what is the difference between get_orders() and orders->get()?

Read more here: How to fetch all orders together in woocommerce using WooCommerce REST API PHP Client Library

Leave a Reply

Your email address will not be published. Required fields are marked *