Пример #1
0
/**
 * Sets meta for countries that no longer exist in their former notation to be considered legacy.
 *
 * @access private
 * @since 3.8.14
 */
function _wpsc_set_legacy_country_meta()
{
    if ($wpsc_country = WPSC_Countries::get_country('YU')) {
        $wpsc_country->set('_is_country_legacy', true);
    }
    if ($wpsc_country = WPSC_Countries::get_country('AN')) {
        $wpsc_country->set('_is_country_legacy', true);
    }
    if ($wpsc_country = WPSC_Countries::get_country('TP')) {
        $wpsc_country->set('_is_country_legacy', true);
    }
}
Пример #2
0
 /**
  * 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();
     }
 }
 public static function get_cache($value = null, $col = 'id')
 {
     $function = __CLASS__ . '::' . __FUNCTION__ . '()';
     $replacement = 'WPSC_Countries::get_country()';
     _wpsc_deprecated_function($function, '3.8.14', $replacement);
     if (defined('WPSC_LOAD_DEPRECATED') && WPSC_LOAD_DEPRECATED) {
         if (is_null($value) && $col == 'id') {
             $value = get_option('currency_type');
         }
         // note that we can't store cache by currency code, the code is used by various countries
         // TODO: remove duplicate entry for Germany (Deutschland)
         if (!in_array($col, array('id', 'isocode'))) {
             return false;
         }
         return WPSC_Countries::get_country($value, WPSC_Countries::RETURN_AN_ARRAY);
     }
 }
function wpsc_country_has_state($country_code)
{
    $country_data = WPSC_Countries::get_country($country_code, true);
    // TODO this function does not seem to do what it's name indicates? What's up with that.
    return $country_data;
}