WC_Tax::find_rates()public staticWC 1.0

Searches for all matching country/state/postcode tax rates.

Method of the class: WC_Tax{}

Hooks from the method

Return

Array.

Usage

$result = WC_Tax::find_rates( $args );
$args(array)
Args that determine the rate to find.
Default: array()

WC_Tax::find_rates() code WC 9.3.1

public static function find_rates( $args = array() ) {
	$args = wp_parse_args(
		$args,
		array(
			'country'   => '',
			'state'     => '',
			'city'      => '',
			'postcode'  => '',
			'tax_class' => '',
		)
	);

	$country   = $args['country'];
	$state     = $args['state'];
	$city      = $args['city'];
	$postcode  = wc_normalize_postcode( wc_clean( $args['postcode'] ) );
	$tax_class = $args['tax_class'];

	if ( ! $country ) {
		return array();
	}

	$cache_key         = WC_Cache_Helper::get_cache_prefix( 'taxes' ) . 'wc_tax_rates_' . md5( sprintf( '%s+%s+%s+%s+%s', $country, $state, $city, $postcode, $tax_class ) );
	$matched_tax_rates = wp_cache_get( $cache_key, 'taxes' );

	if ( false === $matched_tax_rates ) {
		$matched_tax_rates = self::get_matched_tax_rates( $country, $state, $postcode, $city, $tax_class );
		wp_cache_set( $cache_key, $matched_tax_rates, 'taxes' );
	}

	return apply_filters( 'woocommerce_find_rates', $matched_tax_rates, $args );
}