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{}

No Hooks.

Return

Array.

Usage

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

Code of ListTable::get_views() WC 7.1.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';

	// Add 'draft' and 'trash' to list.
	foreach ( array( 'draft', 'trash' ) as $wp_status ) {
		$statuses[ $wp_status ] = ( get_post_status_object( $wp_status ) )->label;
	}

	$statuses_in_list = array_intersect( array_keys( $statuses ), get_post_stati( array( 'show_in_admin_status_list' => true ) ) );

	foreach ( $statuses_in_list as $slug ) {
		$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, '' === $current || 'all' === $current );

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

	return $view_links;
}