WC_Order::set_status( string $new_status, string $note = '', bool $manual_update = false )

Set order status.


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_update

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

Default value: false


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/class-wc-order.php

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

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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