本文整理汇总了PHP中WC_Tax::get_tax_location方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Tax::get_tax_location方法的具体用法?PHP WC_Tax::get_tax_location怎么用?PHP WC_Tax::get_tax_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Tax
的用法示例。
在下文中一共展示了WC_Tax::get_tax_location方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_base_tax_rates
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;
}
示例2: test_get_shipping_tax_rates
/**
* 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);
}