本文整理汇总了PHP中WPSC_Country::get_tax方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSC_Country::get_tax方法的具体用法?PHP WPSC_Country::get_tax怎么用?PHP WPSC_Country::get_tax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPSC_Country
的用法示例。
在下文中一共展示了WPSC_Country::get_tax方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function test_get_tax()
{
$country = new WPSC_Country(self::COUNTRY_ID_WITHOUT_REGIONS);
$tax = $country->get_tax();
$this->assertEquals(self::COUNTRY_WITHOUT_REGIONS_TAX_RATE, $tax);
}
示例2: switch
/**
* get_tax_rate method, gets the tax rate as a percentage, based on the selected country and region
* * EDIT: Replaced with WPEC Taxes - this function should probably be deprecated
* Note: to refresh cart items use wpsc_refresh_cart_items
*
* @access public
*/
function get_tax_rate()
{
$country = new WPSC_Country(get_option('base_country'));
$country_data = WPSC_Countries::get_country(get_option('base_country'), true);
$add_tax = false;
if ($this->selected_country == get_option('base_country')) {
// Tax rules for various countries go here, if your countries tax rules
// deviate from this, please supply code to add your region
switch ($this->selected_country) {
case 'US':
// USA!
$tax_region = get_option('base_region');
if ($this->selected_region == get_option('base_region') && get_option('lock_tax_to_shipping') != '1') {
// if they in the state, they pay tax
$add_tax = true;
} else {
if ($this->delivery_region == get_option('base_region')) {
// if they live outside the state, but are delivering to within the state, they pay tax also
$add_tax = true;
}
}
break;
case 'CA':
// Canada! apparently in canada, the region that you are in is used for tax purposes
if ($this->selected_region != null) {
$tax_region = $this->selected_region;
} else {
$tax_region = get_option('base_region');
}
$add_tax = true;
break;
default:
// Everywhere else!
$tax_region = get_option('base_region');
if ($country->has_regions()) {
if (get_option('base_region') == $region) {
$add_tax = true;
}
} else {
$add_tax = true;
}
break;
}
}
if ($add_tax == true) {
if ($country->has_regions()) {
$region = $country->get_region($tax_region);
$tax_percentage = $region->get_tax();
} else {
$tax_percentage = $country->get_tax();
}
} else {
// no tax charged = tax equal to 0%
$tax_percentage = 0;
}
if ($this->tax_percentage != $tax_percentage) {
$this->clear_cache();
$this->tax_percentage = $tax_percentage;
$this->wpsc_refresh_cart_items();
}
}