I’m using the Using WooCommerce REST API PHP Client Library to manage an external order system. The code I 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 is only returning 10 orders, but I need all the records together as I want to show it in a datatable. I have searched and got one solution from here

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

but it’s generating the following error

Call to undefined method WC_API_Client::get_orders()

Why is 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 their REST API


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: