WC_Order::update_status()publicWC 1.0

Updates status of order immediately.

Метод класса: WC_Order{}

Хуков нет.

Возвращает

true|false.

Использование

$WC_Order = new WC_Order();
$WC_Order->update_status( $new_status, $note, $manual );
$new_status(строка) (обязательный)
Status to change the order to. No internal wc- prefix is required.
$note(строка)
Optional note to add.
По умолчанию: ''
$manual(true|false)
Is this a manual order status change?.
По умолчанию: false

Код WC_Order::update_status() WC 9.3.3

public function update_status( $new_status, $note = '', $manual = false ) {
	if ( ! $this->get_id() ) { // Order must exist.
		return false;
	}

	try {
		$this->set_status( $new_status, $note, $manual );
		$this->save();
	} catch ( Exception $e ) {
		$logger = wc_get_logger();
		$logger->error(
			sprintf(
				'Error updating status for order #%d',
				$this->get_id()
			),
			array(
				'order' => $this,
				'error' => $e,
			)
		);
		$this->add_order_note( __( 'Update status event failed.', 'woocommerce' ) . ' ' . $e->getMessage() );
		return false;
	}
	return true;
}