WC_Tax::find_rates
Searches for all matching country/state/postcode tax rates.
Метод класса: WC_Tax{}
Хуки из метода
Возвращает
Массив.
Использование
$result = WC_Tax::find_rates( $args );
- $args(массив)
- Args that determine the rate to find.
По умолчанию: array()
Код WC_Tax::find_rates() WC Tax::find rates WC 10.4.2
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 );
}