2015-01-13 1 views
2

동료를위한 웹 응용 프로그램을 개발 중이므로 주문을 패키지화하기 위해 응용 프로그램이있는 iPad가 있습니다.업데이트 순서 WooCommerce API PHP CURL

전체 응용 프로그램은 거의 마지막 단계 중 하나가을 완료처리에서 주문 상태를 변경하는 것입니다, 완료됩니다. 내가 뭘 어떻게

:

현재 주문 ID를 취득 후 컬 또는 API를 사용하여 상태를 변경합니다. 무슨 일이 발생하는지는 매우 이상합니다. JSON 데이터를 다시 가져오고 completed_at 시간을 업데이트했지만 상태는 여전히 처리 중입니다. 내가 잘못 보시는

$data = array("status" => "completed");                  
$data_string = json_encode($data);                     

$username = 'XXX'; // Add your own Consumer Key here 
$password = 'XXX'; // Add your own Consumer Secret here 

$ch = curl_init('https://www.deallerleukste.nl/wc-api/v2/orders/5764?consumer_key='.$username.'&consumer_secret='.$password); 
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);         
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                  
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);                  
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                   
    'Content-Type: application/json',                     
    'Content-Length: ' . strlen($data_string))                  
);                             

$result = curl_exec($ch); 

echo $result; 

사람 : 당신이 다음

내 코드를 볼 것인가? 도와주세요!

감사합니다,

Jelmer

답변

0

동적으로 $ 상태에서

$data=json_encode(array('order' => array('status' => $status))); 

당신이 상태를 전달할 수 있습니다이 코드

$data='{ "order": { "status": "completed" }}'; 

또는

를 사용해보십시오 너를 원해.