WordPress at a glance
function is not described

WC_REST_Legacy_Orders_Controller::update_order() protected WC 1.0

Deprecated from version 3.0.0. It is no longer supported and can be removed in future releases. It is recommended to replace this function with the same one.

Update order.

{} It's a method of the class: WC_REST_Legacy_Orders_Controller{}

No Hooks.

Return

Int|WP_Error.

Usage

// protected - for code of main (parent) or child class
$result = $this->update_order( $request );
$request(WP_REST_Request) (required)
Full details about the request.

Changelog

Deprecated 3.0.0

Code of WC_REST_Legacy_Orders_Controller::update_order() WC 5.0.0

<?php
protected function update_order( $request ) {
	try {
		$order = $this->prepare_item_for_database( $request );
		$order->save();

		// Handle set paid.
		if ( $order->needs_payment() && true === $request['set_paid'] ) {
			$order->payment_complete( $request['transaction_id'] );
		}

		// If items have changed, recalculate order totals.
		if ( isset( $request['billing'] ) || isset( $request['shipping'] ) || isset( $request['line_items'] ) || isset( $request['shipping_lines'] ) || isset( $request['fee_lines'] ) || isset( $request['coupon_lines'] ) ) {
			$order->calculate_totals();
		}

		return $order->get_id();
	} catch ( WC_Data_Exception $e ) {
		return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
	} catch ( WC_REST_Exception $e ) {
		return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
	}
}