WC_API_Taxes::get_taxes_count() public WC 2.5.0
Get the total number of taxes
{} It's a method of the class: WC_API_Taxes{}
No Hooks.
Return
Array|WP_Error.
Usage
$WC_API_Taxes = new WC_API_Taxes(); $WC_API_Taxes->get_taxes_count( $class, $filter );
- $class(string)
- -
- $filter(array)
- -
Changelog
Since 2.5.0 | Introduced. |
Code of WC_API_Taxes::get_taxes_count() WC API Taxes::get taxes count WC 5.0.0
public function get_taxes_count( $class = null, $filter = array() ) {
try {
if ( ! current_user_can( 'manage_woocommerce' ) ) {
throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_taxes_count', __( 'You do not have permission to read the taxes count', 'woocommerce' ), 401 );
}
if ( ! empty( $class ) ) {
$filter['tax_rate_class'] = $class;
}
$query = $this->query_tax_rates( $filter, true );
return array( 'count' => (int) $query['headers']->total );
} catch ( WC_API_Exception $e ) {
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
}
}