WC_Settings_Tax::has_standard_tax_rate_for_countryprivateWC 10.5.0

Check if a standard tax rate exists for a given country.

Method of the class: WC_Settings_Tax{}

No Hooks.

Returns

true|false. True if at least one standard tax rate exists for the country.

Usage

// private - for code of main (parent) class only
$result = $this->has_standard_tax_rate_for_country( $country );
$country(string) (required)
Country code.

Changelog

Since 10.5.0 Introduced.

WC_Settings_Tax::has_standard_tax_rate_for_country() code WC 10.5.0

private function has_standard_tax_rate_for_country( $country ) {
	global $wpdb;

	$count = $wpdb->get_var(
		$wpdb->prepare(
			"SELECT COUNT(*) FROM {$wpdb->prefix}woocommerce_tax_rates WHERE (tax_rate_country = %s OR tax_rate_country = '') AND tax_rate_class = ''",
			$country
		)
	);

	return $count > 0;
}