phpclassic / php-shopify

PHP SDK for Shopify API
Apache License 2.0
571 stars 210 forks source link

Get fulfilled orders #316

Open kahmra opened 10 months ago

kahmra commented 10 months ago

! I'm trying to get all the fulfilled orders, for that I created this function:

public function getOrders($status = null, $financialStatus = null, $since = null, $limit = 250)
{
    $shopify = $this->connectToShopify();

    if ($shopify) {
        $options['limit'] = $limit;

        if ($status !== null) {
            $options['status'] = $status;
        }

        if ($financialStatus !== null) {
            $options['financial_status'] = $financialStatus;
        }

        if ($since !== null) {
            $options['since_id'] = $since;
        }

        return $shopify->Order->get($options);
    } else {
        return [];
    }
}

If I pass 'closed' to the status variable, it retrieves both canceled and fulfilled orders, but I need only the shipped orders. For that, I created this second function:

public function getFulfilledOrders($status, $since = null, $limit = 250)
{
    $shopify = $this->connectToShopify();

    if ($shopify) {
        if ($status !== null) {
            $options['fulfillment_status'] = 'fulfilled';
        }

        return $shopify->Order->get($options);
    } else {
        return [];
    }
}

However, this function returns an empty array

Array ()

despite having more than 1000. What could be my mistake? Thank you!

aogg2023 commented 10 months ago

I have reviewed your question and have not used it before. I am currently unable to answer you,

Do you know the answer to my question?

How to obtain all orders for a store with over 250 orders? Currently, I can only obtain 250 orders

kahmra commented 10 months ago

Currently

$fulfilledOrders = $ShopifyConnection->fulfilledOrders($sinceId,250);
            foreach ($fulfilledOrders as $order) {
                $shopifyBatchProcessData->batchProcess("Orders",$order,"order");
            }
aogg2023 commented 10 months ago

现在

$fulfilledOrders = $ShopifyConnection->fulfilledOrders($sinceId,250);
          foreach ($fulfilledOrders as $order) {
              $shopifyBatchProcessData->batchProcess("Orders",$order,"order");
          }

Thank you.

aogg2023 commented 9 months ago

@kahmra Do you know how to obtain the required parameters for the next page page_info The value of info?