Automattic\WooCommerce\Blocks\Domain\Services

DraftOrders::delete_draft_order_post_status_from_args()publicWC 1.0

Remove draft status from the 'status' argument of an $args array.

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

Хуков нет.

Возвращает

Массив.

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

$DraftOrders = new DraftOrders();
$DraftOrders->delete_draft_order_post_status_from_args( $args );
$args(массив) (обязательный)
Array of arguments containing statuses in the status key.

Код DraftOrders::delete_draft_order_post_status_from_args() WC 8.7.0

public function delete_draft_order_post_status_from_args( $args ) {
	if ( ! array_key_exists( 'status', $args ) ) {
		$statuses = [];
		foreach ( wc_get_order_statuses() as $key => $label ) {
			if ( self::DB_STATUS !== $key ) {
				$statuses[] = str_replace( 'wc-', '', $key );
			}
		}
		$args['status'] = $statuses;
	} elseif ( self::DB_STATUS === $args['status'] ) {
		$args['status'] = '';
	} elseif ( is_array( $args['status'] ) ) {
		$args['status'] = array_diff_key( $args['status'], array( self::STATUS => null ) );
	}

	return $args;
}