WC_API_Customers::get_customers_count()
Get the total number of customers
Method of the class: WC_API_Customers{}
No Hooks.
Return
Array|WP_Error
.
Usage
$WC_API_Customers = new WC_API_Customers(); $WC_API_Customers->get_customers_count( $filter );
- $filter(array)
- -
Default: array()
Changelog
Since 2.1 | Introduced. |
WC_API_Customers::get_customers_count() WC API Customers::get customers count code 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() ) ); } }