Hi everyone,
I’m trying to add tracking information to a paid fulfillment order using the Shopify API. I send a POST request to the fulfillment orders endpoint with the following payload and code. However, I don’t get any useful error message or response indicating success or failure.
Here is the code I use:
php
KopierenBearbeiten
$data = [
'fulfillment' => [
'message' => 'The package was shipped this morning.',
'notify_customer' => false,
'tracking_info' => [
'number' => '00340434467160030320',
'company' => 'DHL'
],
'line_items_by_fulfillment_order' => [[
'fulfillment_order_id' => 11708472918365,
'fulfillment_order_line_items' => [[
'id' => 34823647822173,
'quantity' => 1
]]
]]
]
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . '/fulfillments.json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Shopify-Access-Token: ' . $access_token,
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
$shopify_response = json_decode($response, true);
echo "<pre>";
print_r($shopify_response);
echo "</pre>";
I expect either a confirmation or an error message, but the response is either empty or unclear. Has anyone encountered this before or knows what might be missing?
Thanks in advance!
Would you like me to help you tweak the code or check for common pitfalls in this request?