WC_API_Taxes::get_tax_classes_count()
Get the total number of tax classes
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_tax_classes_count();
Changelog
Since 2.5.0 | Introduced. |
WC_API_Taxes::get_tax_classes_count() WC API Taxes::get tax classes count code WC 7.7.0
public function get_tax_classes_count() { try { if ( ! current_user_can( 'manage_woocommerce' ) ) { throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_tax_classes_count', __( 'You do not have permission to read the tax classes count', 'woocommerce' ), 401 ); } $total = count( WC_Tax::get_tax_classes() ) + 1; // +1 for Standard Rate return array( 'count' => $total ); } catch ( WC_API_Exception $e ) { return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); } }