WC_API_Taxes::get_tax_classes_count()
Get the total number of tax classes
Метод класса: WC_API_Taxes{}
Хуков нет.
Возвращает
Массив|WP_Error
.
Использование
$WC_API_Taxes = new WC_API_Taxes(); $WC_API_Taxes->get_tax_classes_count();
Список изменений
С версии 2.5.0 | Введена. |
Код WC_API_Taxes::get_tax_classes_count() WC API Taxes::get tax classes count 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() ) ); } }