我有一些问题,我想在创建订单on-hold
时创建状态订单,因为默认情况下是processing
所以我尝试这样做:
$data = array(
'order' => array(
'status' => 'on-hold',
'payment_details' => array(
'method_id' => 'bacs',
'method_title' => $a['method'],
'paid' => true
),
'billing_address' => array(
'first_name' => $a['nama'],
'last_name' => $a['last'],
'address_1' => $a['address_1'],
'address_2' => $a['address_2'],
'city' => $a['city'],
'state' => $a['state'],
'postcode' => $a['postcode'],
'country' => $a['country'],
'email' => $a['email'],
'phone' => $a['phone']
),
'shipping_address' => array(
'first_name' => $a['nama'],
'last_name' => $a['last'],
'address_1' => $a['address_1'],
'address_2' => $a['address_2'],
'city' => $a['city'],
'state' => $a['state'],
'postcode' => $a['postcode'],
'country' => $a['country']
),
'customer_id' => $a['customer_id'],
'line_items' => json_decode($a['testing'], true),
)
);
但它不起作用,我使用woocommerce V2和kloon/WooCommerce-REST-API-Client-Library
我该怎么办?有人帮我解决我的问题?
答案 0 :(得分:2)
如果您知道order_id
,那么您可以简单地执行此类操作。
$client = new WC_API_Client( 'http://your-store-url.com', 'ck_enter_your_consumer_key', 'cs_enter_your_consumer_secret', $options );
$client->orders->update_status( $order_id, 'on-hold' )
您可以在https://github.com/kloon/WooCommerce-REST-API-Client-Library/blob/master/example/example.php#L50
中看到更多示例