WC_Tax::get_tax_location()public staticWC 1.0

Get the customer tax location based on their status and the current page.

Used by get_rates(), get_shipping_rates().

Метод класса: WC_Tax{}

Хуки из метода

Возвращает

Массив.

Использование

$result = WC_Tax::get_tax_location( $tax_class, $customer );
$tax_class(строка)
string Optional, passed to the filter for advanced tax setups.
По умолчанию: ''
$customer(объект)
Override the customer object to get their location.
По умолчанию: null

Код WC_Tax::get_tax_location() WC 8.7.0

public static function get_tax_location( $tax_class = '', $customer = null ) {
	$location = array();

	if ( is_null( $customer ) && WC()->customer ) {
		$customer = WC()->customer;
	}

	if ( ! empty( $customer ) ) {
		$location = $customer->get_taxable_address();
	} elseif ( wc_prices_include_tax() || 'base' === get_option( 'woocommerce_default_customer_address' ) || 'base' === get_option( 'woocommerce_tax_based_on' ) ) {
		$location = array(
			WC()->countries->get_base_country(),
			WC()->countries->get_base_state(),
			WC()->countries->get_base_postcode(),
			WC()->countries->get_base_city(),
		);
	}

	return apply_filters( 'woocommerce_get_tax_location', $location, $tax_class, $customer );
}