WC_API_Products::get_products_count() public WC 2.1
Get the total number of orders
{} It's a method of the class: WC_API_Products{}
No Hooks.
Return
Array|WP_Error.
Usage
$WC_API_Products = new WC_API_Products(); $WC_API_Products->get_products_count( $type, $filter );
- $type(string)
- -
- $filter(array)
- -
Changelog
Since 2.1 | Introduced. |
Code of WC_API_Products::get_products_count() WC API Products::get products count WC 5.0.0
public function get_products_count( $type = null, $filter = array() ) {
if ( ! empty( $type ) ) {
$filter['type'] = $type;
}
if ( ! current_user_can( 'read_private_products' ) ) {
return new WP_Error( 'woocommerce_api_user_cannot_read_products_count', __( 'You do not have permission to read the products count', 'woocommerce' ), array( 'status' => 401 ) );
}
$query = $this->query_products( $filter );
return array( 'count' => (int) $query->found_posts );
}