I am trying to update the Order custom field value lworder
. I used the below code but I did not find any update. Can anyone please help me with this?
$api_response = wp_remote_post( 'https://your-website/wp-json/wc/v3/orders/{ORDER ID}', array(
//'method' => 'PUT',
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( 'KEY:SECRET' )
),
'meta_key' => array(
'lworder' => 'ordered',
)
) );
$body = json_decode( $api_response['body'] );
//print_r( $body );
if( wp_remote_retrieve_response_message( $api_response ) === 'OK' ) {
echo 'The Order field ' . $body->name . ' has been updated';
}
2
Answers
Tested OK with WooCommerce 6.1.1