From a74efe61a9d5b74099110f89e0225c9aa64ca34a Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 5 Jan 2015 16:40:27 -0200 Subject: [PATCH] [API] dont count coupons if the user dont have permissions --- includes/api/class-wc-api-coupons.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/includes/api/class-wc-api-coupons.php b/includes/api/class-wc-api-coupons.php index 791cd181242..b53aea7c98d 100644 --- a/includes/api/class-wc-api-coupons.php +++ b/includes/api/class-wc-api-coupons.php @@ -156,14 +156,13 @@ class WC_API_Coupons extends WC_API_Resource { * @return array */ public function get_coupons_count( $filter = array() ) { - try { - $query = $this->query_coupons( $filter ); - if ( ! current_user_can( 'read_private_shop_coupons' ) ) { throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_coupons_count', __( 'You do not have permission to read the coupons count', 'woocommerce' ), 401 ); } + $query = $this->query_coupons( $filter ); + return array( 'count' => (int) $query->found_posts ); } catch ( WC_API_Exception $e ) { return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );