WC_Admin_List_Table_Orders::query_filters()protectedWC 1.0

Handle any custom filters.

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

Хуков нет.

Возвращает

Массив.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->query_filters( $query_vars );
$query_vars(массив) (обязательный)
Query vars.

Код WC_Admin_List_Table_Orders::query_filters() WC 8.7.0

protected function query_filters( $query_vars ) {
	global $wp_post_statuses;

	// Filter the orders by the posted customer.
	if ( ! empty( $_GET['_customer_user'] ) ) { // WPCS: input var ok.
		// @codingStandardsIgnoreStart.
		$query_vars['meta_query'] = array(
			array(
				'key'     => '_customer_user',
				'value'   => (int) $_GET['_customer_user'], // WPCS: input var ok, sanitization ok.
				'compare' => '=',
			),
		);
		// @codingStandardsIgnoreEnd
	}

	// Sorting.
	if ( isset( $query_vars['orderby'] ) ) {
		if ( 'order_total' === $query_vars['orderby'] ) {
			// @codingStandardsIgnoreStart
			$query_vars = array_merge( $query_vars, array(
				'meta_key'  => '_order_total',
				'orderby'   => 'meta_value_num',
			) );
			// @codingStandardsIgnoreEnd
		}
	}

	// Status.
	if ( empty( $query_vars['post_status'] ) ) {
		$post_statuses = wc_get_order_statuses();

		foreach ( $post_statuses as $status => $value ) {
			if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
				unset( $post_statuses[ $status ] );
			}
		}

		$query_vars['post_status'] = array_keys( $post_statuses );
	}
	return $query_vars;
}