WC_Tax::get_tax_location()
Get the customer tax location based on their status and the current page.
Used by get_rates(), get_shipping_rates().
Method of the class: WC_Tax{}
Hooks from the method
Return
Array
.
Usage
$result = WC_Tax::get_tax_location( $tax_class, $customer );
- $tax_class(string)
- string Optional, passed to the filter for advanced tax setups.
Default: '' - $customer(object)
- Override the customer object to get their location.
Default: null
WC_Tax::get_tax_location() WC Tax::get tax location code WC 9.5.1
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 ); }