WC_Tax::get_tax_location( string $tax_class = '', object $customer = null )
Get the customer tax location based on their status and the current page.
Description Description
Used by get_rates(), get_shipping_rates().
Parameters Parameters
- $tax_class
-
(Optional) string Optional, passed to the filter for advanced tax setups.
Default value: ''
- $customer
-
(Optional) Override the customer object to get their location.
Default value: null
Return Return
(array)
Source Source
File: includes/class-wc-tax.php
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 );
}