WC_API_Customers::get_customers_count()publicWC 2.1

Get the total number of customers

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

Хуков нет.

Возвращает

Массив|WP_Error.

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

$WC_API_Customers = new WC_API_Customers();
$WC_API_Customers->get_customers_count( $filter );
$filter(массив)
-
По умолчанию: array()

Список изменений

С версии 2.1 Введена.

Код WC_API_Customers::get_customers_count() WC 8.7.0

public function get_customers_count( $filter = array() ) {
	try {
		if ( ! current_user_can( 'list_users' ) ) {
			throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_customers_count', __( 'You do not have permission to read the customers count', 'woocommerce' ), 401 );
		}

		$query = $this->query_customers( $filter );

		return array( 'count' => $query->get_total() );
	} catch ( WC_API_Exception $e ) {
		return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
	}
}