WC_Tax::get_rates_from_location()public staticWC 1.0

Get's an array of matching rates from location and tax class. $customer parameter is used to preserve backward compatibility for filter.

Method of the class: WC_Tax{}

Hooks from the method

Return

Mixed|null. Tax rates.

Usage

$result = WC_Tax::get_rates_from_location( $tax_class, $location, $customer );
$tax_class(string) (required)
Tax class to get rates for.
$location(array) (required)
Location to compute rates for. Should be in form: array( country, state, postcode, city).
$customer(object)
Only used to maintain backward compatibility for filter woocommerce-matched_rates.
Default: null

WC_Tax::get_rates_from_location() code WC 9.4.2

public static function get_rates_from_location( $tax_class, $location, $customer = null ) {
	$tax_class         = sanitize_title( $tax_class );
	$matched_tax_rates = array();

	if ( count( $location ) === 4 ) {
		list( $country, $state, $postcode, $city ) = $location;

		$matched_tax_rates = self::find_rates(
			array(
				'country'   => $country,
				'state'     => $state,
				'postcode'  => $postcode,
				'city'      => $city,
				'tax_class' => $tax_class,
			)
		);
	}

	return apply_filters( 'woocommerce_matched_rates', $matched_tax_rates, $tax_class, $customer );
}