Fulfill an order its not working 2023-07 PHP

Topic summary

A developer is encountering a 404 error when attempting to fulfill Shopify orders using PHP and the Shopify API.

Initial Approach:

  • Originally used a direct POST request to the /orders/{order_id}/fulfillments.json endpoint with Guzzle HTTP client
  • Included tracking information and location ID in the request

Current Issue:

  • Switched to using the PHPShopify SDK and FulfillmentOrder API
  • The new method fails specifically when orders contain deleted items
  • Code retrieves fulfillment order ID and attempts to post fulfillment with tracking details

Status:

  • One user suggested using fulfillmentId and GraphQL implementation instead
  • Another developer reported experiencing the exact same problem
  • No working solution has been identified yet
  • The discussion remains open with the core issue unresolved: handling fulfillments for orders with deleted line items
Summarized with AI on November 15. AI used: claude-sonnet-4-5-20250929.

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_url’ => ‘https://www.starken.cl/seguimiento’,
‘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,
“url” => “https://www.starken.cl/seguimiento
];
echo"

“;
print_r($fulfillment);
echo”
";

$fulfillment->save(
true, // Update Object
);

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…

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”,
‘url’ => “https://www.starken.cl/seguimiento”,
],
‘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”;
}
}

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

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