Shopify API按名称或order_number获取订单

时间:2015-04-29 16:47:52

标签: api cakephp shopify restful-url

我使用 CakePHP 的插件进行调用以获取某些订单。我可以用某些字段调用所有订单,但我想知道如何调用以获取具有特定名称或order_number的订单?以下是 Shopify 调用的来源。它已经过验证和所有内容:

public function call($method, $path, $params=array())
    {
        if (!$this->isAuthorized())
            return;
        $password = $this->is_private_app ? $this->secret : md5($this->secret.$this->ShopifyAuth->token);
        $baseurl = "https://{$this->api_key}:$password@{$this->ShopifyAuth->shop_domain}/";

        $url = $baseurl.ltrim($path, '/');
        $query = in_array($method, array('GET','DELETE')) ? $params : array();
        $payload = in_array($method, array('POST','PUT')) ? stripslashes(json_encode($params)) : array();
    $request_headers = in_array($method, array('POST','PUT')) ? array("Content-Type: application/json; charset=utf-8", 'Expect:') : array();
    $request_headers[] = 'X-Shopify-Access-Token: ' . $this->ShopifyAuth->token;
        list($response_body, $response_headers) = $this->Curl->HttpRequest($method, $url, $query, $payload, $request_headers);
    $this->last_response_headers = $response_headers;
    $response = json_decode($response_body, true);

        if (isset($response['errors']) or ($this->last_response_headers['http_status_code'] >= 400))
            throw new ShopifyApiException($method, $path, $params, $this->last_response_headers, $response);

        return (is_array($response) and (count($response) > 0)) ? array_shift($response) : $response;
    }

    private function shopApiCallLimitParam($index)
    {
        if ($this->last_response_headers == null)
        {
            return 0;
        }
        $params = explode('/', $this->last_response_headers['http_x_shopify_shop_api_call_limit']);
        return (int) $params[$index];
    }

...以及进行GET调用的代码:

// I only want the id and title of the collections
            $fields = "fields=name,id,status,financial_status,fulfillment_status,billing_address,customer";
            // get list of collections
            $custom_collections = $this->ShopifyAPI->call('GET', "/admin/orders.json", $fields);
            $this->set('collections', $custom_collections);

我想我错过了我可以为通话设定条件以获得某些订单的地方。我已经阅读过API文档,但似乎无法得到答案。

我已尝试在?name=%231001之后将.json放在网址上以尝试获取#1001 的订单,但它会返回一个空数组。

然后我尝试了?order_number = 1001 但是它给我带来了每个订单以及1001 D:这真的令人困惑,有人能帮帮我吗?

提前致谢。

0 个答案:

没有答案