Question

There is already a question posted on this topic, but no answer that works for me. Bigcommerce PHP API - No data returned

I can connect to the online store from my PHP code, but GetOrders() returns an empty array A json_encode gives me [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]

getOrdersCount() returns 47317, so I know there are orders in there.

Any ideas?

Thanks. Here's my code:

<?php
require '...../bigcommerce.php';
use Bigcommerce\Api\Client as Bigcommerce;

Bigcommerce::configure(array(
'store_url' => 'https://store-xxxx.mybigcommerce.com',
'username' => 'xxxxx',
'api_key' => 'xxxxx'
));
Bigcommerce::setCipher('RC4-SHA');
Bigcommerce::verifyPeer(false);   

$count = Bigcommerce::getOrdersCount();
echo 'number of orders:' . $count;

$orders = Bigcommerce::getOrders();

foreach($orders as $order) {
        echo $order->name;
        echo $order->price;
    }

?>
Was it helpful?

Solution

Your problem is that "name" and "price" are not fields that belong to orders. That is why it is returning that data. For each order it is echoing empty (non existent) fields,

Instead try:

$orders = Bigcommerce::getOrders();

foreach($orders as $order) {
    echo $order->id;
    echo $order->total_inc_tax;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top