Automattic\WooCommerce\Internal\Admin\Orders

ListTable::get_views()publicWC 1.0

Get the list of views for this table (all orders, completed orders, etc, each with a count of the number of corresponding orders).

{} Это метод класса: ListTable{}

Хуков нет.

Возвращает

Массив.

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

$ListTable = new ListTable();
$ListTable->get_views();

Код ListTable::get_views() WC 6.8.0

public function get_views() {
	$view_counts = array();
	$view_links  = array();
	$statuses    = wc_get_order_statuses();
	$current     = isset( $_GET['status'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['status'] ?? '' ) ) : 'all';

	foreach ( $statuses as $slug => $name ) {
		$total_in_status = $this->count_orders_by_status( $slug );

		if ( $total_in_status > 0 ) {
			$view_counts[ $slug ] = $total_in_status;
		}
	}

	$all_count         = array_sum( $view_counts );
	$view_links['all'] = $this->get_view_link( 'all', __( 'All', 'woocommerce' ), $all_count, 'all' === $current );

	foreach ( $view_counts as $slug => $count ) {
		$view_links[ $slug ] = $this->get_view_link( $slug, $statuses[ $slug ], $count, $slug === $current );
	}

	return $view_links;
}