APSB
APSB

Reputation: 587

How to set status order in woocommerce API

i have something problem in there i want to make my status order when i create an order is on-hold because in default is processing so i try make like this :

$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),
        )
    );

but its doesnt work, iam using woocommerce V2 and kloon/WooCommerce-REST-API-Client-Library

what should i do ? have someone help me to solve my problem ?

Upvotes: 2

Views: 1659

Answers (1)

Khorshed Alam
Khorshed Alam

Reputation: 2708

If you know the order_id then you can simply do something like this.

$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' )

You can see more example there https://github.com/kloon/WooCommerce-REST-API-Client-Library/blob/master/example/example.php#L50

Upvotes: 2

Related Questions