如何在woocommerce API中设置状态顺序

时间:2016-11-03 02:30:51

标签: php wordpress rest api woocommerce

我有一些问题,我想在创建订单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 V2kloon/WooCommerce-REST-API-Client-Library

我该怎么办?有人帮我解决我的问题?

1 个答案:

答案 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

中看到更多示例