Fulfill an order its not working 2023-07 PHP

Fulfill an order its not working 2023-07 PHP

kahmra
Tourist
9 0 2

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
16343 2438 3177

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...

Hire us | Pass Core Web Vital | B2B Wholesale Experts | Claim Your Free Website Review |
Connect with Us: WhatsApp | Skype: oscprofessionals-87 | Email: pallavi@oscprofessionals.com |
Custom Shopify SolutionsPrivate Apps, Theme Customization & SEO | Digital Marketing |
OSCP Apps: Discount Suite | Wholesale App | Bundle & Upsell | Shipping Discount | and more...
kahmra
Tourist
9 0 2

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 2

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