Abstract_WC_Order_Data_Store_CPT::get_post_status()protectedWC 3.6.0

Get the status to save to the post object.

Plugins extending the order classes can override this to change the stored status/add prefixes etc.

Метод класса: Abstract_WC_Order_Data_Store_CPT{}

Хуки из метода

Возвращает

Строку.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_post_status( $order );
$order(WC_order) (обязательный)
Order object.

Список изменений

С версии 3.6.0 Введена.

Код Abstract_WC_Order_Data_Store_CPT::get_post_status() WC 8.7.0

protected function get_post_status( $order ) {
	$order_status = $order->get_status( 'edit' );

	if ( ! $order_status ) {
		$order_status = apply_filters( 'woocommerce_default_order_status', 'pending' );
	}

	$post_status    = $order_status;
	$valid_statuses = get_post_stati();

	// Add a wc- prefix to the status, but exclude some core statuses which should not be prefixed.
	// @todo In the future this should only happen based on `wc_is_order_status`, but in order to
	// preserve back-compatibility this happens to all statuses except a select few. A doing_it_wrong
	// Notice will be needed here, followed by future removal.
	if ( ! in_array( $post_status, array( 'auto-draft', 'draft', 'trash' ), true ) && in_array( 'wc-' . $post_status, $valid_statuses, true ) ) {
		$post_status = 'wc-' . $post_status;
	}

	return $post_status;
}