WC_Report_Customer_List::prepare_items()publicWC 1.0

Prepare customer list items.

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

Возвращает

null. Ничего (null).

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

$WC_Report_Customer_List = new WC_Report_Customer_List();
$WC_Report_Customer_List->prepare_items();

Код WC_Report_Customer_List::prepare_items() WC 9.4.2

public function prepare_items() {
	$current_page = absint( $this->get_pagenum() );
	$per_page     = 20;

	/**
	 * Init column headers.
	 */
	$this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() );

	add_action( 'pre_user_query', array( $this, 'order_by_last_name' ) );

	/**
	 * Get users.
	 */
	$admin_users = new WP_User_Query(
		array(
			'role'   => 'administrator',
			'fields' => 'ID',
		)
	);

	$manager_users = new WP_User_Query(
		array(
			'role'   => 'shop_manager',
			'fields' => 'ID',
		)
	);

	$query = new WP_User_Query(
		apply_filters(
			'woocommerce_admin_report_customer_list_user_query_args',
			array(
				'exclude' => array_merge( $admin_users->get_results(), $manager_users->get_results() ),
				'number'  => $per_page,
				'offset'  => ( $current_page - 1 ) * $per_page,
			)
		)
	);

	$this->items = $query->get_results();

	remove_action( 'pre_user_query', array( $this, 'order_by_last_name' ) );

	/**
	 * Pagination.
	 */
	$this->set_pagination_args(
		array(
			'total_items' => $query->total_users,
			'per_page'    => $per_page,
			'total_pages' => ceil( $query->total_users / $per_page ),
		)
	);
}