WC_Order::update_status( string $new_status, string $note = '', bool $manual = false )

Updates status of order immediately.


Description Description


Parameters Parameters

$new_status

(Required) Status to change the order to. No internal wc- prefix is required.

$note

(Optional) note to add.

Default value: ''

$manual

(Optional) Is this a manual order status change?.

Default value: false


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/class-wc-order.php

	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;
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.