Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在WooCommerce API中获取所有客户订单_Php_Wordpress_Woocommerce_Php 5.5 - Fatal编程技术网

Php 在WooCommerce API中获取所有客户订单

Php 在WooCommerce API中获取所有客户订单,php,wordpress,woocommerce,php-5.5,Php,Wordpress,Woocommerce,Php 5.5,我正在使用WooCommerce API v2中的此端点尝试获取属于特定客户的所有订单 使用此库 我已经检查了网站的仪表板,还有待处理的订单 但我总是得到这样的回应:- [data] => Array ( ) [body] => [duration] => 1.36552 ) [response] => stdClass Object ( [body] => {"orders":[]} [code] => 200 [headers] => Array

我正在使用WooCommerce API v2中的此端点尝试获取属于特定客户的所有订单

使用此库

我已经检查了网站的仪表板,还有待处理的订单

但我总是得到这样的回应:-

[data] => Array ( ) [body] => [duration] => 1.36552 ) [response] => stdClass Object ( [body] => {"orders":[]} [code] => 200 [headers] => Array ( [Date] => Thu, 31 Mar 2016 07:37:35 GMT [Server] => Apache [X-Powered-By] => PHP/5.5.33 [Connection] => close [Transfer-Encoding] => chunked [Content-Type] => application/json; charset=UTF-8 ) ) ) )
API中的其他端点工作正常这是我的简单代码

<?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( 'http://localhost/store', $API_KEY, $API_SECRET, $options );

print_r($client->customers->get_orders($userId));

} catch ( WC_API_Client_Exception $e ) {
    echo $e->getMessage() . PHP_EOL;
    echo $e->getCode() . PHP_EOL;

    if ( $e instanceof WC_API_Client_HTTP_Exception ) {
        print_r( $e->get_request() );
        print_r( $e->get_response() );
    }
}

?>


我看不到任何地方定义了
$userId
,请尝试为
$userId
变量赋值,然后进行测试。我在完整的代码中赋值,我还尝试了使用phpmyadminI从数据库中获得的用户直接id。我刚刚在本地设置中测试了这一点,效果很好,我得到了属于特定客户的所有订单。未决订单是否也出现在API响应中?它返回的订单之一是
{“id”:701,“订单号”:701,“创建时间”:“2016-01-09T12:11:21Z”,“更新时间”:“2016-01-09T12:11:21Z”,“完成时间”:“2016-01-09T12:11:21Z”,“状态”:“未决”,…………
我看不到任何地方定义了
$userId
,请尝试为
$userId
变量赋值,然后进行测试。我在完整的代码中赋值,我还尝试了使用phpmyadminI从数据库中获取的用户直接id。我刚刚在本地设置中测试了这个值,效果很好,我得到了所有的ord属于特定客户的ers。未决订单是否也出现在API响应中?它返回的订单之一是
{“id”:701,“订单编号”:701,“创建时间”:“2016-01-09T12:11:21Z”,“更新时间”:“2016-01-09T12:11:21Z”,“完成时间”:“2016-01-09T12:11:21Z”,“状态”:“未决”…