Reputation: 3520
I am trying to create a fulfillment for an order using the API, and this fulfillment should include a tracking number. I am passing the tracking number with the request, and the request appears successful (the order is correctly fulfilled in the admin). However, the tracking number I pass is never present.
I am not including line items (to fulfill all items in the order), though I have tried it both ways (fulfilling one item at a time)
//$id, $key and $password are set previously
$endpoint = "https://{$key}:{$password}@mystore.shopify.com/admin/orders/{$id}/fulfillments.json";
$fulfillment = array(
'fulfillment' => array(
'tracking_number' => '12345'
)
);
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fulfillment));
res = curl_exec($ch);
After running the above code, $res contains something similar to this:
{"fulfillment":{"created_at":"2012-10-22T16:57:53-04:00","id":69428396,"order_id":143675378,"service":"manual","status":"success","tracking_company":null,"tracking_number":null,"tracking_url":"http://www.google.com/search?q=","updated_at":"2012-10-22T16:57:53-04:00","receipt":{},"line_items":[{"fulfillment_service":"manual","fulfillment_status":"fulfilled","grams":0,"id":233975006,"price":"19.00","product_id":108718266,"quantity":1,"requires_shipping":true,"sku":"","title":"Profound grid-enabled intranet","variant_id":248446746,"variant_title":null,"vendor":"Shopify","name":"Profound grid-enabled intranet","variant_inventory_management":null,"properties":[]},{"fulfillment_service":"manual","fulfillment_status":"fulfilled","grams":0,"id":233975008,"price":"19.00","product_id":108718276,"quantity":2,"requires_shipping":true,"sku":"","title":"Operative multi-tasking task-force","variant_id":248446754,"variant_title":null,"vendor":"Shopify","name":"Operative multi-tasking task-force","variant_inventory_management":null,"properties":[]}]}}
You can see in that response, the line items have fulfillment status set to fulfilled (correct) but tracking_number is null (incorrect).
Any help is greatly appreciated!
Upvotes: 1
Views: 436
Reputation: 176
Need to specify content type for the request.
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json');
Upvotes: 1