WC_API_Coupons::get_coupons_count()
Get the total number of coupons
Метод класса: WC_API_Coupons{}
Хуков нет.
Возвращает
Массив|WP_Error
.
Использование
$WC_API_Coupons = new WC_API_Coupons(); $WC_API_Coupons->get_coupons_count( $filter );
- $filter(массив)
- -
По умолчанию: array()
Список изменений
С версии 2.1 | Введена. |
Код WC_API_Coupons::get_coupons_count() WC API Coupons::get coupons count WC 8.7.0
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() ) ); } }