WC_API_Coupons::get_coupons_count( array $filter = array() )
Get the total number of coupons
Description Description
Parameters Parameters
- $filter
-
(Optional)
Default value: array()
Return Return
(array|WP_Error)
Source Source
File: includes/legacy/api/v2/class-wc-api-coupons.php
public function get_coupons_count( $filter = array() ) { try { 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() ) ); } }
Changelog Changelog
Version | Description |
---|---|
2.1 | Introduced. |