0

I am looking for a way to update order status with rest api (php) based on order ID.

I tried several things from the doc (well at least, I have found below code Without success)

    $data = array(
        "entity" => array(
            'entity_id'=>'000000159',
            'status'=>'pending2'
        )
    );

$retour = $this->api->put("orders",$data );

How can I accomplish this.

1
  • 1
    'entity_id'=>'000000159' it's not entity_id but real_order_id – Adrian Szulc Oct 9 '17 at 16:09
0
$entity_id = 955;
$request_url='http://example.com/rest/V1/orders';
$data_json = [
    "entity"=> [
        "entity_id" => $entity_id,
        "state" => "processing",
        "status" => "Processing"
    ]
];
$data_string = json_encode($data_json);
$ch = curl_init($request_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Authorization: Bearer '.json_decode($token),
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
);
$response = curl_exec($ch);
$response =  json_decode($response);
print_r($response);
curl_close($ch);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.