FROM CACHE - fr_header

Getting a blank response from Shopify while adding fulfilment to order using Php

Getting a blank response from Shopify while adding fulfilment to order using Php

Cosmekarn
Shopify Partner
4 0 0

I am using the code below to create fullfilment for orders in Shopify this code was working correctly till last weeks sudenly it stops working I have tried many solution but nothing is clear since the response is always BLANK.

 

$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);
// $result_shopify = json_decode(trim($response_shopify),true);
// print_r( "<br/>response: ".$response_shopify);
// print_r( "<br/>fulfillment: ".$result_shopify['fulfillment']);
// print_r ("<br/>errors: ".$result_shopify['errors']['base']);
// $fulfillment = $result['fulfillment'];
$resp_array = json_decode(trim($response_shopify), TRUE);
echo("*************************");
print_r($response_shopify);
$fulfillment = strval($resp_array['fulfillment']['status']);
// print_r("fulfillment: ".$fulfillment);
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;
}


$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);
// $result_shopify = json_decode(trim($response_shopify),true);
// print_r( "<br/>response: ".$response_shopify);
// print_r( "<br/>fulfillment: ".$result_shopify['fulfillment']);
// print_r ("<br/>errors: ".$result_shopify['errors']['base']);
// $fulfillment = $result['fulfillment'];
$resp_array = json_decode(trim($response_shopify), TRUE);
echo("*************************");
print_r($response_shopify);
$fulfillment = strval($resp_array['fulfillment']['status']);
// print_r("fulfillment: ".$fulfillment);
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;
}
0 RÉPONSES 0