WordPress at Your Fingertips
function is not described

WC_Abstract_Order::set_status() public WC 3.0.0

Set order status.

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

No Hooks.

Return

Array. details of change

Usage

$WC_Abstract_Order = new WC_Abstract_Order();
$WC_Abstract_Order->set_status( $new_status );
$new_status(string) (required)
Status to change the order to. No internal wc- prefix is required.

Changelog

Since 3.0.0 Introduced.

Code of WC_Abstract_Order::set_status() WC 5.8.0

public function set_status( $new_status ) {
	$old_status = $this->get_status();
	$new_status = 'wc-' === substr( $new_status, 0, 3 ) ? substr( $new_status, 3 ) : $new_status;

	// If setting the status, ensure it's set to a valid status.
	if ( true === $this->object_read ) {
		// Only allow valid new status.
		if ( ! in_array( 'wc-' . $new_status, $this->get_valid_statuses(), true ) && 'trash' !== $new_status ) {
			$new_status = 'pending';
		}

		// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
		if ( $old_status && ! in_array( 'wc-' . $old_status, $this->get_valid_statuses(), true ) && 'trash' !== $old_status ) {
			$old_status = 'pending';
		}
	}

	$this->set_prop( 'status', $new_status );

	return array(
		'from' => $old_status,
		'to'   => $new_status,
	);
}