WC_Abstract_Order::set_status()
Set order status.
Метод класса: WC_Abstract_Order{}
Хуков нет.
Возвращает
Массив
. details of change
Использование
$WC_Abstract_Order = new WC_Abstract_Order(); $WC_Abstract_Order->set_status( $new_status );
- $new_status(строка) (обязательный)
- Status to change the order to. No internal wc- prefix is required.
Список изменений
С версии 3.0.0 | Введена. |
Код WC_Abstract_Order::set_status() WC Abstract Order::set status WC 9.7.1
public function set_status( $new_status ) { $old_status = $this->get_status(); $new_status = OrderUtil::remove_status_prefix( $new_status ); $status_exceptions = array( OrderStatus::AUTO_DRAFT, OrderStatus::TRASH ); // 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 ) && ! in_array( $new_status, $status_exceptions, true ) ) { $new_status = OrderStatus::PENDING; } // If the old status is set but unknown (e.g. draft) assume its pending for action usage. if ( $old_status && ( OrderStatus::AUTO_DRAFT === $old_status || ( ! in_array( 'wc-' . $old_status, $this->get_valid_statuses(), true ) && ! in_array( $old_status, $status_exceptions, true ) ) ) ) { $old_status = OrderStatus::PENDING; } } $this->set_prop( 'status', $new_status ); return array( 'from' => $old_status, 'to' => $new_status, ); }