| @@ 250-261 (lines=12) @@ | ||
| 247 | * @param array $filter |
|
| 248 | * @return array |
|
| 249 | */ |
|
| 250 | public function get_orders_count( $status = null, $filter = array() ) { |
|
| 251 | ||
| 252 | if ( ! empty( $status ) ) |
|
| 253 | $filter['status'] = $status; |
|
| 254 | ||
| 255 | $query = $this->query_orders( $filter ); |
|
| 256 | ||
| 257 | if ( ! current_user_can( 'read_private_shop_orders' ) ) |
|
| 258 | 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 ) ); |
|
| 259 | ||
| 260 | return array( 'count' => (int) $query->found_posts ); |
|
| 261 | } |
|
| 262 | ||
| 263 | /** |
|
| 264 | * Edit an order |
|
| @@ 137-148 (lines=12) @@ | ||
| 134 | * @param array $filter |
|
| 135 | * @return array |
|
| 136 | */ |
|
| 137 | public function get_products_count( $type = null, $filter = array() ) { |
|
| 138 | ||
| 139 | if ( ! empty( $type ) ) |
|
| 140 | $filter['type'] = $type; |
|
| 141 | ||
| 142 | if ( ! current_user_can( 'read_private_products' ) ) |
|
| 143 | 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 ) ); |
|
| 144 | ||
| 145 | $query = $this->query_products( $filter ); |
|
| 146 | ||
| 147 | return array( 'count' => (int) $query->found_posts ); |
|
| 148 | } |
|
| 149 | ||
| 150 | /** |
|
| 151 | * Edit a product |
|