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); }
/** * 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(); } }