Fulfill an order its not working 2023-07 PHP

kahmra
Tourist
9 0 1

Hi! i have this function on PHP

 

function fulfill_order_by_id($order_id,$tracking_number){
$url=shopi_api_url().'orders/'.$order_id.'/fulfillments.json';
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', $url,['form_params' => [
'fulfillment'=> [
'location_id' =>'63110676671',
'notify_customer' => 'true',
'tracking_company' => 'Other',
'tracking_number' => $tracking_number ]]]);
$json_body = json_decode($response->getBody(),true);
return $json_body;
}
 
and  is giving me 404 error i try evertyng but nothing works and i dont find any info.
 
this is what i try now and save not exists
 
$fulfillment = $shopify->Fulfillment();
/*$fulfillment->update_tracking([], // Params
["fulfillment" => [, "tracking_info" => ["company" => "Other", */
 
$fulfillment->line_items_by_fulfillment_order  = [
"location_id"=> "63110676671",
"order_id"=> $order_id,
"notify_customer" => true
];
$fulfillment->tracking_info = [
"company" => "Other",
"number" => $tracking_number,
];
echo"<pre>";
print_r($fulfillment);
echo"</pre>";
 
$fulfillment->save(
true, // Update Object
);
 
 
Replies 4 (4)

oscprofessional
Shopify Partner
15905 2378 3087

Hi @kahmra,

You need to use fulfillmentId to update the status of fulfill an order. And this fulfillmentId you can get by orderID. I have implemented this using graphQL.

If you need more suggestions please feel free to ask.

 

Thanks...

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: pallavi@oscprofessionals.com | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free
kahmra
Tourist
9 0 1

hi! im ussing this method now.

but this not works if the order have a delete item

function fulfill_order_by_id($order_id,$tracking_number){
$config=connection();
$shopify = new PHPShopify\ShopifySDK($config);
$list = $shopify->Order($order_id)->FulfillmentOrder()->get();
$fulfillmentorder_id = $list[0]['id'];
try{
$params = array(
                'notify_customer'=> true,
                'tracking_info' => [
                    'number' => $tracking_number,
                    'company' => "Other",
                ],
                'line_items_by_fulfillment_order' => [
                        array('fulfillment_order_id' => $fulfillmentorder_id)
                ]
            );
 
$ret = $shopify->Fulfillment()->post($params);
}catch(Exception $e) {
echo 'Caught exception ' .  $e->getMessage(), "\n";
}
}
jmfieldapi
New Member
5 0 0

did you ever find a solution here? I am having the exact same problem?

kahmra
Tourist
9 0 1

nop 😞 im fullfit orders handly if they have a delete product.