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