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).

Method of the class: ListTable{}

Return

Array.

Usage

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

ListTable::get_views() code WC 8.7.0

public function get_views() {
	$view_links = array();

	/**
	 * Filters the list of available list table view links before the actual query runs.
	 * This can be used to, e.g., remove counts from the links.
	 *
	 * @since 8.6.0
	 *
	 * @param string[] $views An array of available list table view links.
	 */
	$view_links = apply_filters( 'woocommerce_before_' . $this->order_type . '_list_table_view_links', $view_links );
	if ( ! empty( $view_links ) ) {
		return $view_links;
	}

	$view_counts = array();
	$statuses    = $this->get_visible_statuses();
	$current     = ! empty( $this->request['status'] ) ? sanitize_text_field( $this->request['status'] ) : 'all';
	$all_count   = 0;

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

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

		if ( ( get_post_status_object( $slug ) )->show_in_admin_all_list && 'auto-draft' !== $slug ) {
			$all_count += $total_in_status;
		}
	}

	$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;
}