get_tax_location() public static method

Used by get_rates(), get_shipping_rates().
public static get_tax_location ( $tax_class = '' ) : array
$tax_class string Optional, passed to the filter for advanced tax setups.
return array
 public function set_base_tax_rates($rates, $tax_class)
 {
     $location = WC_Tax::get_tax_location($tax_class);
     if (in_array($tax_class, array('virtual-rate', 'virtual-reduced-rate')) && isset($location[0]) && sizeof($location) === 4 && $location[0] !== WC()->countries->get_base_country()) {
         list($country, $state, $postcode, $city) = $location;
         $rates = WC_Tax::find_rates(array('country' => $country, 'state' => $state, 'postcode' => $postcode, 'city' => $city, 'tax_class' => $tax_class));
     }
     return $rates;
 }
Example #2
0
 /**
  * Get rates.
  */
 public function test_get_shipping_tax_rates()
 {
     global $wpdb;
     $wpdb->query("DELETE FROM {$wpdb->prefix}woocommerce_tax_rates");
     $wpdb->query("DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations");
     $customer_location = WC_Tax::get_tax_location();
     $tax_rate = array('tax_rate_country' => $customer_location[0], 'tax_rate_state' => '', 'tax_rate' => '20.0000', 'tax_rate_name' => 'VAT', 'tax_rate_priority' => '1', 'tax_rate_compound' => '0', 'tax_rate_shipping' => '1', 'tax_rate_order' => '1', 'tax_rate_class' => '');
     $tax_rate_id = WC_Tax::_insert_tax_rate($tax_rate);
     $tax_rates = WC_Tax::get_shipping_tax_rates();
     $this->assertEquals($tax_rates, array($tax_rate_id => array('rate' => '20.0000', 'label' => 'VAT', 'shipping' => 'yes', 'compound' => 'no')));
     WC_Tax::_delete_tax_rate($tax_rate_id);
 }