此主题已经发布了一个问题,但没有一个对我有用的答案。 Bigcommerce PHP API - No data returned
我可以从我的PHP代码连接到在线商店,但GetOrders()返回一个空数组 json_encode为我提供[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}, {},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{} {},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{ },{}]
getOrdersCount()返回47317,所以我知道那里有订单。
有什么想法吗?
感谢。这是我的代码:
<?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;
}
?>
答案 0 :(得分:0)
您的问题是“名称”和“价格”不是属于订单的字段。这就是它返回数据的原因。对于每个订单,它回显空(不存在)字段,
而是尝试:
$orders = Bigcommerce::getOrders();
foreach($orders as $order) {
echo $order->id;
echo $order->total_inc_tax;
}