I am searching to run WooCommerce REST API with an Update. Its not a big issue to get data as json: https://www.example.com/wp-json/wc/v2/orders?consumer_key=ck_XXXXXXXXXXX&consumer_secret=cs_XXXXXXXXXXXX
But I am stuck at updating data and tried different approaches like:
<?php
$data = [
'status' => 'completed'
];
print_r($woocommerce->put('orders/727', $data));
?>
or
$updated_order = $wc_api->update_order( 247, array( 'status' => 'completed' ) );
print_r( $updated_order );
But nothing happens...
This is my full php-code I am using:
<?php
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'https://example.com',
'consumer_key',
'consumer_secret',
[
'wp_api' => true,
'version' => 'wc/v3'
]
);
?>
//JSON response example:
echo($woocommerce->get(''));
$updated_order = $wc_api->update_order( 247, array( 'status' => 'completed' ) );
print_r( $updated_order );
// the updated order object will be returned
?>
I assume there is a mistake I am addressing the API.