WordPress at a glance
function is not described

WC_API_Taxes::query_tax_rates() protected WC 2.5.0

Helper method to get tax rates objects

{} It's a method of the class: WC_API_Taxes{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->query_tax_rates( $args, $count_only );
$args(array) (required)
-
$count_only(true/false)
-

Changelog

Since 2.5.0 Introduced.

Code of WC_API_Taxes::query_tax_rates() WC 5.0.0

<?php
protected function query_tax_rates( $args, $count_only = false ) {
	global $wpdb;

	$results = '';

	// Set args
	$args = $this->merge_query_args( $args, array() );

	$query = "
		SELECT tax_rate_id
		FROM {$wpdb->prefix}woocommerce_tax_rates
		WHERE 1 = 1
	";

	// Filter by tax class
	if ( ! empty( $args['tax_rate_class'] ) ) {
		$tax_rate_class = 'standard' !== $args['tax_rate_class'] ? sanitize_title( $args['tax_rate_class'] ) : '';
		$query .= " AND tax_rate_class = '$tax_rate_class'";
	}

	// Order tax rates
	$order_by = ' ORDER BY tax_rate_order';

	// Pagination
	$per_page   = isset( $args['posts_per_page'] ) ? $args['posts_per_page'] : get_option( 'posts_per_page' );
	$offset     = 1 < $args['paged'] ? ( $args['paged'] - 1 ) * $per_page : 0;
	$pagination = sprintf( ' LIMIT %d, %d', $offset, $per_page );

	if ( ! $count_only ) {
		$results = $wpdb->get_results( $query . $order_by . $pagination );
	}

	$wpdb->get_results( $query );
	$headers              = new stdClass;
	$headers->page        = $args['paged'];
	$headers->total       = (int) $wpdb->num_rows;
	$headers->is_single   = $per_page > $headers->total;
	$headers->total_pages = ceil( $headers->total / $per_page );

	return array(
		'results' => $results,
		'headers' => $headers,
	);
}