| @@ 148-156 (lines=9) @@ | ||
| 145 | * @param array $filter |
|
| 146 | * @return array |
|
| 147 | */ |
|
| 148 | public function get_coupons_count( $filter = array() ) { |
|
| 149 | ||
| 150 | $query = $this->query_coupons( $filter ); |
|
| 151 | ||
| 152 | if ( ! current_user_can( 'read_private_shop_coupons' ) ) |
|
| 153 | return new WP_Error( 'woocommerce_api_user_cannot_read_coupons_count', __( 'You do not have permission to read the coupons count', 'woocommerce' ), array( 'status' => 401 ) ); |
|
| 154 | ||
| 155 | return array( 'count' => (int) $query->found_posts ); |
|
| 156 | } |
|
| 157 | ||
| 158 | /** |
|
| 159 | * Get the coupon for the given code |
|
| @@ 190-198 (lines=9) @@ | ||
| 187 | * @param array $filter |
|
| 188 | * @return array |
|
| 189 | */ |
|
| 190 | public function get_customers_count( $filter = array() ) { |
|
| 191 | ||
| 192 | $query = $this->query_customers( $filter ); |
|
| 193 | ||
| 194 | if ( ! current_user_can( 'list_users' ) ) |
|
| 195 | return new WP_Error( 'woocommerce_api_user_cannot_read_customers_count', __( 'You do not have permission to read the customers count', 'woocommerce' ), array( 'status' => 401 ) ); |
|
| 196 | ||
| 197 | return array( 'count' => count( $query->get_results() ) ); |
|
| 198 | } |
|
| 199 | ||
| 200 | ||
| 201 | /** |
|