WC_Order::set_status()publicWC 3.0.0

Set order status.

Method of the class: WC_Order{}

Hooks from the method

Return

Array.

Usage

$WC_Order = new WC_Order();
$WC_Order->set_status( $new_status, $note, $manual_update );
$new_status(string) (required)
Status to change the order to. No internal wc- prefix is required.
$note(string)
Optional note to add.
Default: ''
$manual_update(true|false)
Is this a manual order status change?.
Default: false

Changelog

Since 3.0.0 Introduced.

WC_Order::set_status() code WC 8.6.1

public function set_status( $new_status, $note = '', $manual_update = false ) {
	$result = parent::set_status( $new_status );

	if ( true === $this->object_read && ! empty( $result['from'] ) && $result['from'] !== $result['to'] ) {
		$this->status_transition = array(
			'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $result['from'],
			'to'     => $result['to'],
			'note'   => $note,
			'manual' => (bool) $manual_update,
		);

		if ( $manual_update ) {
			do_action( 'woocommerce_order_edit_status', $this->get_id(), $result['to'] );
		}

		$this->maybe_set_date_paid();
		$this->maybe_set_date_completed();
	}

	return $result;
}