I have been using the following code in Shopify to handle order fulfillment. It was functioning correctly until last week, but suddenly it stopped working. Despite attempting various solutions, the issue remains unresolved as the response I receive is always blank.
Here's the modified code:
$data = array(
"fulfillment" => array(
"tracking_number" => $tracking_id,
"location_id" => "56530665662",
"tracking_url" => "https://yalidine.com/suivre-un-colis/?tracking=".$tracking_id,
"tracking_company" => "Yalidine"
)
);
$data_string = json_encode($data);
$ch_shopify = curl_init('https://'.$shopify_api_key.':'.$shopify_api_password.'@'.$shop_name.'.myshopify.com/admin/orders/'.$order_id.'/fulfillments.json');
curl_setopt($ch_shopify, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch_shopify, CURLOPT_POST, 1);
curl_setopt($ch_shopify, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch_shopify, CURLOPT_RETURNTRANSFER, true);
$response_shopify = curl_exec($ch_shopify);
$resp_array = json_decode(trim($response_shopify), TRUE);
echo("*************************");
print_r($response_shopify);
$fulfillment = strval($resp_array['fulfillment']['status']);
if ($resp_array['errors']['base'][0] == "Line items are already fulfilled" || $fulfillment == "success") {
$_SESSION['response'] = $order_number;
header("Location: index.php");
exit();
} else {
$_SESSION['error'] = $resp_array;
echo "resp_array: ".$resp_array;
}
Please note that the value of resp_array is consistently blank.
I have attempted various adjustments, such as adding the API version, but the issue persists.
When testing the code on Postman, I received the following error: "{ "errors": { "fulfillment": "Required parameter missing or invalid" } }".