Update order fulfillment details using shopify API

Update order fulfillment details using shopify API

naveenkumarp
Visitor
2 0 0

I'm a newbie to shopify. I'm trying to update the tracking info back to shopify store using fulfillment api but it seems like it isn't making a connection somewhere. Any help would be appreciated.

Here is my function:

public function AddTrackingDetailsBackToShopify($ShopifyOrderNo,$FulfilmentArray)
{

$postArray = json_encode($FulfilmentArray);
$url = 'https://'.SHOPIFY_APP_API_KEY.':'.SHOPIFY_APP_PASSWORD.'@'.SHOPIFY_SHOP_URL.'/admin/api/'.$this->getYear().'/orders/'.$ShopifyOrderNo.'/fulfillments.json';
try {
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postArray);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$headers = [
"accept: application/json",
"content-type: application/json",
"Access-Control-Allow-Methods: POST, GET, OPTIONS"
];
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($curl);
if ($result === FALSE) {
echo "Result is False";
$error = "cURL Error: " . curl_error($curl);
echo $error;
} else {
echo "Result is True";
$final_order = json_decode($result);
echo "<pre>";
print_r($final_order);
echo "</pre>";
}
curl_close($curl);
} catch (Exception $e) {
echo "In catch Section";
$error = $e->getMessage();
print_r($error);
}

}

 

 

Here is my fulfillment array that I'm passing:

Array
(
[fulfillment] => Array
(
[location_id] => XXXXXXX
[tracking_url] => https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=XXXXXXXXX
[tracking_number] => XXXXXXXXX
[tracking_company] => Fedex
[notify_customer] => 1
)

)

 

I tried even sending the item_id

Replies 0 (0)