diff --git a/wp-shopping-cart.php b/wp-shopping-cart.php index 12a8885d20..05e3c1290f 100644 --- a/wp-shopping-cart.php +++ b/wp-shopping-cart.php @@ -123,11 +123,9 @@ public function setup_table_names() { global $wpdb; $wpdb->wpsc_meta = WPSC_TABLE_META; $wpdb->wpsc_also_bought = WPSC_TABLE_ALSO_BOUGHT; - $wpdb->wpsc_region_tax = WPSC_TABLE_REGION_TAX; $wpdb->wpsc_coupon_codes = WPSC_TABLE_COUPON_CODES; $wpdb->wpsc_cart_contents = WPSC_TABLE_CART_CONTENTS; $wpdb->wpsc_claimed_stock = WPSC_TABLE_CLAIMED_STOCK; - $wpdb->wpsc_currency_list = WPSC_TABLE_CURRENCY_LIST; $wpdb->wpsc_purchase_logs = WPSC_TABLE_PURCHASE_LOGS; $wpdb->wpsc_checkout_forms = WPSC_TABLE_CHECKOUT_FORMS; $wpdb->wpsc_product_rating = WPSC_TABLE_PRODUCT_RATING; @@ -137,6 +135,8 @@ public function setup_table_names() { $wpdb->wpsc_purchasemeta = WPSC_TABLE_PURCHASE_META; $wpdb->wpsc_visitors = WPSC_TABLE_VISITORS; $wpdb->wpsc_visitormeta = WPSC_TABLE_VISITOR_META; + + do_action( 'wpsc_setup_table_names' ); } /** diff --git a/wpsc-admin/ajax-and-init.php b/wpsc-admin/ajax-and-init.php index 57e90d1cf8..cbaf3b014c 100644 --- a/wpsc-admin/ajax-and-init.php +++ b/wpsc-admin/ajax-and-init.php @@ -88,16 +88,24 @@ function wpsc_change_currency() { return; } - global $wpdb; - + // it appears that what is called 'currencyid' here is really the country id if ( is_numeric( $_POST['currencyid'] ) ) { - $currency_data = $wpdb->get_results( $wpdb->prepare( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`=%d LIMIT 1", $_POST['currencyid'] ), ARRAY_A ); + $wpsc_country = wpsc_get_country_object( $_POST['currencyid'] ); + $price_out = null; - if ( $currency_data[0]['symbol'] != '' ) { - $currency_sign = $currency_data[0]['symbol_html']; - } else { - $currency_sign = $currency_data[0]['code']; + + // we are going to look for currency code as html, if that not found, then the + // symbol, if that not cound we will go with the isocode + $currency_sign = $wpsc_country->get_currency_symbol_html(); + + if ( empty( $currency_sign ) ) { + $currency_sign = $wpsc_country->get_currency_symbol(); + } + + if ( empty( $currency_sign ) ) { + $currency_sign = $wpsc_country->get_currency_code(); } + echo $currency_sign; } } diff --git a/wpsc-admin/includes/display-items-functions.php b/wpsc-admin/includes/display-items-functions.php index 9dac79f08f..e8530d24ba 100644 --- a/wpsc-admin/includes/display-items-functions.php +++ b/wpsc-admin/includes/display-items-functions.php @@ -127,12 +127,10 @@ function wpsc_price_control_forms() { } $product_data['meta']['_wpsc_price'] = wpsc_format_number( $product_data['meta']['_wpsc_price'] ); - - $currency_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A ); + $currency_data = wpsc_get_all_countries(); /* Get country name and symbol */ - $currency_type = get_option( 'currency_type' ); - $country = new WPSC_Country( $currency_type ); + $country = wpsc_get_currency_type_country_object(); $ct_code = $country->get_currency_code(); // Country currency code $ct_symb = $country->get_currency_symbol(); // Country symbol @@ -197,9 +195,9 @@ function wpsc_price_control_forms() { @@ -214,9 +212,9 @@ function wpsc_price_control_forms() { diff --git a/wpsc-admin/includes/product-functions.php b/wpsc-admin/includes/product-functions.php index 60295c53cb..5da6514656 100644 --- a/wpsc-admin/includes/product-functions.php +++ b/wpsc-admin/includes/product-functions.php @@ -778,24 +778,37 @@ function wpsc_edit_product_variations($product_id, $post_data) { } -function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){ +/** + * @param int $product_id + * @param int $new_currency_country_id + * @param float $new_price + */ +function wpsc_update_alt_product_currency($product_id, $new_currency_country_id, $new_price ){ global $wpdb; - $old_curr = get_product_meta($product_id, 'currency',true); - $sql = $wpdb->prepare( "SELECT `isocode` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`= %d", $newCurrency ); - $isocode = $wpdb->get_var($sql); - - $newCurrency = 'currency'; - $old_curr[$isocode] = $newPrice; - if(($newPrice != '') && ($newPrice > 0.00)){ - update_product_meta($product_id, $newCurrency, $old_curr); + $old_currency_original_meta_value = get_product_meta( $product_id, 'currency', true ); + if ( !is_array( $old_currency_original_meta_value ) ) { + $new_meta_value = array(); } else { - if((empty($old_curr[$isocode]) || 0.00 == $old_curr[$isocode]) && is_array($old_curr)) - unset($old_curr[$isocode]); - update_product_meta($product_id, $newCurrency, $old_curr); - + $new_meta_value = $old_currency_original_meta_value; } + if ( ! empty( $new_currency_country_id ) ) { + $wpsc_country_new_currency = wpsc_get_country_object( $new_currency_country_id ); + if ( $wpsc_country_new_currency ) { + + $new_meta_value[ $wpsc_country_new_currency->get_isocode() ] = $new_price; + + if ( ! empty( $new_price ) ) { + update_product_meta( $product_id, 'currency', $new_meta_value ); + } else { + if ( ( empty( $new_meta_value[ $wpsc_country_new_currency->get_isocode() ] ) || 0.00 == $new_meta_value[ $wpsc_country_new_currency->get_isocode() ] ) && is_array( $new_meta_value ) ) { + unset( $new_meta_value[ $wpsc_country_new_currency->get_isocode() ] ); + } + update_product_meta( $product_id, 'currency', $new_meta_value ); + } + } + } } /** diff --git a/wpsc-admin/includes/save-data.functions.php b/wpsc-admin/includes/save-data.functions.php index 55442401c0..686562ed06 100755 --- a/wpsc-admin/includes/save-data.functions.php +++ b/wpsc-admin/includes/save-data.functions.php @@ -554,13 +554,14 @@ function wpsc_save_category_set( $category_id, $tt_id ) { if ( ! empty( $_POST['countrylist2'] ) && ( $category_id > 0 ) ) { $AllSelected = false; - $countryList = $wpdb->get_col( "SELECT `id` FROM `" . WPSC_TABLE_CURRENCY_LIST . "`" ); + $countryList = wpsc_get_country_objects(); if ( $AllSelected != true ){ + $all_counntry_ids = array_keys( $countryList ); $posted_countries = array_map( 'intval', $_POST['countrylist2'] ); - $unselectedCountries = array_diff( $countryList, $posted_countries ); + $unselectedCountries = array_diff( $all_counntry_ids, $posted_countries ); //find the countries that are selected - $selectedCountries = array_intersect( $countryList, $posted_countries ); + $selectedCountries = array_intersect( $all_counntry_ids, $posted_countries ); wpsc_update_categorymeta( $category_id, 'target_market', $selectedCountries ); } diff --git a/wpsc-admin/includes/settings-tabs/general.php b/wpsc-admin/includes/settings-tabs/general.php index 06c9ef9c25..6a500abc8c 100644 --- a/wpsc-admin/includes/settings-tabs/general.php +++ b/wpsc-admin/includes/settings-tabs/general.php @@ -7,19 +7,19 @@ public function __construct() { } private function get_regions() { - global $wpdb; - if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['country'] ) ) + if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['country'] ) ) { $base_country = $_POST['country']; - else + } else { $base_country = get_option( 'base_country' ); - $from = WPSC_TABLE_REGION_TAX . ' AS r'; - $join = WPSC_TABLE_CURRENCY_LIST . ' AS c'; - $sql = $wpdb->prepare( " - SELECT r.id, r.name - FROM {$from} - INNER JOIN {$join} ON r.country_id = c.id AND c.isocode = %s - ", $base_country ); - $this->regions = $wpdb->get_results( $sql ); + } + + if ( ! empty( $base_country ) ) { + $wpsc_country = wpsc_get_country_object( $base_country ); + + if ( $wpsc_country && $wpsc_country->has_regions() ) { + $this->regions = $wpsc_country->get_regions(); + } + } } public function display_region_drop_down() { @@ -27,8 +27,8 @@ public function display_region_drop_down() { if ( ! empty( $this->regions ) ): ?>

@@ -59,10 +59,6 @@ public function display() { -
@@ -78,13 +74,13 @@ public function display() { All None' , 'wpsc') , esc_url( add_query_arg( array( 'selected_all' => 'all' ) ) ), esc_url( add_query_arg( array( 'selected_all' => 'none' ) ) ) ); ?>
- - - ' checked='checked' /> -
+ $wpsc_country ) : ?> + is_visible() ) : ?> + +
- ' /> -
+ +
@@ -133,27 +129,34 @@ public function display() {

get_results( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A ); - $currency_type = esc_attr( get_option( 'currency_type' ) ); + $currency_type_country_id = wpsc_get_currency_type_country_id(); ?> get_row( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . esc_attr( get_option( 'currency_type' ) ) . "' LIMIT 1", ARRAY_A ); + $wpsc_country_of_currency_type = wpsc_get_currency_type_country_object(); + + if ( $wpsc_country_of_currency_type ) { + $currency_sign = $wpsc_country_of_currency_type->get_currency_symbol_html(); + + if ( empty( $currency_sign ) ) { + $currency_sign = $wpsc_country_of_currency_type->get_currency_symbol(); + } - if ( $currency_data['symbol'] != '' ) { - $currency_sign = esc_attr( $currency_data['symbol_html'] ); + if ( empty( $currency_sign ) ) { + $currency_sign = $wpsc_country_of_currency_type->get_currency_code(); + } } else { - $currency_sign = esc_attr( $currency_data['code'] ); + $currency_sign = ''; } $currency_sign_location = esc_attr( get_option( 'currency_sign_location' ) ); diff --git a/wpsc-admin/includes/tax_and_shipping.php b/wpsc-admin/includes/tax_and_shipping.php index 59b841348c..54dae4e91c 100755 --- a/wpsc-admin/includes/tax_and_shipping.php +++ b/wpsc-admin/includes/tax_and_shipping.php @@ -20,10 +20,12 @@ ?> get_row( $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode` IN(%s) LIMIT 1", $country_isocode ), ARRAY_A ); - if(($country_data['has_regions'] == 1)) - { - $region_data = $wpdb->get_results("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."` WHERE `".WPSC_TABLE_REGION_TAX."`.`country_id` IN('".$country_data['id']."') ",ARRAY_A) ; + $wpsc_country = wpsc_get_country_object( $country_isocode ); + $country_data = $wpsc_country->get_array(); + + if( $wpsc_country->has_regions() ) { + $region_data = $wpsc_country->get_regions( true ); + $region_data = array_chunk($region_data, 14); echo "
\n\r"; @@ -32,8 +34,9 @@ { echo "
\n\r"; echo "\n\r"; - foreach($region_col as $region) + foreach($region_col as $wpsc_region) { + $region = $wpsc_region->as_array(); $tax_percentage = $region['tax']; echo " \n\r"; if($region['id'] == $base_region) diff --git a/wpsc-admin/init.php b/wpsc-admin/init.php index 4df2aacfec..5681f6e5e7 100644 --- a/wpsc-admin/init.php +++ b/wpsc-admin/init.php @@ -866,10 +866,19 @@ function wpsc_delete_coupon(){ add_action( 'admin_init', 'wpsc_delete_coupon' ); } -function _wpsc_action_update_option_base_country( $old_value, $new_value ) { - global $wpdb; - $region_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(`regions`.`id`) FROM `" . WPSC_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('%s')", $new_value ) ); - if ( ! $region_count ) +/** + * Check to see if the base region need to be updated when the base country option is updated + * @param string $old_base_country_iso_code string + * @param string $new_base_country_iso_code string + * + */ +function _wpsc_action_update_option_base_country( $old_base_country_iso_code, $new_base_country_iso_code ) { + $wpsc_country = wpsc_get_country_object( $new_base_country_iso_code ); + + if ( ! $wpsc_country->has_regions() ) { update_option( 'base_region', '' ); + } + } + add_action( 'update_option_base_country', '_wpsc_action_update_option_base_country', 10, 2 ); diff --git a/wpsc-admin/settings-page.php b/wpsc-admin/settings-page.php index 6da344cc2d..8806b1978c 100644 --- a/wpsc-admin/settings-page.php +++ b/wpsc-admin/settings-page.php @@ -600,51 +600,38 @@ private function save_options( $selected = '' ) { if ( $_POST['countrylist2'] != null || !empty($selected) ) { $AllSelected = false; if ( $selected == 'all' ) { - $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '1'" ); + wpsc_set_all_countries_visibility( true ); $AllSelected = true; } if ( $selected == 'none' ) { - $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '0'" ); + wpsc_set_all_countries_visibility( false ); $AllSelected = true; } if ( $AllSelected != true ) { - $countrylist = $wpdb->get_col( "SELECT id FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC " ); + $all_countries = wpsc_get_all_countries(); + + // all we need are the ids we used weh creating the web page + $all_country_ids = array_keys( $all_countries ); + + $country_ids_posted = array_map( 'intval', $_POST['countrylist2'] ); + //find the countries not selected - $unselectedCountries = array_diff( $countrylist, $_POST['countrylist2'] ); - foreach ( $unselectedCountries as $unselected ) { - $wpdb->update( - WPSC_TABLE_CURRENCY_LIST, - array( - 'visible' => 0 - ), - array( - 'id' => $unselected - ), - '%d', - '%d' - ); + $unselected_country_ids = array_diff( $all_country_ids, $country_ids_posted ); + + foreach ( $unselected_country_ids as $unselected_country_id ) { + $all_countries[$unselected_country_id]->set_visible( false ); } //find the countries that are selected - $selectedCountries = array_intersect( $countrylist, $_POST['countrylist2'] ); - foreach ( $selectedCountries as $selected ) { - $wpdb->update( - WPSC_TABLE_CURRENCY_LIST, - array( - 'visible' => 1 - ), - array( - 'id' => $selected - ), - '%d', - '%d' - ); + $selected_country_ids = array_intersect( $all_country_ids, $country_ids_posted ); + foreach ( $selected_country_ids as $selected_country_id ) { + $all_countries[$selected_country_id]->set_visible( true ); } } - WPSC_Countries::clear_cache(); wpsc_core_flush_temporary_data(); } + $previous_currency = get_option( 'currency_type' ); //To update options @@ -670,7 +657,10 @@ private function save_options( $selected = '' ) { } if ( $previous_currency != get_option( 'currency_type' ) ) { - $currency_code = $wpdb->get_var( "SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` IN ('" . absint( get_option( 'currency_type' ) ) . "')" ); + $wpsc_currency_type_country = wpsc_get_currency_type_country_object(); + if ( $wpsc_currency_type_country ) { + $currency_code = $wpsc_currency_type_country->get_currency_code(); + } $selected_gateways = get_option( 'custom_gateway_options' ); $already_changed = array( ); diff --git a/wpsc-components/theme-engine-v1/widgets/admin_menu_widget.php b/wpsc-components/theme-engine-v1/widgets/admin_menu_widget.php index cd30251681..dd1dab8ee9 100755 --- a/wpsc-components/theme-engine-v1/widgets/admin_menu_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/admin_menu_widget.php @@ -18,7 +18,7 @@ function WP_Widget_Admin_Menu() { 'description' => __( 'Admin Menu Widget', 'wpsc' ) ); - $this->WP_Widget( 'wpsc_admin_menu', __( '(WPEC) Admin Menu', 'wpsc' ), $widget_ops ); + parent::__construct( 'wpsc_admin_menu', __( '(WPEC) Admin Menu', 'wpsc' ), $widget_ops ); } diff --git a/wpsc-components/theme-engine-v1/widgets/category_widget.php b/wpsc-components/theme-engine-v1/widgets/category_widget.php index d98f8b184d..7a8da5e7eb 100755 --- a/wpsc-components/theme-engine-v1/widgets/category_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/category_widget.php @@ -16,7 +16,7 @@ function WP_Widget_Product_Categories() { 'classname' => 'widget_wpsc_categorisation', 'description' => __( 'Product Grouping Widget', 'wpsc' ) ); - $this->WP_Widget( 'wpsc_categorisation', __( '(WPEC) Product Categories', 'wpsc' ), $widget_ops ); + parent::__construct( 'wpsc_categorisation', __( '(WPEC) Product Categories', 'wpsc' ), $widget_ops ); } /** diff --git a/wpsc-components/theme-engine-v1/widgets/donations_widget.php b/wpsc-components/theme-engine-v1/widgets/donations_widget.php index 437669ed26..2ae941e4a1 100755 --- a/wpsc-components/theme-engine-v1/widgets/donations_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/donations_widget.php @@ -19,7 +19,7 @@ function WP_Widget_Donations() { 'description' => __( 'Donations Widget', 'wpsc' ) ); - $this->WP_Widget( 'wpsc_donations', __( '(WPEC) Product Donations', 'wpsc' ), $widget_ops ); + parent::__construct( 'wpsc_donations', __( '(WPEC) Product Donations', 'wpsc' ), $widget_ops ); } diff --git a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php index a8598781c2..1d5166410f 100755 --- a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php @@ -13,7 +13,7 @@ class WP_Widget_Latest_Products extends WP_Widget { */ function WP_Widget_Latest_Products() { $widget_ops = array( 'classname' => 'widget_wpsc_latest_products','description' => __( 'Latest Products Widget', 'wpsc' ) ); - $this->WP_Widget( 'wpsc_latest_products', __( '(WPEC) Latest Products', 'wpsc' ), $widget_ops ); + parent::__construct( 'wpsc_latest_products', __( '(WPEC) Latest Products', 'wpsc' ), $widget_ops ); } /** diff --git a/wpsc-components/theme-engine-v1/widgets/price_range_widget.php b/wpsc-components/theme-engine-v1/widgets/price_range_widget.php index a1a1fb0e0c..828af1ade8 100755 --- a/wpsc-components/theme-engine-v1/widgets/price_range_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/price_range_widget.php @@ -19,7 +19,7 @@ function WP_Widget_Price_Range() { 'description' => __( 'Price Range Widget', 'wpsc' ) ); - $this->WP_Widget( 'wpsc_price_range', __( '(WPEC) Price Range', 'wpsc' ), $widget_ops ); + parent::__construct( 'wpsc_price_range', __( '(WPEC) Price Range', 'wpsc' ), $widget_ops ); } diff --git a/wpsc-components/theme-engine-v1/widgets/product_tag_widget.php b/wpsc-components/theme-engine-v1/widgets/product_tag_widget.php index a86b6bbcb6..1529a850e3 100755 --- a/wpsc-components/theme-engine-v1/widgets/product_tag_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/product_tag_widget.php @@ -19,7 +19,7 @@ function WP_Widget_Product_Tags() { 'description' => __( 'Product Tags Widget', 'wpsc' ) ); - $this->WP_Widget( 'wpsc_product_tags', __( '(WPEC) Product Tags', 'wpsc' ), $widget_ops ); + parent::__construct( 'wpsc_product_tags', __( '(WPEC) Product Tags', 'wpsc' ), $widget_ops ); } diff --git a/wpsc-components/theme-engine-v1/widgets/shopping_cart_widget.php b/wpsc-components/theme-engine-v1/widgets/shopping_cart_widget.php index 9191083430..0420ea5891 100755 --- a/wpsc-components/theme-engine-v1/widgets/shopping_cart_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/shopping_cart_widget.php @@ -19,7 +19,7 @@ function WP_Widget_Shopping_Cart() { 'description' => __( 'Shopping Cart Widget', 'wpsc' ) ); - $this->WP_Widget( 'wpsc_shopping_cart', __( '(WPEC) Shopping Cart', 'wpsc' ), $widget_ops ); + parent::__construct( 'wpsc_shopping_cart', __( '(WPEC) Shopping Cart', 'wpsc' ), $widget_ops ); } diff --git a/wpsc-components/theme-engine-v1/widgets/specials_widget.php b/wpsc-components/theme-engine-v1/widgets/specials_widget.php index 00a48e0707..358bfda0ba 100755 --- a/wpsc-components/theme-engine-v1/widgets/specials_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/specials_widget.php @@ -19,7 +19,7 @@ function WP_Widget_Product_Specials() { 'description' => __( 'Product Specials Widget', 'wpsc' ) ); - $this->WP_Widget( 'wpsc_product_specials', __( '(WPEC) Product Specials', 'wpsc' ), $widget_ops ); + parent::__construct( 'wpsc_product_specials', __( '(WPEC) Product Specials', 'wpsc' ), $widget_ops ); } diff --git a/wpsc-components/theme-engine-v2/helpers/form.php b/wpsc-components/theme-engine-v2/helpers/form.php index 09df7276c4..a26f30fe23 100644 --- a/wpsc-components/theme-engine-v2/helpers/form.php +++ b/wpsc-components/theme-engine-v2/helpers/form.php @@ -357,30 +357,37 @@ function _wpsc_filter_control_select_region( $output, $field, $args ) { $options = array(); if ( $country == 'all' ) { - $state_data = $wpdb->get_results( "SELECT `regions`.*, country.country as country, country.isocode as country_isocode FROM `" . WPSC_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id`" ); + + $state_data = wpsc_get_all_regions(); + $options[__( 'No State', 'wpsc' )] = array( '' => __( 'No State', 'wpsc' ), ); - foreach ( $state_data as $state ) { - if ( ! array_key_exists( $state->country, $options ) ) { - $options[ $state->country ] = array(); + foreach ( $state_data as $region_id => $wpsc_region ) { + + $wpsc_country = $wpsc_region->get_country(); + + if ( ! array_key_exists( $wpsc_country->get_name(), $options ) ) { + $options[ $wpsc_country->get_name() ] = array(); } $options[ $state->country ][ $state->id ] = array( - 'title' => $state->name, + 'title' => $wpsc_region->get_name(), 'attributes' => array( - 'data-alternative-spellings' => $state->code, - 'data-country-id' => $state->country_id, - 'data-country-isocode' => $state->country_isocode, + 'data-alternative-spellings' => $wpsc_region->get_name(), + 'data-country-id' => $wpsc_country->get_id(), + 'data-country-isocode' => $wpsc_country->get_isocode(), ) ); } } else { - $state_data = $wpdb->get_results( $wpdb->prepare( "SELECT `regions`.*, country.isocode as country FROM `" . WPSC_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN(%s)", $country ) ); - - foreach ( $state_data as $state ) { - $options[ $state->id ] = $state->name; + $wpsc_country = wpsc_get_country_object( $country ); + if ( $wpsc_country ) { + $wpsc_regions = $wpsc_country->get_regions(); + foreach ( $wpsc_regions as $region_id => $wpsc_region ) { + $options[ $region_id ] = $wpsc_region->get_name(); + } } } $output .= wpsc_form_select( diff --git a/wpsc-core/wpsc-constants.php b/wpsc-core/wpsc-constants.php index f57149a81a..3414409d39 100644 --- a/wpsc-core/wpsc-constants.php +++ b/wpsc-core/wpsc-constants.php @@ -210,7 +210,6 @@ function wpsc_core_constants_table_names() { define( 'WPSC_TABLE_CART_CONTENTS', "{$wp_table_prefix}wpsc_cart_contents" ); define( 'WPSC_TABLE_SUBMITED_FORM_DATA', "{$wp_table_prefix}wpsc_submited_form_data" ); define( 'WPSC_TABLE_SUBMITTED_FORM_DATA', "{$wp_table_prefix}wpsc_submited_form_data" ); - define( 'WPSC_TABLE_CURRENCY_LIST', "{$wp_table_prefix}wpsc_currency_list" ); // These tables may be needed in some situations, but are not vital to // the core functionality of the plugin @@ -242,7 +241,6 @@ function wpsc_core_constants_table_names() { define( 'WPSC_TABLE_VARIATION_VALUES', "{$wp_table_prefix}wpsc_variation_values" ); define( 'WPSC_TABLE_VARIATION_VALUES_ASSOC', "{$wp_table_prefix}wpsc_variation_values_assoc" ); define( 'WPSC_TABLE_VARIATION_COMBINATIONS', "{$wp_table_prefix}wpsc_variation_combinations" ); - define( 'WPSC_TABLE_REGION_TAX', "{$wp_table_prefix}wpsc_region_tax" ); define( 'WPSC_TABLE_CART_ITEM_META', "{$wp_table_prefix}wpsc_cart_item_meta" ); define( 'WPSC_TABLE_PURCHASE_META', "{$wp_table_prefix}wpsc_purchase_meta" ); @@ -250,6 +248,10 @@ function wpsc_core_constants_table_names() { define( 'WPSC_TABLE_VISITORS', "{$wp_table_prefix}wpsc_visitors" ); define( 'WPSC_TABLE_VISITOR_META', "{$wp_table_prefix}wpsc_visitor_meta" ); + if ( defined( 'WPEC_LOAD_DEPRECATED' ) && WPEC_LOAD_DEPRECATED ) { + define( 'WPSC_TABLE_REGION_TAX', "{$wp_table_prefix}wpsc_region_tax" ); + define( 'WPSC_TABLE_CURRENCY_LIST', "{$wp_table_prefix}wpsc_currency_list" ); + } } /** diff --git a/wpsc-core/wpsc-deprecated.php b/wpsc-core/wpsc-deprecated.php index 2a09003762..881d8fc544 100644 --- a/wpsc-core/wpsc-deprecated.php +++ b/wpsc-core/wpsc-deprecated.php @@ -7,8 +7,9 @@ * @return false */ -function wpsc_cart_item_custom_message(){ +function wpsc_cart_item_custom_message() { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } @@ -18,9 +19,10 @@ function wpsc_cart_item_custom_message(){ * Deprecated function for merchants modules * */ -function wpsc_merchants_modules_deprecated($nzshpcrt_gateways){ +function wpsc_merchants_modules_deprecated( $nzshpcrt_gateways ) { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); $nzshpcrt_gateways = apply_filters( 'wpsc_gateway_modules', $nzshpcrt_gateways ); + return $nzshpcrt_gateways; } @@ -33,14 +35,15 @@ function wpsc_merchants_modules_deprecated($nzshpcrt_gateways){ * * @param $args (array) Arguments. */ -function nzshpcrt_price_range($args){ +function nzshpcrt_price_range( $args ) { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - wpsc_price_range($args); + wpsc_price_range( $args ); } // preserved for backwards compatibility function nzshpcrt_shopping_basket( $input = null, $override_state = null ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_shopping_cart'); + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_shopping_cart' ); + return wpsc_shopping_cart( $input, $override_state ); } @@ -50,9 +53,10 @@ function nzshpcrt_shopping_basket( $input = null, $override_state = null ) { * deprecated as we do not have brands anymore... * */ -function show_cats_brands($category_group = null , $display_method = null, $order_by = 'name', $image = null) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_shopping_cart'); +function show_cats_brands( $category_group = null, $display_method = null, $order_by = 'name', $image = null ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_shopping_cart' ); } + /** * Filter: wpsc-purchlogitem-links-start * @@ -67,9 +71,9 @@ function wpsc_purchlogitem_links_start_deprecated() { } -function nzshpcrt_donations($args){ +function nzshpcrt_donations( $args ) { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - wpsc_donations($args); + wpsc_donations( $args ); } /** @@ -90,7 +94,7 @@ function nzshpcrt_donations($args){ * 5. Function now expects two arrays as per the standard Widget API. */ function nzshpcrt_latest_product( $args = null, $instance ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_latest_product'); + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_latest_product' ); echo wpsc_latest_product( $args, $instance ); } @@ -99,22 +103,25 @@ function nzshpcrt_latest_product( $args = null, $instance ) { * Obsolete, preserved for backwards compatibility * * @access public + * * @param mixed $price_in * @param mixed $tax_status * @param bool $nohtml deprecated - * @param bool $id. deprecated - * @param bool $no_dollar_sign. (default: false) + * @param bool $id . deprecated + * @param bool $no_dollar_sign . (default: false) + * * @return void */ -function nzshpcrt_currency_display($price_in, $tax_status, $nohtml = false, $id = false, $no_dollar_sign = false) { +function nzshpcrt_currency_display( $price_in, $tax_status, $nohtml = false, $id = false, $no_dollar_sign = false ) { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - $output = wpsc_currency_display($price_in, array( - 'display_currency_symbol' => !(bool)$no_dollar_sign, - 'display_as_html' => ! (bool)$nohtml, - 'display_decimal_point' => true, - 'display_currency_code' => false - )); + $output = wpsc_currency_display( $price_in, array( + 'display_currency_symbol' => ! (bool) $no_dollar_sign, + 'display_as_html' => ! (bool) $nohtml, + 'display_decimal_point' => true, + 'display_currency_code' => false + ) ); + return $output; } @@ -125,31 +132,35 @@ function nzshpcrt_currency_display($price_in, $tax_status, $nohtml = false, $id * * @deprecated */ -function wpsc_include_language_constants(){ +function wpsc_include_language_constants() { // _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - if(!defined('TXT_WPSC_ABOUT_THIS_PAGE')) - include_once(WPSC_FILE_PATH.'/wpsc-languages/EN_en.php'); + if ( ! defined( 'TXT_WPSC_ABOUT_THIS_PAGE' ) ) { + include_once( WPSC_FILE_PATH . '/wpsc-languages/EN_en.php' ); + } } -add_action('init','wpsc_include_language_constants'); -if(!function_exists('wpsc_has_noca_message')){ - function wpsc_has_noca_message(){ +add_action( 'init', 'wpsc_include_language_constants' ); + +if ( ! function_exists( 'wpsc_has_noca_message' ) ) { + function wpsc_has_noca_message() { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - if(isset($_SESSION['nocamsg']) && isset($_GET['noca']) && $_GET['noca'] == 'confirm') + if ( isset( $_SESSION['nocamsg'] ) && isset( $_GET['noca'] ) && $_GET['noca'] == 'confirm' ) { return true; - else + } else { return false; + } } } -if(!function_exists('wpsc_is_noca_gateway')){ - function wpsc_is_noca_gateway(){ +if ( ! function_exists( 'wpsc_is_noca_gateway' ) ) { + function wpsc_is_noca_gateway() { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - if(count($wpsc_gateway->wpsc_gateways) == 1 && $wpsc_gateway->wpsc_gateways[0]['name'] == 'Noca') + if ( count( $wpsc_gateway->wpsc_gateways ) == 1 && $wpsc_gateway->wpsc_gateways[0]['name'] == 'Noca' ) { return true; - else + } else { return false; + } } } @@ -164,7 +175,7 @@ function wpsc_current_page() { $current_page = 1; - if ( $wpsc_query->query_vars['page'] > 1) { + if ( $wpsc_query->query_vars['page'] > 1 ) { $current_page = $wpsc_query->query_vars['page']; } @@ -191,6 +202,7 @@ function wpsc_showing_products() { } else { $startnum = 0; } + return ( $startnum + 1 ) . ' to ' . ( $startnum + wpsc_product_count() ); } @@ -208,7 +220,7 @@ function wpsc_showing_products_page() { global $wpsc_query; - $output = $wpsc_query->page_count; + $output = $wpsc_query->page_count; $current_page = wpsc_current_page(); return $current_page . ' of ' . $output; @@ -224,7 +236,8 @@ function wpsc_showing_products_page() { */ function is_wpsc_profile_page() { _wpsc_deprecated_function( __FUNCTION__, '3.8.10' ); - return !empty($_REQUEST['tab']) && ( $_REQUEST['tab'] == 'edit_profile' ); + + return ! empty( $_REQUEST['tab'] ) && ( $_REQUEST['tab'] == 'edit_profile' ); } /** @@ -235,7 +248,8 @@ function is_wpsc_profile_page() { */ function is_wpsc_downloads_page() { _wpsc_deprecated_function( __FUNCTION__, '3.8.10' ); - return !empty($_REQUEST['tab']) && ( $_REQUEST['tab'] == 'downloads' ); + + return ! empty( $_REQUEST['tab'] ) && ( $_REQUEST['tab'] == 'downloads' ); } @@ -247,6 +261,7 @@ function is_wpsc_downloads_page() { */ function wpsc_user_details() { _wpsc_deprecated_function( __FUNCTION__, '3.8.10' ); + return wpsc_user_purchases(); } @@ -254,13 +269,15 @@ function wpsc_user_details() { /** * wpsc product search url * Add product_search parameter if required. + * * @param $url (string) URL. + * * @return (string) URL. */ function wpsc_product_search_url( $url ) { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); if ( isset( $_GET['product_search'] ) ) { - if ( strrpos( $url, '?') ) { + if ( strrpos( $url, '?' ) ) { $url .= '&product_search=' . $_GET['product_search']; } else { $url .= '?product_search=' . $_GET['product_search']; @@ -274,11 +291,14 @@ function wpsc_product_search_url( $url ) { /** * wpsc adjacent products url * URL for the next or previous page of products on a category or group page. + * * @param $n (int) Page number. + * * @return (string) URL for the adjacent products page link. */ function wpsc_adjacent_products_url( $n ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination' ); + return false; } @@ -286,59 +306,74 @@ function wpsc_adjacent_products_url( $n ) { /** * wpsc next products link * Links to the next page of products on a category or group page. + * * @param $text (string) Link text. * @param $show_disabled (bool) Show unlinked text if last page. + * * @return (string) Next page link or text. */ function wpsc_next_products_link( $text = 'Next', $show_disabled = false ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination' ); + return false; } /** * wpsc previous products link * Links to the previous page of products on a category or group page. + * * @param $text (string) Link text. * @param $show_disabled (bool) Show unlinked text if first page. + * * @return (string) Previous page link or text. */ function wpsc_previous_products_link( $text = 'Previous', $show_disabled = false ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination' ); + return false; } /** * wpsc first products link * Links to the first page of products on a category or group page. + * * @param $text (string) Link text. * @param $show_disabled (bool) Show unlinked text if last page. + * * @return (string) First page link or text. */ function wpsc_first_products_link( $text = 'First', $show_disabled = false ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination' ); + return false; } /** * wpsc last products link * Links to the last page of products on a category or group page. + * * @param $text (string) Link text. * @param $show_disabled (bool) Show unlinked text if first page. + * * @return (string) Last page link or text. */ function wpsc_last_products_link( $text = 'Last', $show_disabled = false ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination' ); + return false; } /** * Saves the variation set data + * * @param nothing + * * @return nothing */ function wpsc_save_variation_set() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } @@ -347,7 +382,8 @@ function wpsc_save_variation_set() { * @return boolean - true while we have pages to loop through */ function wpsc_have_pages() { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination' ); + return false; } @@ -356,7 +392,8 @@ function wpsc_have_pages() { * @return nothing - iterate through the pages */ function wpsc_the_page() { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination' ); + return false; } @@ -365,73 +402,87 @@ function wpsc_the_page() { * @return integer - the page number */ function wpsc_page_number() { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination' ); + return false; } function wpsc_ordersummary() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } function display_ecomm_rss_feed() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } function display_ecomm_admin_menu() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } // displays error messages if the category setup is odd in some way // needs to be in a function because there are at least three places where this code must be used. function wpsc_odd_category_setup() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } function wpsc_product_image_html( $image_name, $product_id ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } function wpsc_delete_currency_layer() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } function wpsc_akst_send_mail() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } function wpsc_akst_hide_pop() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } function wpsc_akst_page() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } -function wpsc_akst_share_link($action = 'print') { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - if($action == 'print') +function wpsc_akst_share_link( $action = 'print' ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + if ( $action == 'print' ) { echo '
'; - else + } else { return '
'; + } + return false; } function wpsc_akst_share_form() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } function wpsc_has_shipping_form() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } @@ -444,14 +495,16 @@ function wpsc_has_shipping_form() { */ function wpsc_is_admin() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - global $pagenow; + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + global $pagenow; - $current_screen = get_current_screen(); + $current_screen = get_current_screen(); - if( 'post.php' == $pagenow && 'wpsc-product' == $current_screen->post_type ) return true; + if ( 'post.php' == $pagenow && 'wpsc-product' == $current_screen->post_type ) { + return true; + } - return false; + return false; } @@ -473,6 +526,7 @@ function wpsc_print_product_list() { */ function wpsc_total_product_count() { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return wpsc_product_count(); } @@ -485,7 +539,7 @@ function wpsc_total_product_count() { class WPSC_Query extends WP_Query { function WPSC_Query( $query = '' ) { _wpsc_deprecated_function( __FUNCTION__, '3.8', 'WP_Query()' ); - $query = wp_parse_args( $query ); + $query = wp_parse_args( $query ); $query['post_type'] = 'wpsc-product'; parent::WP_Query( $query ); } @@ -493,6 +547,7 @@ function WPSC_Query( $query = '' ) { function wpec_get_the_post_id_by_shortcode( $shortcode ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'wpsc_get_the_post_id_by_shortcode' ); + return wpsc_get_the_post_id_by_shortcode( $shortcode ); } @@ -521,13 +576,14 @@ function wpsc_check_permalink_notice() { /** * @deprecated since 3.8.8. Not used in core any more. */ -function wpsc_display_tracking_id(){ +function wpsc_display_tracking_id() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - $value = wpsc_trackingid_value(); - if(!empty($value)) - return $value; - else - return __('Add New','wpsc'); + $value = wpsc_trackingid_value(); + if ( ! empty( $value ) ) { + return $value; + } else { + return __( 'Add New', 'wpsc' ); + } } /** @@ -535,11 +591,12 @@ function wpsc_display_tracking_id(){ */ function wpsc_the_purch_item_price() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - if ( $purchlogs->purchitem->processed > 1 && $purchlogs->purchitem->processed != 6 ) { - $purchlogs->totalAmount += $purchlogs->purchitem->totalprice; - } - return $purchlogs->purchitem->totalprice; + global $purchlogs; + if ( $purchlogs->purchitem->processed > 1 && $purchlogs->purchitem->processed != 6 ) { + $purchlogs->totalAmount += $purchlogs->purchitem->totalprice; + } + + return $purchlogs->purchitem->totalprice; } /** @@ -547,8 +604,9 @@ function wpsc_the_purch_item_price() { */ function wpsc_the_purch_item_date() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return date( 'M d Y,g:i a', $purchlogs->purchitem->date ); + global $purchlogs; + + return date( 'M d Y,g:i a', $purchlogs->purchitem->date ); } /** @@ -556,12 +614,12 @@ function wpsc_the_purch_item_date() { */ function wpsc_the_purch_item_name() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - if ( wpsc_purchlogs_has_customfields( wpsc_the_purch_item_id() ) ) { - return $purchlogs->the_purch_item_name() . '' . esc_attr__( 'exclamation icon', 'wpsc' ) . ''; - } else { - return $purchlogs->the_purch_item_name(); - } + global $purchlogs; + if ( wpsc_purchlogs_has_customfields( wpsc_the_purch_item_id() ) ) { + return $purchlogs->the_purch_item_name() . '' . esc_attr__( 'exclamation icon', 'wpsc' ) . ''; + } else { + return $purchlogs->the_purch_item_name(); + } } /** @@ -569,8 +627,9 @@ function wpsc_the_purch_item_name() { */ function wpsc_the_purch_item_id() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->purchitem->id; + global $purchlogs; + + return $purchlogs->purchitem->id; } /** @@ -578,8 +637,9 @@ function wpsc_the_purch_item_id() { */ function wpsc_the_purch_item_details() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->the_purch_item_details(); + global $purchlogs; + + return $purchlogs->the_purch_item_details(); } //status loop functions @@ -589,8 +649,9 @@ function wpsc_the_purch_item_details() { */ function wpsc_have_purch_items_statuses() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->have_purch_status(); + global $purchlogs; + + return $purchlogs->have_purch_status(); } /** @@ -598,8 +659,9 @@ function wpsc_have_purch_items_statuses() { */ function wpsc_the_purch_status() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->the_purch_status(); + global $purchlogs; + + return $purchlogs->the_purch_status(); } /** @@ -607,12 +669,12 @@ function wpsc_the_purch_status() { */ function wpsc_purchlogs_is_google_checkout() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - if ( $purchlogs->purchitem->gateway == 'google' ) { - return true; - } else { - return false; - } + global $purchlogs; + if ( $purchlogs->purchitem->gateway == 'google' ) { + return true; + } else { + return false; + } } /** @@ -620,8 +682,9 @@ function wpsc_purchlogs_is_google_checkout() { */ function wpsc_the_purch_total() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->totalAmount; + global $purchlogs; + + return $purchlogs->totalAmount; } /** @@ -629,12 +692,13 @@ function wpsc_the_purch_total() { */ function wpsc_the_purch_item() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - if ( isset( $_SESSION['newlogs'] ) ) { - $purchlogs->allpurchaselogs = $_SESSION['newlogs']; - $purchlogs->purch_item_count = count( $_SESSION['newlogs'] ); - } - return $purchlogs->the_purch_item(); + global $purchlogs; + if ( isset( $_SESSION['newlogs'] ) ) { + $purchlogs->allpurchaselogs = $_SESSION['newlogs']; + $purchlogs->purch_item_count = count( $_SESSION['newlogs'] ); + } + + return $purchlogs->the_purch_item(); } /** @@ -642,8 +706,9 @@ function wpsc_the_purch_item() { */ function wpsc_the_purch_item_statuses() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->the_purch_item_statuses(); + global $purchlogs; + + return $purchlogs->the_purch_item_statuses(); } /** @@ -651,8 +716,9 @@ function wpsc_the_purch_item_statuses() { */ function wpsc_the_purch_item_status() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->the_purch_item_status(); + global $purchlogs; + + return $purchlogs->the_purch_item_status(); } /** @@ -660,8 +726,9 @@ function wpsc_the_purch_item_status() { */ function wpsc_the_purch_status_id() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->purchstatus['order']; + global $purchlogs; + + return $purchlogs->purchstatus['order']; } /** @@ -677,10 +744,10 @@ function wpsc_purchlog_filter_by() { */ function wpsc_the_purch_status_name() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - if ( isset( $purchlogs->purchstatus['label'] ) ) { - return $purchlogs->purchstatus['label']; - } + global $purchlogs; + if ( isset( $purchlogs->purchstatus['label'] ) ) { + return $purchlogs->purchstatus['label']; + } } /** @@ -688,51 +755,52 @@ function wpsc_the_purch_status_name() { */ function wpsc_purchlogs_getfirstdates() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - $dates = $purchlogs->getdates(); - $fDate = ''; - foreach ( $dates as $date ) { - $is_selected = ''; - $cleanDate = date( 'M Y', $date['start'] ); - $value = $date["start"] . "_" . $date["end"]; - if ( $value == $_GET['view_purchlogs_by'] ) { - $is_selected = 'selected="selected"'; - } - $fDate .= ""; - } - return $fDate; + global $purchlogs; + $dates = $purchlogs->getdates(); + $fDate = ''; + foreach ( $dates as $date ) { + $is_selected = ''; + $cleanDate = date( 'M Y', $date['start'] ); + $value = $date["start"] . "_" . $date["end"]; + if ( $value == $_GET['view_purchlogs_by'] ) { + $is_selected = 'selected="selected"'; + } + $fDate .= ""; + } + + return $fDate; } /** * @deprecated since 3.8.8. Not used in core any more. */ -function wpsc_change_purchlog_view( $viewby, $status='' ) { +function wpsc_change_purchlog_view( $viewby, $status = '' ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - if ( $viewby == 'all' ) { - $dates = $purchlogs->getdates(); - $purchaselogs = $purchlogs->get_purchlogs( $dates, $status ); - $_SESSION['newlogs'] = $purchaselogs; - $purchlogs->allpurchaselogs = $purchaselogs; - } elseif ( $viewby == '3mnths' ) { - $dates = $purchlogs->getdates(); - $dates = array_slice( $dates, 0, 3 ); - $purchlogs->current_start_timestamp = $dates[count($dates)-1]['start']; - $purchlogs->current_end_timestamp = $dates[0]['end']; - $newlogs = $purchlogs->get_purchlogs( $dates, $status ); - $_SESSION['newlogs'] = $newlogs; - $purchlogs->allpurchaselogs = $newlogs; - } else { - - $dates = explode( '_', $viewby ); - $date[0]['start'] = $dates[0]; - $date[0]['end'] = $dates[1]; - $purchlogs->current_start_timestamp = $dates[0]; - $purchlogs->current_end_timestamp = $dates[1]; - $newlogs = $purchlogs->get_purchlogs( $date, $status ); - $_SESSION['newlogs'] = $newlogs; - $purchlogs->allpurchaselogs = $newlogs; - } + global $purchlogs; + if ( $viewby == 'all' ) { + $dates = $purchlogs->getdates(); + $purchaselogs = $purchlogs->get_purchlogs( $dates, $status ); + $_SESSION['newlogs'] = $purchaselogs; + $purchlogs->allpurchaselogs = $purchaselogs; + } elseif ( $viewby == '3mnths' ) { + $dates = $purchlogs->getdates(); + $dates = array_slice( $dates, 0, 3 ); + $purchlogs->current_start_timestamp = $dates[ count( $dates ) - 1 ]['start']; + $purchlogs->current_end_timestamp = $dates[0]['end']; + $newlogs = $purchlogs->get_purchlogs( $dates, $status ); + $_SESSION['newlogs'] = $newlogs; + $purchlogs->allpurchaselogs = $newlogs; + } else { + + $dates = explode( '_', $viewby ); + $date[0]['start'] = $dates[0]; + $date[0]['end'] = $dates[1]; + $purchlogs->current_start_timestamp = $dates[0]; + $purchlogs->current_end_timestamp = $dates[1]; + $newlogs = $purchlogs->get_purchlogs( $date, $status ); + $_SESSION['newlogs'] = $newlogs; + $purchlogs->allpurchaselogs = $newlogs; + } } /** @@ -740,11 +808,11 @@ function wpsc_change_purchlog_view( $viewby, $status='' ) { */ function wpsc_search_purchlog_view( $search ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - $newlogs = $purchlogs->search_purchlog_view( $search ); - $purchlogs->getDates(); - $purchlogs->purch_item_count = count( $newlogs ); - $purchlogs->allpurchaselogs = $newlogs; + global $purchlogs; + $newlogs = $purchlogs->search_purchlog_view( $search ); + $purchlogs->getDates(); + $purchlogs->purch_item_count = count( $newlogs ); + $purchlogs->allpurchaselogs = $newlogs; } /** @@ -752,32 +820,38 @@ function wpsc_search_purchlog_view( $search ) { */ function wpsc_purchlog_is_checked_status() { _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogitem, $purchlogs; + global $purchlogitem, $purchlogs; - if ( $purchlogs->purchstatus['order'] == $purchlogitem->extrainfo->processed ) { - return 'selected="selected"'; - } else { - return ''; - } + if ( $purchlogs->purchstatus['order'] == $purchlogitem->extrainfo->processed ) { + return 'selected="selected"'; + } else { + return ''; + } } /** * @deprecated since 3.8.9. Use _wpsc_country_dropdown_options instead. + * * @param string $selected_country ISO code of selected country + * * @return string output */ function country_list( $selected_country = null ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.9', '_wpsc_country_dropdown_options' ); + return _wpsc_country_dropdown_options( array( 'selected' => $selected_country ) ); } /** * @deprecated since 3.8.9. Use wpsc_get_the_product_tags() instead. + * * @param integer $id Product ID + * * @return array Product tags */ function get_the_product_tags( $id = 0 ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'wpsc_get_the_product_tags' ); + return wpsc_get_the_product_tags( $id ); } @@ -790,10 +864,11 @@ function wpsc_admin_product_listing( $parent_product = null, $args = array() ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.9' ); global $wp_query; - if ( empty( $args ) ) + if ( empty( $args ) ) { $args = $wp_query->query; + } - add_filter( 'the_title','esc_html' ); + add_filter( 'the_title', 'esc_html' ); $args = array_merge( $args, array( 'posts_per_page' => '-1' ) ); @@ -801,17 +876,17 @@ function wpsc_admin_product_listing( $parent_product = null, $args = array() ) { if ( ! $GLOBALS['wpsc_products'] ) : - ?> - - - - + + + + 'all_with_object_id' ) ); foreach ( $object_terms as $term ) { - if ( ! array_key_exists( $term->object_id, $object_terms_cache ) ) - $object_terms_cache[$term->object_id] = array(); + if ( ! array_key_exists( $term->object_id, $object_terms_cache ) ) { + $object_terms_cache[ $term->object_id ] = array(); + } - $object_terms_cache[$term->object_id][$term->parent] = $term->name; + $object_terms_cache[ $term->object_id ][ $term->parent ] = $term->name; } } $global_product = $product; - setup_postdata($product); - $product_post_type_object = get_post_type_object('wpsc-product'); + setup_postdata( $product ); + $product_post_type_object = get_post_type_object( 'wpsc-product' ); $current_user_can_edit_this_product = current_user_can( $product_post_type_object->cap->edit_post, $product->ID ); - $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; + $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; $post_owner = ( $current_user->ID == $product->post_author ? 'self' : 'other' ); - $edit_link = get_edit_post_link( $product->ID ); + $edit_link = get_edit_post_link( $product->ID ); - if ( isset( $object_terms_cache[$product->ID] ) ) { - ksort( $object_terms_cache[$product->ID] ); - $title = implode( ', ', $object_terms_cache[$product->ID] ); + if ( isset( $object_terms_cache[ $product->ID ] ) ) { + ksort( $object_terms_cache[ $product->ID ] ); + $title = implode( ', ', $object_terms_cache[ $product->ID ] ); } else { $title = get_the_title( $product->ID ); } - if ( empty( $title ) ) + if ( empty( $title ) ) { $title = __( '(no title)', 'wpsc' ); + } ?> - post_status ); ?> iedit ' valign="top"> - ID; ?>' + class='post_status ); ?> iedit ' valign="top"> + '', + 'title' => __( 'Name', 'wpsc' ), + 'weight' => __( 'Weight', 'wpsc' ), + 'stock' => __( 'Stock', 'wpsc' ), + 'price' => __( 'Price', 'wpsc' ), + 'sale_price' => __( 'Sale Price', 'wpsc' ), + 'SKU' => __( 'SKU', 'wpsc' ), + 'hidden_alerts' => '' + ); + } - if(empty($posts_columns)) - $posts_columns = array('image' => '', 'title' => __('Name', 'wpsc') , 'weight' => __('Weight', 'wpsc'), 'stock' => __('Stock', 'wpsc'), 'price' => __('Price', 'wpsc'), 'sale_price' => __('Sale Price', 'wpsc'), 'SKU' => __('SKU', 'wpsc'), 'hidden_alerts' => ''); + foreach ( $posts_columns as $column_name => $column_display_name ) { + $attributes = "class=\"$column_name column-$column_name\""; - foreach ( $posts_columns as $column_name=>$column_display_name ) { - $attributes = "class=\"$column_name column-$column_name\""; + switch ( $column_name ) { - switch ($column_name) { + case 'date': /* !date case */ + if ( '0000-00-00 00:00:00' == $product->post_date && 'date' == $column_name ) { + $t_time = $h_time = __( 'Unpublished', 'wpsc' ); + $time_diff = 0; + } else { + $t_time = get_the_time( __( 'Y/m/d g:i:s A', 'wpsc' ) ); + $m_time = $product->post_date; + $time = get_post_time( 'G', true, $post ); - case 'date': /* !date case */ - if ( '0000-00-00 00:00:00' == $product->post_date && 'date' == $column_name ) { - $t_time = $h_time = __( 'Unpublished', 'wpsc' ); - $time_diff = 0; - } else { - $t_time = get_the_time( __( 'Y/m/d g:i:s A', 'wpsc' ) ); - $m_time = $product->post_date; - $time = get_post_time('G', true, $post); + $time_diff = time() - $time; - $time_diff = time() - $time; + if ( $time_diff > 0 && $time_diff < 24 * 60 * 60 ) { + $h_time = sprintf( __( '%s ago', 'wpsc' ), human_time_diff( $time ) ); + } else { + $h_time = mysql2date( __( 'Y/m/d', 'wpsc' ), $m_time ); + } + } - if ( $time_diff > 0 && $time_diff < 24*60*60 ) - $h_time = sprintf( __( '%s ago', 'wpsc' ), human_time_diff( $time ) ); - else - $h_time = mysql2date(__( 'Y/m/d', 'wpsc' ), $m_time); - } + echo ''; + break; - echo ''; - break; + case 'title': /* !title case */ + $attributes = 'class="post-title column-title"'; + + $edit_link = wp_nonce_url( $edit_link, 'edit-product_' . $product->ID ); + ?> + + + + ID ); - ?> - + - - ID)) - $has_var = 'wpsc_has_variation'; - $actions = array(); - if ( $current_user_can_edit_this_product && 'trash' != $product->post_status ) { - $actions['edit'] = ''. __( 'Edit', 'wpsc' ) . ''; - //commenting this out for now as we are trying new variation ui quick edit boxes are open by default so we dont need this link. - //$actions['quick_edit'] = "".__('Quick Edit', 'wpsc').""; - } + $product_data['meta'] = array(); + $product_data['meta'] = get_post_meta( $product->ID, '' ); + foreach ( $product_data['meta'] as $meta_name => $meta_value ) { + $product_data['meta'][ $meta_name ] = maybe_unserialize( array_pop( $meta_value ) ); + } + $product_data['transformed'] = array(); + if ( ! isset( $product_data['meta']['_wpsc_product_metadata']['weight'] ) ) { + $product_data['meta']['_wpsc_product_metadata']['weight'] = ""; + } + if ( ! isset( $product_data['meta']['_wpsc_product_metadata']['weight_unit'] ) ) { + $product_data['meta']['_wpsc_product_metadata']['weight_unit'] = ""; + } - $actions = apply_filters('post_row_actions', $actions, $product); - $action_count = count($actions); - $i = 0; - echo '
'; + $product_data['transformed']['weight'] = wpsc_convert_weight( $product_data['meta']['_wpsc_product_metadata']['weight'], "pound", $product_data['meta']['_wpsc_product_metadata']['weight_unit'], false ); + $weight = $product_data['transformed']['weight']; + if ( $weight == '' ) { + $weight = '0'; + } + ?> +
+ $link ) { - ++$i; - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; - echo "$link$sep"; - } + break; - echo ''; - ?> - - - - ID, 'price', true); - ?> - - ID, ''); - foreach($product_data['meta'] as $meta_name => $meta_value) { - $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value)); - } - $product_data['transformed'] = array(); - if(!isset($product_data['meta']['_wpsc_product_metadata']['weight'])) $product_data['meta']['_wpsc_product_metadata']['weight'] = ""; - if(!isset($product_data['meta']['_wpsc_product_metadata']['weight_unit'])) $product_data['meta']['_wpsc_product_metadata']['weight_unit'] = ""; - - $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "pound", $product_data['meta']['_wpsc_product_metadata']['weight_unit'], false); - $weight = $product_data['transformed']['weight']; - if($weight == ''){ - $weight = '0'; - } - ?> - - ID, '_wpsc_stock', true); - ?> - - ID, '_wpsc_stock', true ); + ?> + + - - + + - - ID, '_wpsc_sku', true); - ?> - - ID, '_wpsc_special_price', true); - ?> - - - - + + ID, '_wpsc_sku', true ); + ?> + + - - ID, '_wpsc_special_price', true ); + ?> + + - - - - + + - - + + - - + + + + + + + + + + - - -post_type && 'trash' == $post->post_status && !in_array('trash', $post_status)) + $post = get_post( get_the_ID() ); + if ( ! empty( $post ) && 'wpsc-product' == $post->post_type && 'trash' == $post->post_status && ! in_array( 'trash', $post_status ) ) { $post_status[] = 'Trash'; + } return $post_status; } function wpsc_product_label_forms() { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; } -function wpsc_convert_weights($weight, $unit) { +function wpsc_convert_weights( $weight, $unit ) { _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_convert_weight' ); - if (is_array($weight)) { + if ( is_array( $weight ) ) { $weight = $weight['weight']; } - return wpsc_convert_weight( $weight, $unit, 'gram', true ); + + return wpsc_convert_weight( $weight, $unit, 'gram', true ); } /** @@ -1204,6 +1337,7 @@ function wpsc_convert_weights($weight, $unit) { function wpsc_in_the_loop() { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); global $wpsc_query; + return $wpsc_query->in_the_loop; } @@ -1214,6 +1348,7 @@ function wpsc_in_the_loop() { function wpsc_rewind_products() { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); global $wpsc_query; + return $wpsc_query->rewind_posts(); } @@ -1224,8 +1359,9 @@ function wpsc_rewind_products() { function wpsc_product_has_file() { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); global $wpsc_query, $wpdb; - if ( is_numeric( $wpsc_query->product['file'] ) && ($wpsc_query->product['file'] > 0) ) + if ( is_numeric( $wpsc_query->product['file'] ) && ( $wpsc_query->product['file'] > 0 ) ) { return true; + } return false; } @@ -1238,8 +1374,8 @@ function wpsc_currency_sign() { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); global $wpdb; $currency_sign_location = get_option( 'currency_sign_location' ); - $currency_type = get_option( 'currency_type' ); - $currency_symbol = $wpdb->get_var( $wpdb->prepare( "SELECT `symbol_html` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` = %d LIMIT 1", $currency_type ) ); + $currency_type = get_option( 'currency_type' ); + $currency_symbol = $wpdb->get_var( $wpdb->prepare( "SELECT `symbol_html` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` = %d LIMIT 1", $currency_type ) ); return $currency_symbol; } @@ -1252,6 +1388,7 @@ function wpsc_page_is_selected() { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); // determine if we are on this page global $wpsc_query; + return $wpsc_query->page['selected']; } @@ -1263,62 +1400,72 @@ function wpsc_page_url() { _wpsc_deprecated_function( __FUNCTION__, '3.8' ); // generate the page URL global $wpsc_query; + return $wpsc_query->page['url']; } function shipwire_build_xml( $log_id ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); + return WPSC_Shipwire::get_order_xml( $log_id ); } function shipwire_built_sync_xml() { _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); + return WPSC_Shipwire::get_inventory_xml(); } function shipwire_built_tracking_xml() { _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); + return WPSC_Shipwire::get_tracking_xml(); } function shipwire_send_sync_request( $xml ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); + return WPSC_Shipwire::send_inventory_request( $xml ); } function shipwire_sent_request( $xml ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); + return WPSC_Shipwire::send_order_request( $xml ); } function shipwire_send_tracking_request( $xml ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); + return WPSC_Shipwire::send_tracking_request( $xml ); } function wpsc_rage_where( $where ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8', 'wpsc_range_where()' ); - return wpsc_range_where( $where ); + _wpsc_deprecated_function( __FUNCTION__, '3.8.8', 'wpsc_range_where()' ); + + return wpsc_range_where( $where ); } /** * WPSC Product Variation Price Available * Gets the formatted lowest price of a product's available variations. * - * @param $product_id (int) Product ID - * @param $from_text (string) From text with price placeholder eg. 'from %s' - * @param $only_normal_price (bool) Don't show sale price + * @param $product_id (int) Product ID + * @param $from_text (string) From text with price placeholder eg. 'from %s' + * @param $only_normal_price (bool) Don't show sale price + * * @return (string) Number formatted price * * @uses wpsc_product_variation_price_from() */ function wpsc_product_variation_price_available( $product_id, $from_text = false, $only_normal_price = false ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.10', 'wpsc_product_variation_price_from()' ); + _wpsc_deprecated_function( __FUNCTION__, '3.8.10', 'wpsc_product_variation_price_from()' ); $args = array( 'from_text' => $from_text, 'only_normal_price' => $only_normal_price, 'only_in_stock' => true ); + return wpsc_product_variation_price_from( $product_id, $args ); } @@ -1334,6 +1481,7 @@ function wpsc_post_title_seo( $title ) { if ( $new_title != '' ) { $title = $new_title; } + return esc_html( $title ); } @@ -1344,10 +1492,15 @@ function wpsc_product_image_forms() { edit_multiple_image_gallery( $post ); -?> + ?> -

>

-> +

+ ID > 0 ) { - if ( has_post_thumbnail( $post->ID ) ) + if ( has_post_thumbnail( $post->ID ) ) { echo get_the_post_thumbnail( $post->ID, 'admin-product-thumbnails' ); + } $args = array( - 'post_type' => 'attachment', - 'numberposts' => -1, + 'post_type' => 'attachment', + 'numberposts' => - 1, 'post_status' => null, 'post_parent' => $post->ID, - 'orderby' => 'menu_order', - 'order' => 'ASC' + 'orderby' => 'menu_order', + 'order' => 'ASC' ); - $attached_images = (array)get_posts( $args ); + $attached_images = (array) get_posts( $args ); if ( count( $attached_images ) > 0 ) { foreach ( $attached_images as $images ) { $attached_image = wp_get_attachment_image( $images->ID, 'admin-product-thumbnails' ); - echo $attached_image. ' '; + echo $attached_image . ' '; } } @@ -1393,7 +1547,7 @@ function wpsc_media_upload_tab_gallery( $tabs ) { function wpsc_media_upload_url( $form_action_url ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); - $form_action_url = esc_url( add_query_arg( array( 'parent_page'=>'wpsc-edit-products' ) ) ); + $form_action_url = esc_url( add_query_arg( array( 'parent_page' => 'wpsc-edit-products' ) ) ); return $form_action_url; @@ -1445,8 +1599,10 @@ function wpsc_filter_delete_text( $translation, $text, $domain ) { if ( 'Delete' == $text && isset( $_REQUEST['post_id'] ) && isset( $_REQUEST['parent_page'] ) ) { $translations = &get_translations_for_domain( $domain ); - return $translations->translate( 'Trash' ) ; + + return $translations->translate( 'Trash' ); } + return $translation; } @@ -1465,9 +1621,13 @@ function wpsc_filter_feature_image_text( $translation, $text, $domain ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); if ( 'Use as featured image' == $text && isset( $_REQUEST['post_id'] ) ) { $post = get_post( $_REQUEST['post_id'] ); - if ( $post->post_type != 'wpsc-product' ) return $translation; + if ( $post->post_type != 'wpsc-product' ) { + return $translation; + } $translations = &get_translations_for_domain( $domain ); + return $translations->translate( 'Use as Product Thumbnail', 'wpsc' ); + //this will never happen, this is here only for gettexr to pick up the translation return __( 'Use as Product Thumbnail', 'wpsc' ); } @@ -1482,10 +1642,10 @@ function wpsc_display_invoice() { return; } - $purchase_id = (int)$_REQUEST['purchaselog_id']; - add_action('wpsc_packing_slip', 'wpsc_packing_slip'); - do_action('wpsc_before_packing_slip', $purchase_id); - do_action('wpsc_packing_slip', $purchase_id); + $purchase_id = (int) $_REQUEST['purchaselog_id']; + add_action( 'wpsc_packing_slip', 'wpsc_packing_slip' ); + do_action( 'wpsc_before_packing_slip', $purchase_id ); + do_action( 'wpsc_packing_slip', $purchase_id ); exit(); } @@ -1493,89 +1653,93 @@ function wpsc_packing_slip( $purchase_id ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); echo "" . __( 'Packing Slip', 'wpsc' ) . ""; global $wpdb; - $purch_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`=%d", $purchase_id ); - $purch_data = $wpdb->get_row( $purch_sql, ARRAY_A ) ; + $purch_sql = $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`=%d", $purchase_id ); + $purch_data = $wpdb->get_row( $purch_sql, ARRAY_A ); - $cartsql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=%d", $purchase_id ); - $cart_log = $wpdb->get_results($cartsql,ARRAY_A) ; - $j = 0; + $cartsql = $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=%d", $purchase_id ); + $cart_log = $wpdb->get_results( $cartsql, ARRAY_A ); + $j = 0; - if($cart_log != null) { + if ( $cart_log != null ) { echo "
\n\r"; echo apply_filters( 'wpsc_packing_slip_header', '

' . esc_html__( 'Packing Slip', 'wpsc' ) . "

\n\r" ); - echo "". esc_html__( 'Order', 'wpsc' )." # ".$purchase_id."

\n\r"; + echo "" . esc_html__( 'Order', 'wpsc' ) . " # " . $purchase_id . "

\n\r"; echo "
- -
+ +
'; + if ( 'excerpt' == $mode ) { + echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode ); + } else { + echo '' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . ''; + } + echo '
'; + if ( 'publish' == $product->post_status ) { + _e( 'Published', 'wpsc' ); + } elseif ( 'future' == $product->post_status ) { + if ( $time_diff > 0 ) { + echo '' . __( 'Missed schedule', 'wpsc' ) . ''; + } else { + _e( 'Scheduled', 'wpsc' ); + } + } else { + _e( 'Last Modified', 'wpsc' ); + } + echo '
'; - if ( 'excerpt' == $mode ) - echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode); - else - echo '' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . ''; - echo '
'; - if ( 'publish' == $product->post_status ) { - _e( 'Published', 'wpsc' ); - } elseif ( 'future' == $product->post_status ) { - if ( $time_diff > 0 ) - echo '' . __( 'Missed schedule', 'wpsc' ) . ''; - else - _e( 'Scheduled', 'wpsc' ); - } else { - _e( 'Last Modified', 'wpsc' ); - } - echo '
> + + post_status != 'trash' ) { ?> + + + + + + + <?php echo $product_alert[' + title='' class='product-alert-image' + src='/product-alert.jpg' alt=''/> + + + ID ) ) { + $has_var = 'wpsc_has_variation'; + } + $actions = array(); + if ( $current_user_can_edit_this_product && 'trash' != $product->post_status ) { + $actions['edit'] = '' . __( 'Edit', 'wpsc' ) . ''; + //commenting this out for now as we are trying new variation ui quick edit boxes are open by default so we dont need this link. + //$actions['quick_edit'] = "".__('Quick Edit', 'wpsc').""; + } + + $actions = apply_filters( 'post_row_actions', $actions, $product ); + $action_count = count( $actions ); + $i = 0; + echo '
'; + + foreach ( $actions as $action => $link ) { + ++ $i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + echo "$link$sep"; + } + + echo '
'; + ?> +
+ 'attachment', + 'numberposts' => 1, + 'post_status' => null, + 'post_parent' => $product->ID, + 'orderby' => 'menu_order', + 'order' => 'ASC' + ); + + if ( isset( $product->ID ) && has_post_thumbnail( $product->ID ) ) { + echo get_the_post_thumbnail( $product->ID, 'admin-product-thumbnails' ); + } else { + $image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif"; + ?> + ' + src='' alt='' + width='38' height='38'/> + + > - - post_status != 'trash' ) { ?> - - - - - - - <?php echo $product_alert[' title='' class='product-alert-image' src='/product-alert.jpg' alt='' /> - ID, 'price', true ); + ?> + > + + + + > + + + + - 'attachment', - 'numberposts' => 1, - 'post_status' => null, - 'post_parent' => $product->ID, - 'orderby' => 'menu_order', - 'order' => 'ASC' - ); - - if(isset($product->ID) && has_post_thumbnail($product->ID)){ - echo get_the_post_thumbnail($product->ID, 'admin-product-thumbnails'); - } else { - $image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif"; - ?> - ' src='' alt='' width='38' height='38' /> - - > - - - - > - - - - > - - - - > + + + + >ID); - if ( !empty( $categories ) ) { - $out = array(); - foreach ( $categories as $c ) - $out[] = " " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . ""; - echo join( ', ', $out ); - } else { - esc_html_e( 'Uncategorized', 'wpsc' ); - } - ?>>ID ); + if ( ! empty( $categories ) ) { + $out = array(); + foreach ( $categories as $c ) { + $out[] = " " . esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) ) . ""; + } + echo join( ', ', $out ); + } else { + esc_html_e( 'Uncategorized', 'wpsc' ); + } + ?>>ID); - if ( !empty( $tags ) ) { - $out = array(); - foreach ( $tags as $c ) - $out[] = " " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . ""; - echo join( ', ', $out ); - } else { - esc_html_e( 'No Tags', 'wpsc' ); - } - ?>> - - - -

-
> - - - >
- '; - comments_number("" . /* translators: comment count link */ _x( '0', 'comment count', 'wpsc' ) . '', "" . /* translators: comment count link */ _x('1', 'comment count', 'wpsc') . '', "" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count', 'wpsc') . ''); - if ( $pending_comments ) - echo ''; - ?> -
>ID ); + if ( ! empty( $tags ) ) { + $out = array(); + foreach ( $tags as $c ) { + $out[] = " " . esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'post_tag', 'display' ) ) . ""; + } + echo join( ', ', $out ); + } else { + esc_html_e( 'No Tags', 'wpsc' ); + } + ?>> + + + + +

+
>> + + + " . esc_html__( 'Edit', 'wpsc' ) . ""; } ?>> +
+ '; + } + comments_number( "" . /* translators: comment count link */ + _x( '0', 'comment count', 'wpsc' ) . '', "" . /* translators: comment count link */ + _x( '1', 'comment count', 'wpsc' ) . '', "" . /* translators: comment count link: % will be substituted by comment count */ + _x( '%', 'comment count', 'wpsc' ) . '' ); + if ( $pending_comments ) { + echo ''; + } + ?> +
+
ID) . "' class='delete'>" . __( 'Delete', 'wpsc' ) . ""; } ?>>ID ); ?>" . esc_html__( 'Edit', 'wpsc' ) . ""; + } ?>ID ) . "' class='delete'>" . __( 'Delete', 'wpsc' ) . ""; + } ?>ID ); ?>>ID ); ?>>ID ); ?>
\n\r"; - $form_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_SUBMITTED_FORM_DATA."` WHERE `log_id` = %d", $purchase_id ); - $input_data = $wpdb->get_results($form_sql,ARRAY_A); + $form_sql = $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` = %d", $purchase_id ); + $input_data = $wpdb->get_results( $form_sql, ARRAY_A ); - foreach($input_data as $input_row) { - $rekeyed_input[$input_row['form_id']] = $input_row; + foreach ( $input_data as $input_row ) { + $rekeyed_input[ $input_row['form_id'] ] = $input_row; } - if($input_data != null) { - $form_data = $wpdb->get_results( "SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' ORDER BY `checkout_order`" , ARRAY_A ); + if ( $input_data != null ) { + $form_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' ORDER BY `checkout_order`", ARRAY_A ); - foreach($form_data as $form_field) { + foreach ( $form_data as $form_field ) { - switch($form_field['type']) { + switch ( $form_field['type'] ) { case 'country': - $region_count_sql = $wpdb->prepare( "SELECT COUNT(`regions`.`id`) FROM `".WPSC_TABLE_REGION_TAX."` AS `regions` INNER JOIN `".WPSC_TABLE_CURRENCY_LIST."` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('%s')", $purch_data['billing_country'] ); + $region_count_sql = $wpdb->prepare( "SELECT COUNT(`regions`.`id`) FROM `" . WPSC_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('%s')", $purch_data['billing_country'] ); $delivery_region_count = $wpdb->get_var( $region_count_sql ); - if(is_numeric($purch_data['billing_region']) && ($delivery_region_count > 0)) - echo " \n\r"; + if ( is_numeric( $purch_data['billing_region'] ) && ( $delivery_region_count > 0 ) ) { + echo " \n\r"; + } - echo " \n\r"; - break; + echo " \n\r"; + break; case 'delivery_country': - if(is_numeric($purch_data['shipping_region']) && ($delivery_region_count > 0)) - echo " \n\r"; + if ( is_numeric( $purch_data['shipping_region'] ) && ( $delivery_region_count > 0 ) ) { + echo " \n\r"; + } - echo " \n\r"; - break; + echo " \n\r"; + break; case 'heading': - if($form_field['name'] == "Hidden Fields") - continue; - else - echo " \n\r"; - break; + if ( $form_field['name'] == "Hidden Fields" ) { + continue; + } else { + echo " \n\r"; + } + break; default: - if ($form_field['name']=="State" && !empty($purch_data['billing_region']) || $form_field['name']=="State" && !empty($purch_data['billing_region'])) + if ( $form_field['name'] == "State" && ! empty( $purch_data['billing_region'] ) || $form_field['name'] == "State" && ! empty( $purch_data['billing_region'] ) ) { echo ""; - else - echo " \n\r"; - break; + } else { + echo " \n\r"; + } + break; } } } else { - echo " \n\r"; - echo " \n\r"; - echo " \n\r"; - echo " \n\r"; + echo " \n\r"; + echo " \n\r"; + echo " \n\r"; + echo " \n\r"; } if ( 2 == get_option( 'payment_method' ) ) { $gateway_name = ''; global $nzshpcrt_gateways; - foreach( $nzshpcrt_gateways as $gateway ) { + foreach ( $nzshpcrt_gateways as $gateway ) { if ( $purch_data['gateway'] != 'testmode' ) { if ( $gateway['internalname'] == $purch_data['gateway'] ) { $gateway_name = $gateway['name']; } } else { - $gateway_name = esc_html__('Manual Payment', 'wpsc'); + $gateway_name = esc_html__( 'Manual Payment', 'wpsc' ); } } } @@ -1583,42 +1747,42 @@ function wpsc_packing_slip( $purchase_id ) { echo "
".esc_html__('State', 'wpsc').":".wpsc_get_region($purch_data['billing_region'])."
" . esc_html__( 'State', 'wpsc' ) . ":" . wpsc_get_region( $purch_data['billing_region'] ) . "
" . esc_html( $form_field['name'] ) . ":" . esc_html( $rekeyed_input[$form_field['id']]['value'] ) . "
" . esc_html( $form_field['name'] ) . ":" . esc_html( $rekeyed_input[ $form_field['id'] ]['value'] ) . "
".esc_html__('State', 'wpsc').":".wpsc_get_region($purch_data['shipping_region'])."
" . esc_html__( 'State', 'wpsc' ) . ":" . wpsc_get_region( $purch_data['shipping_region'] ) . "
" . esc_html( $form_field['name'] ) . ":" . esc_html( $rekeyed_input[ $form_field['id']]['value'] ) . "
" . esc_html( $form_field['name'] ) . ":" . esc_html( $rekeyed_input[ $form_field['id'] ]['value'] ) . "
" . esc_html( $form_field['name'] ) . ":
" . esc_html( $form_field['name'] ) . ":
" . esc_html( $form_field['name'] ) . ":". - ( isset( $rekeyed_input[$form_field['id']] ) ? esc_html( $rekeyed_input[$form_field['id']]['value'] ) : '' ) . - "
" . esc_html( $form_field['name'] ) . ":" . + ( isset( $rekeyed_input[ $form_field['id'] ] ) ? esc_html( $rekeyed_input[ $form_field['id'] ]['value'] ) : '' ) . + "
".esc_html__('Name', 'wpsc').":".$purch_data['firstname']." ".$purch_data['lastname']."
".esc_html__('Address', 'wpsc').":".$purch_data['address']."
".esc_html__('Phone', 'wpsc').":".$purch_data['phone']."
".esc_html__('Email', 'wpsc').":".$purch_data['email']."
" . esc_html__( 'Name', 'wpsc' ) . ":" . $purch_data['firstname'] . " " . $purch_data['lastname'] . "
" . esc_html__( 'Address', 'wpsc' ) . ":" . $purch_data['address'] . "
" . esc_html__( 'Phone', 'wpsc' ) . ":" . $purch_data['phone'] . "
" . esc_html__( 'Email', 'wpsc' ) . ":" . $purch_data['email'] . "
\n\r"; - do_action ('wpsc_packing_slip_extra_info',$purchase_id); + do_action( 'wpsc_packing_slip_extra_info', $purchase_id ); echo ""; echo ""; - echo " "; + echo " "; - echo " "; + echo " "; - echo " "; + echo " "; - echo " "; - echo ''; + echo " "; + echo ''; echo ''; - $endtotal = 0; - $all_donations = true; + $endtotal = 0; + $all_donations = true; $all_no_shipping = true; - $file_link_list = array(); - $total_shipping = 0; - foreach($cart_log as $cart_row) { + $file_link_list = array(); + $total_shipping = 0; + foreach ( $cart_log as $cart_row ) { $alternate = ""; - $j++; - if(($j % 2) != 0) { + $j ++; + if ( ( $j % 2 ) != 0 ) { $alternate = "class='alt'"; } // product ID will be $cart_row['prodid']. need to fetch name and stuff $variation_list = ''; - if($cart_row['donation'] != 1) { + if ( $cart_row['donation'] != 1 ) { $all_donations = false; } - if($cart_row['no_shipping'] != 1) { + if ( $cart_row['no_shipping'] != 1 ) { $shipping = $cart_row['pnp']; $total_shipping += $shipping; $all_no_shipping = false; @@ -1627,9 +1791,9 @@ function wpsc_packing_slip( $purchase_id ) { } $price = $cart_row['price'] * $cart_row['quantity']; - $gst = $price - ($price / (1+($cart_row['gst'] / 100))); + $gst = $price - ( $price / ( 1 + ( $cart_row['gst'] / 100 ) ) ); - if($gst > 0) { + if ( $gst > 0 ) { $tax_per_item = $gst / $cart_row['quantity']; } @@ -1652,11 +1816,10 @@ function wpsc_packing_slip( $purchase_id ) { echo " "; echo " "; - echo ''; @@ -1665,31 +1828,33 @@ function wpsc_packing_slip( $purchase_id ) { echo "
".esc_html__('Quantity', 'wpsc')." " . esc_html__( 'Quantity', 'wpsc' ) . " ".esc_html__('Name', 'wpsc')."" . esc_html__( 'Name', 'wpsc' ) . "".esc_html__('Price', 'wpsc')." " . esc_html__( 'Price', 'wpsc' ) . " ".esc_html__('Shipping', 'wpsc')." ' . esc_html__('Tax', 'wpsc') . '" . esc_html__( 'Shipping', 'wpsc' ) . " ' . esc_html__( 'Tax', 'wpsc' ) . '
"; - echo wpsc_currency_display($shipping ); + echo wpsc_currency_display( $shipping ); echo " '; echo wpsc_currency_display( $cart_row['tax_charged'] ); echo '
"; echo ''; - if ( floatval( $purch_data['discount_value'] ) ) - echo ''; - - echo ''; - echo ''; - //wpec_taxes - if($purch_data['wpec_taxes_total'] != 0.00) - { - echo ''; - } - echo ''; + if ( floatval( $purch_data['discount_value'] ) ) { + echo ''; + } + + echo ''; + echo ''; + //wpec_taxes + if ( $purch_data['wpec_taxes_total'] != 0.00 ) { + echo ''; + } + echo ''; echo '
'.esc_html__('Discount', 'wpsc').'(' . wpsc_currency_display( $purch_data['discount_value'] ) . ')
'.esc_html__('Base Shipping','wpsc').'' . wpsc_currency_display( $purch_data['base_shipping'] ) . '
'.esc_html__('Total Shipping','wpsc').'' . wpsc_currency_display( $purch_data['base_shipping'] + $total_shipping ) . '
'.esc_html__('Taxes','wpsc').'' . wpsc_currency_display( $purch_data['wpec_taxes_total'] ) . '
'.esc_html__('Total Price','wpsc').'' . wpsc_currency_display( $purch_data['totalprice'] ) . '
' . esc_html__( 'Discount', 'wpsc' ) . '(' . wpsc_currency_display( $purch_data['discount_value'] ) . ')
' . esc_html__( 'Base Shipping', 'wpsc' ) . '' . wpsc_currency_display( $purch_data['base_shipping'] ) . '
' . esc_html__( 'Total Shipping', 'wpsc' ) . '' . wpsc_currency_display( $purch_data['base_shipping'] + $total_shipping ) . '
' . esc_html__( 'Taxes', 'wpsc' ) . '' . wpsc_currency_display( $purch_data['wpec_taxes_total'] ) . '
' . esc_html__( 'Total Price', 'wpsc' ) . '' . wpsc_currency_display( $purch_data['totalprice'] ) . '
'; echo "\n\r"; } else { - echo "
".esc_html__('This users cart was empty', 'wpsc'); + echo "
" . esc_html__( 'This users cart was empty', 'wpsc' ); } } //other actions are here -if ( isset( $_GET['display_invoice'] ) && ( 'true' == $_GET['display_invoice'] ) ) +if ( isset( $_GET['display_invoice'] ) && ( 'true' == $_GET['display_invoice'] ) ) { add_action( 'admin_init', 'wpsc_display_invoice', 0 ); +} -if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc_display_invoice' == $_REQUEST['wpsc_admin_action'] ) ) +if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc_display_invoice' == $_REQUEST['wpsc_admin_action'] ) ) { add_action( 'admin_init', 'wpsc_display_invoice' ); +} /** @@ -1699,13 +1864,15 @@ function wpsc_packing_slip( $purchase_id ) { * remove_filter('http_api_curl', 'wpsc_curl_ssl'); * * @param resource $ch + * * @return resource $ch **/ function wpsc_curl_ssl( $ch ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.13', "add_filter( 'https_ssl_verify', '__return_false' )" ); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); + curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); + curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false ); + return $ch; } @@ -1717,7 +1884,8 @@ function wpsc_curl_ssl( $ch ) { * @deprecated since 3.8.13 */ function wpsc_get_cartmeta( $cart_item_id, $meta_key ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13', 'wpsc_get_cart_item_meta'); + _wpsc_deprecated_function( __FUNCTION__, '3.8.13', 'wpsc_get_cart_item_meta' ); + return wpsc_get_cart_item_meta( $cart_item_id, $meta_key, true ); } @@ -1728,7 +1896,8 @@ function wpsc_get_cartmeta( $cart_item_id, $meta_key ) { * @deprecated since 3.8.13 */ function wpsc_update_cartmeta( $cart_item_id, $meta_key, $meta_value ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13', 'wpsc_update_cart_item_meta'); + _wpsc_deprecated_function( __FUNCTION__, '3.8.13', 'wpsc_update_cart_item_meta' ); + return wpsc_update_cart_item_meta( $cart_item_id, $meta_key, $meta_value ); } @@ -1739,38 +1908,43 @@ function wpsc_update_cartmeta( $cart_item_id, $meta_key, $meta_value ) { * @deprecated since 3.8.13 */ function wpsc_delete_cartmeta( $cart_item_id, $meta_key, $meta_value = '' ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13', 'wpsc_delete_cart_item_meta'); + _wpsc_deprecated_function( __FUNCTION__, '3.8.13', 'wpsc_delete_cart_item_meta' ); + return wpsc_delete_cart_item_meta( $cart_item_id, $meta_key, $meta_value ); } function wpsc_get_exchange_rate( $from, $to ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); + return _wpsc_get_exchange_rate( $from, $to ); } /** * @access public + * * @param unknown $stuff * @param unknown $post_ID + * * @return string * @deprecated since 3.8.13.3 */ -function wpsc_the_featured_image_fix( $stuff, $post_ID ){ - _wpsc_deprecated_function( __FUNCTION__, '3.8.13.2', 'wpsc_the_featured_image_fix'); +function wpsc_the_featured_image_fix( $stuff, $post_ID ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13.2', 'wpsc_the_featured_image_fix' ); global $wp_query; $is_tax = is_tax( 'wpsc_product_category' ); $queried_object = get_queried_object(); - $is_single = is_single() && $queried_object->ID == $post_ID && get_post_type() == 'wpsc-product'; + $is_single = is_single() && $queried_object->ID == $post_ID && get_post_type() == 'wpsc-product'; if ( $is_tax || $is_single ) { $header_image = get_header_image(); - $stuff = ''; + $stuff = ''; - if ( $header_image ) + if ( $header_image ) { $stuff = ''; + } } remove_action( 'post_thumbnail_html', 'wpsc_the_featured_image_fix' ); @@ -1780,12 +1954,15 @@ function wpsc_the_featured_image_fix( $stuff, $post_ID ){ /** * @access public + * * @param string $meta_object_type Type of object metadata is for (e.g., variation. cart, etc) + * * @return string Name of the custom meta table defined in $wpdb, or the name as it would be defined * @deprecated since 3.8.13.4 */ function wpsc_meta_table_name( $meta_object_type ) { _wpsc_deprecated_function( __FUNCTION__, '3.8.14', '_wpsc_meta_table_name' ); + return _wpsc_meta_table_name( $meta_object_type ); } @@ -1795,14 +1972,14 @@ function wpsc_meta_table_name( $meta_object_type ) { * @access public * @deprecated since 3.8.14 */ -function wpsc_google_checkout(){ +function wpsc_google_checkout() { $currpage = wpsc_selfURL(); - if (array_search("google",(array)get_option('custom_gateway_options')) !== false && $currpage != get_option('shopping_cart_url')) { + if ( array_search( "google", (array) get_option( 'custom_gateway_options' ) ) !== false && $currpage != get_option( 'shopping_cart_url' ) ) { global $nzshpcrt_gateways; - foreach($nzshpcrt_gateways as $gateway) { - if($gateway['internalname'] == 'google' ) { + foreach ( $nzshpcrt_gateways as $gateway ) { + if ( $gateway['internalname'] == 'google' ) { $gateway_used = $gateway['internalname']; - $gateway['function'](true); + $gateway['function']( true ); } } } @@ -1814,10 +1991,10 @@ function wpsc_google_checkout(){ * @access public * @deprecated since 3.8.14 */ -function wpsc_empty_google_logs(){ +function wpsc_empty_google_logs() { global $wpdb; _wpsc_deprecated_function( __FUNCTION__, '3.8.14', 'wpsc_empty_google_logs' ); - $sql = $wpdb->prepare( "DELETE FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid` = '%s'", wpsc_get_customer_meta( 'checkout_session_id' ) ); + $sql = $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` = '%s'", wpsc_get_customer_meta( 'checkout_session_id' ) ); $wpdb->query( $sql ); wpsc_delete_customer_meta( 'checkout_session_id' ); } @@ -1846,11 +2023,11 @@ function _wpsc_deprecated_javascript_localization_vars() { $wpsc_deprecated_js_vars = array(); - $wpsc_deprecated_js_vars['WPSC_DIR_NAME'] = WPSC_DIR_NAME; - $wpsc_deprecated_js_vars['fileLoadingImage'] = WPSC_CORE_IMAGES_URL . '/loading.gif'; + $wpsc_deprecated_js_vars['WPSC_DIR_NAME'] = WPSC_DIR_NAME; + $wpsc_deprecated_js_vars['fileLoadingImage'] = WPSC_CORE_IMAGES_URL . '/loading.gif'; $wpsc_deprecated_js_vars['fileBottomNavCloseImage'] = WPSC_CORE_IMAGES_URL . '/closelabel.gif'; - $wpsc_deprecated_js_vars['resizeSpeed'] = 9; // controls the speed of the image resizing (1=slowest and 10=fastest) - $wpsc_deprecated_js_vars['borderSize'] = 10; //if you adjust the padding in the CSS, you will need to update this variable + $wpsc_deprecated_js_vars['resizeSpeed'] = 9; // controls the speed of the image resizing (1=slowest and 10=fastest) + $wpsc_deprecated_js_vars['borderSize'] = 10; //if you adjust the padding in the CSS, you will need to update this variable return $wpsc_deprecated_js_vars; } @@ -1866,7 +2043,7 @@ function wpsc_google_checkout_submit() { _wpsc_deprecated_function( __FUNCTION__, '3.8.14' ); global $wpdb, $wpsc_cart, $current_user; - $wpsc_checkout = new wpsc_checkout(); + $wpsc_checkout = new wpsc_checkout(); $purchase_log_id = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` IN(%s) LIMIT 1", wpsc_get_customer_meta( 'checkout_session_id' ) ); get_currentuserinfo(); if ( $current_user->display_name != '' ) { @@ -1906,25 +2083,25 @@ function wpsc_admin_dynamic_css() { $flash = apply_filters( 'flash_uploader', $flash ); if ( 1 == $flash ) { -?> + ?> div.flash-image-uploader { - display: block; + display: block; } div.browser-image-uploader { - display: none; + display: none; } - + ?> div.flash-image-uploader { - display: none; + display: none; } div.browser-image-uploader { - display: block; + display: block; } -

- a bug in WordPress prior to version 3.3, you might run into 404 errors when viewing your products. To work around this, upgrade to WordPress 3.3 or later, or simply click "Save Changes" below a second time.' , 'wpsc' ), 'http://core.trac.wordpress.org/ticket/16736', 'http://codex.wordpress.org/Updating_WordPress' ); ?> + a bug in WordPress prior to version 3.3, you might run into 404 errors when viewing your products. To work around this, upgrade to WordPress 3.3 or later, or simply click "Save Changes" below a second time.', 'wpsc' ), 'http://core.trac.wordpress.org/ticket/16736', 'http://codex.wordpress.org/Updating_WordPress' ); ?>

id != 'wpsc-product' ) + if ( $current_screen->id != 'wpsc-product' ) { return $context; + } + return __( 'Upload Image%s', 'wpsc' ); } @@ -2001,10 +2180,11 @@ function change_link( $link ) { global $post_ID; $current_screen = get_current_screen(); - if ( $current_screen && $current_screen->id != 'wpsc-product' ) + if ( $current_screen && $current_screen->id != 'wpsc-product' ) { return $link; + } - $uploading_iframe_ID = $post_ID; + $uploading_iframe_ID = $post_ID; $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID"; return $media_upload_iframe_src . "&type=image&parent_page=wpsc-edit-products"; @@ -2022,7 +2202,6 @@ function wpsc_google_shipping_settings() { foreach ( (array) $_POST['google_shipping'] as $key => $country ) { if ( $country == 'on' ) { $google_shipping_country[] = $key; - $updated++; } } update_option( 'google_shipping_country', $google_shipping_country ); @@ -2038,7 +2217,7 @@ function wpsc_google_shipping_settings() { } } -if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'google_shipping_settings') ) { +if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( $_REQUEST['wpsc_admin_action'] == 'google_shipping_settings' ) ) { add_action( 'admin_init', 'wpsc_google_shipping_settings' ); } @@ -2049,7 +2228,7 @@ function wpsc_css_header() { /** * deprecating item filters from wpsc_display_form_fields() in release 3.8.13.4 * - * @deprecated 3.8.14 + * @deprecated 3.8.14 * * This function displays each of the form fields. * @@ -2058,25 +2237,26 @@ function wpsc_css_header() { * 'wpsc_account_form_field_shippingfirstname' - while Your Billing Details would be filtered * via 'wpsc_account_form_field_your-billing-details'. * - * @param varies $meta_value - * @param string $meta_key + * @param varies $meta_value + * @param string $meta_key * */ function wpsc_user_log_deprecated_filter_values( $meta_value, $meta_key ) { $filter = 'wpsc_account_form_field_' . $meta_key; if ( has_filter( $filter ) ) { - $meta_value = apply_filters( $filter , esc_html( $meta_value ) ); + $meta_value = apply_filters( $filter, esc_html( $meta_value ) ); _wpsc_doing_it_wrong( $filter, __( 'The filter being used has been deprecated. Use wpsc_get_visitor_meta or wpsc_get_visitor_meta_$neta_name instead.' ), '3.8.14' ); } return $meta_value; } + add_filter( 'wpsc_get_visitor_meta', 'wpsc_user_log_deprecated_filter_values', 10, 2 ); /** * deprecating user log filter for getting all customer meta as an array. * - *@deprecated 3.8.14 + * @deprecated 3.8.14 * * @return none */ @@ -2113,3 +2293,345 @@ function _wpsc_action_user_update_errors( $errors, $update, $user ) { } // add_action( 'user_profile_update_errors', '_wpsc_action_user_update_errors', 10, 3 ); + + +/** + * Adjust countires data structures to contain information that is in the database, where the countries + * data was mainatined prior to this change + * + * @param array countries data + * + * @deprecated 4.1 + * + * @return array + */ +function _wpsc_merge_legacy_countries_data_from_db( $countries ) { + + $legacy_countries_data = get_option( 'wpsc_legacy_countries_data', - 1 ); + if ( - 1 == $legacy_countries_data ) { + if ( function_exists( '_wpsc_extract_legacy_countries_data' ) ) { + $legacy_countries_data = _wpsc_extract_legacy_countries_data( $countries ); + } else { + $legacy_countries_data = array(); + } + + update_option( 'wpsc_legacy_countries_data', $legacy_countries_data ); + } + + foreach ( $legacy_countries_data as $country_id => $country_array ) { + if ( empty( $country_array ) && isset( $countries[ $country_id ] ) ) { + unset( $countries[ $country_id ] ); + } else { + $countries[ $country_id ] = $country_array; + } + } + + + global $wpdb; + + $sql = 'SELECT id, isocode, visible FROM ' . WPSC_TABLE_CURRENCY_LIST; + $legacy_visibilities = $wpdb->get_results( $sql ); + + $country_visibility_overrides = get_option( 'wpsc_country_visibility_overrides', -1 ); + if ( -1 == $country_visibility_overrides ) { + // make sure the option is initialized + $country_visibility_overrides = array(); + foreach( $legacy_visibilities as $legacy_visibility ) { + + $legacy_visibility->visible = (bool) $legacy_visibility->visible; + $legacy_visibility->id = intval( $legacy_visibility->id ); + + if ( isset( $countries[$legacy_visibility->id ] ) ) { + if ( $countries[$legacy_visibility->id ]['visible'] != $legacy_visibility->visible ) { + $country_visibility_overrides[ $legacy_visibility->isocode ] = $legacy_visibility->visible; + } + } + } + + update_option( 'wpsc_country_visibility_overrides', $country_visibility_overrides ); + } + + + return $countries; +} + +add_action( 'wpsc_get_countries_data_array', '_wpsc_merge_legacy_countries_data_from_db', 1, 1 ); + + +/** + * Compare countries data to what is in the database and compute an arrray of differences + * + * @param array $countries_data + * + * @deprecated 4.1 + * + * @return array + */ +function _wpsc_extract_legacy_countries_data( $countries_data ) { + + + + $differences = array(); + + // TODO: code it + + return $differences; + +} + +/** + * Adjust countires data structures to contain information that is in the database, where the countries + * data was mainatined prior to this change + * + * @param $regions + * + * @deprecated 4.1 + * + * @return array + */ +function _wpsc_merge_legacy_regions_data_from_db( $regions ) { + + $legacy_regions_data = get_option( 'wpsc_legacy_regions_data', - 1 ); + if ( - 1 == $legacy_regions_data ) { + if ( function_exists( '_wpsc_extract_legacy_regions_data' ) ) { + $legacy_regions_data = _wpsc_extract_legacy_regions_data( $regions ); + } else { + $legacy_regions_data = array(); + } + + update_option( 'wpsc_legacy_regions_data', $legacy_regions_data ); + } + + foreach ( $legacy_regions_data as $region_id => $region_array ) { + if ( empty( $region_array ) && isset( $regions[ $region_id ] ) ) { + unset( $regions[ $region_id ] ); + } else { + $regions[ $region_id ] = $region_array; + } + } + + return $regions; +} + +add_action( 'wpsc_get_regions_data_array', '_wpsc_merge_legacy_regions_data_from_db', 1, 1 ); + + +/** + * Compare regions data to what is in the database and compute an arrray of differences + * + * @param array $regions_data + * + * @deprecated 4.1 + * + * @return array + */ +function _wpsc_extract_legacy_regions_data( $rregions_data ) { + + $differences = array(); + + // TODO: code it + + return $differences; + +} + +if ( is_admin() ) { + add_filter( 'query', '_wpsc_check_for_countries_regions_changes', 10, 1 ); + /** + * Check if a query is updating the countries, region or currencies data and if so we remove any + * information we have about the changes to the default data + * + * @deprecated 4.1 + * + * @param $query + */ + function _wpsc_check_for_countries_regions_changes( $query ) { + + if ( is_admin() ) { + $changing_a_table_we_care_about = ( false !== stripos( $query, WPSC_TABLE_CURRENCY_LIST ) ) || ( false !== stripos( $query, WPSC_TABLE_REGION_TAX ) ); + if ( $changing_a_table_we_care_about ) { + if ( stripos( $query, 'update' ) || stripos( $query, 'delete' ) || stripos( $query, 'insert' ) ) { + // delete the options to force them to rebuild on the next request + delete_option( 'wpsc_legacy_countries_data' ); + delete_option( 'wpsc_legacy_regions_data' ); + } + } + } + + return $query; + } + +} + +/** + * Add currency and region tables to the gloval structure + * @deprecated 4.1 + */ +function wpsc_setup_deprecated_table_names() { + global $wpdb; + $wpdb->wpsc_currency_list = WPSC_TABLE_CURRENCY_LIST; + $wpdb->wpsc_region_tax = WPSC_TABLE_REGION_TAX; +} + +add_action( 'wpsc_setup_table_names', 'wpsc_setup_deprecated_table_names' ); + +/** + * Setup the currency and region tables + * + * @param array $wpsc_database_template + * + * @deprecated 4.1 + * + * @return array + */ +function wpsc_currency_and_region_tables( $wpsc_database_template ) { + global $wpdb; + + // code to create or update the {$wpdb->prefix}wpsc_currency_list table + $table_name = WPSC_TABLE_CURRENCY_LIST; /* !wpsc_currency_list */ + $wpsc_database_template[ $table_name ]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment"; + $wpsc_database_template[ $table_name ]['columns']['country'] = "varchar(255) NOT NULL DEFAULT '' "; + $wpsc_database_template[ $table_name ]['columns']['isocode'] = "char(2) NULL DEFAULT '' "; + $wpsc_database_template[ $table_name ]['columns']['currency'] = "varchar(255) NOT NULL DEFAULT '' "; + $wpsc_database_template[ $table_name ]['columns']['symbol'] = "varchar(10) NOT NULL DEFAULT '' "; + $wpsc_database_template[ $table_name ]['columns']['symbol_html'] = "varchar(10) NOT NULL DEFAULT '' "; + $wpsc_database_template[ $table_name ]['columns']['code'] = "char(3) NOT NULL DEFAULT '' "; + $wpsc_database_template[ $table_name ]['columns']['has_regions'] = "char(1) NOT NULL DEFAULT '0' "; + $wpsc_database_template[ $table_name ]['columns']['tax'] = "varchar(8) NOT NULL DEFAULT '' "; + $wpsc_database_template[ $table_name ]['columns']['continent'] = "varchar(20) NOT NULL DEFAULT '' "; + $wpsc_database_template[ $table_name ]['columns']['visible'] = "varchar(1) NOT NULL DEFAULT '1' "; + $wpsc_database_template[ $table_name ]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )"; + $wpsc_database_template[ $table_name ]['actions']['after']['all'] = "wpsc_add_currency_list"; + $wpsc_database_template[ $table_name ]['previous_names'] = "{$wpdb->prefix}currency_list"; + + // code to create or update the {$wpdb->prefix}wpsc_region_tax table + $table_name = WPSC_TABLE_REGION_TAX; /* !wpsc_region_tax */ + $wpsc_database_template[ $table_name ]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment"; + $wpsc_database_template[ $table_name ]['columns']['country_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' "; + $wpsc_database_template[ $table_name ]['columns']['name'] = "varchar(64) NOT NULL DEFAULT '' "; + $wpsc_database_template[ $table_name ]['columns']['code'] = "char(2) NOT NULL DEFAULT '' "; + $wpsc_database_template[ $table_name ]['columns']['tax'] = "float NOT NULL DEFAULT '0' "; + $wpsc_database_template[ $table_name ]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )"; + $wpsc_database_template[ $table_name ]['indexes']['country_id'] = " KEY `country_id` ( `country_id` )"; + $wpsc_database_template[ $table_name ]['actions']['after']['all'] = "wpsc_add_region_list"; + $wpsc_database_template[ $table_name ]['previous_names'] = "{$wpdb->prefix}region_tax"; + + return $wpsc_database_template; +} + +add_filter( 'wpsc_alter_database_template', 'wpsc_currency_and_region_tables', 1, 1 ); + + +/** + * wpsc_add_currency_list function, converts values to decimal to satisfy mySQL strict mode + * + * @deprecated 4.1 + * + * * @return boolean true on success, false on failure + */ +function wpsc_add_currency_list() { + global $wpdb, $currency_sql; + require_once(WPSC_FILE_PATH . "/wpsc-updates/currency_list.php"); + $currency_data = $wpdb->get_var( "SELECT COUNT(*) AS `count` FROM `" . WPSC_TABLE_CURRENCY_LIST . "`" ); + if ( $currency_data == 0 ) { + $currency_array = explode( "\n", $currency_sql ); + foreach ( $currency_array as $currency_row ) { + $wpdb->query( $currency_row ); + } + } +} + +/** + * wpsc_add_region_list function, converts values to decimal to satisfy mySQL strict mode + * + * @deprecated 4.1 + * + * @return boolean true on success, false on failure + */ +function wpsc_add_region_list() { + global $wpdb; + $add_regions = $wpdb->get_var( "SELECT COUNT(*) AS `count` FROM `" . WPSC_TABLE_REGION_TAX . "`" ); + if ( $add_regions < 1 ) { + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Alberta', 'AB', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'British Columbia', 'BC', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Manitoba', 'MB', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'New Brunswick', 'NB', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Newfoundland and Labrador', 'NL', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Northwest Territories', 'NT', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Nova Scotia', 'NS', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Nunavut', 'NU', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Ontario', 'ON', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Prince Edward Island', 'PE', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Quebec', 'QC', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Saskatchewan', 'SK', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Yukon', 'YK', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Alabama', 'AL', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Alaska', 'AK', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Arizona', 'AZ', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Arkansas', 'AR', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'California', 'CA', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Colorado', 'CO', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Connecticut', 'CT', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Delaware', 'DE', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Florida', 'FL', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Georgia', 'GA', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Hawaii', 'HI', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Idaho', 'ID', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Illinois', 'IL', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Indiana', 'IN', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Iowa', 'IA', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Kansas', 'KS', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Kentucky', 'KY', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Louisiana', 'LA', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Maine', 'ME', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Maryland', 'MD', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Massachusetts', 'MA', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Michigan', 'MI', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Minnesota', 'MN', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Mississippi', 'MS', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Missouri', 'MO', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Montana', 'MT', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Nebraska', 'NE', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Nevada', 'NV', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'New Hampshire', 'NH', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'New Jersey', 'NJ', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'New Mexico', 'NM', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'New York', 'NY', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'North Carolina', 'NC', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'North Dakota', 'ND', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Ohio', 'OH', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Oklahoma', 'OK', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Oregon', 'OR', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Pennsylvania', 'PA', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Rhode Island', 'RI', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'South Carolina', 'SC', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'South Dakota', 'SD', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Tennessee', 'TN', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Texas', 'TX', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Utah', 'UT', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Vermont', 'VT', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Virginia', 'VA', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Washington', 'WA', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Washington DC', 'DC', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'West Virginia', 'WV', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Wisconsin', 'WI', '0')" ); + $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Wyoming', 'WY', '0')" ); + } + + if ( $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `code`=''" ) > 0 ) { + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'AB' WHERE `name` IN('Alberta') LIMIT 1 ;" ); + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'BC' WHERE `name` IN('British Columbia') LIMIT 1 ;" ); + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'MB' WHERE `name` IN('Manitoba') LIMIT 1 ;" ); + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'NK' WHERE `name` IN('New Brunswick') LIMIT 1 ;" ); + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'NF' WHERE `name` IN('Newfoundland') LIMIT 1 ;" ); + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'NT' WHERE `name` IN('Northwest Territories') LIMIT 1 ;" ); + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'NS' WHERE `name` IN('Nova Scotia') LIMIT 1 ;" ); + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'ON' WHERE `name` IN('Ontario') LIMIT 1 ;" ); + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'PE' WHERE `name` IN('Prince Edward Island') LIMIT 1 ;" ); + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'PQ' WHERE `name` IN('Quebec') LIMIT 1 ;" ); + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'SN' WHERE `name` IN('Saskatchewan') LIMIT 1 ;" ); + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'YT' WHERE `name` IN('Yukon') LIMIT 1 ;" ); + $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'NU' WHERE `name` IN('Nunavut') LIMIT 1 ;" ); + } +} + diff --git a/wpsc-core/wpsc-includes.php b/wpsc-core/wpsc-includes.php index 2f0822eb84..3e11e413ce 100644 --- a/wpsc-core/wpsc-includes.php +++ b/wpsc-core/wpsc-includes.php @@ -36,7 +36,6 @@ require_once( WPSC_FILE_PATH . '/wpsc-includes/meta.functions.php' ); require_once( WPSC_FILE_PATH . '/wpsc-includes/productfeed.php' ); require_once( WPSC_FILE_PATH . '/wpsc-includes/image_processing.php' ); -require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-data-map.class.php' ); require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-country.class.php' ); require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-countries.class.php' ); require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-region.class.php' ); @@ -49,6 +48,8 @@ require_once( WPSC_FILE_PATH . '/wpsc-includes/checkout-form.class.php' ); require_once( WPSC_FILE_PATH . '/wpsc-includes/checkout-form-data.class.php' ); require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-theme-engine-bootstrap.php' ); +require_once( WPSC_FILE_PATH . '/wpsc-includes/country-and-region-data.php' ); +require_once( WPSC_FILE_PATH . '/wpsc-includes/country-api.php' ); do_action( 'wpsc_loaded_module_'. basename( __FILE__ ) ); diff --git a/wpsc-core/wpsc-installer.php b/wpsc-core/wpsc-installer.php index 816ec29c91..450b6a2bab 100644 --- a/wpsc-core/wpsc-installer.php +++ b/wpsc-core/wpsc-installer.php @@ -436,6 +436,7 @@ function wpsc_create_or_update_tables( $debug = false ) { global $wpdb; // creates or updates the structure of the shopping cart tables + $wpsc_database_template = array(); include( WPSC_FILE_PATH . '/wpsc-updates/database_template.php' ); $template_hash = sha1( serialize( $wpsc_database_template ) ); @@ -593,116 +594,7 @@ function wpsc_create_or_update_tables( $debug = false ) { } } -/** - * The following functions are used exclusively in database_template.php - */ - -/** - * wpsc_add_currency_list function, converts values to decimal to satisfy mySQL strict mode - * * @return boolean true on success, false on failure - */ -function wpsc_add_currency_list() { - global $wpdb, $currency_sql; - require_once(WPSC_FILE_PATH . "/wpsc-updates/currency_list.php"); - $currency_data = $wpdb->get_var( "SELECT COUNT(*) AS `count` FROM `" . WPSC_TABLE_CURRENCY_LIST . "`" ); - if ( $currency_data == 0 ) { - $currency_array = explode( "\n", $currency_sql ); - foreach ( $currency_array as $currency_row ) { - $wpdb->query( $currency_row ); - } - } -} -/** - * wpsc_add_region_list function, converts values to decimal to satisfy mySQL strict mode - * * @return boolean true on success, false on failure - */ -function wpsc_add_region_list() { - global $wpdb; - $add_regions = $wpdb->get_var( "SELECT COUNT(*) AS `count` FROM `" . WPSC_TABLE_REGION_TAX . "`" ); - if ( $add_regions < 1 ) { - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Alberta', 'AB', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'British Columbia', 'BC', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Manitoba', 'MB', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'New Brunswick', 'NB', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Newfoundland and Labrador', 'NL', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Northwest Territories', 'NT', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Nova Scotia', 'NS', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Nunavut', 'NU', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Ontario', 'ON', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Prince Edward Island', 'PE', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Quebec', 'QC', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Saskatchewan', 'SK', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Yukon', 'YK', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Alabama', 'AL', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Alaska', 'AK', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Arizona', 'AZ', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Arkansas', 'AR', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'California', 'CA', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Colorado', 'CO', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Connecticut', 'CT', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Delaware', 'DE', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Florida', 'FL', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Georgia', 'GA', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Hawaii', 'HI', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Idaho', 'ID', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Illinois', 'IL', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Indiana', 'IN', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Iowa', 'IA', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Kansas', 'KS', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Kentucky', 'KY', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Louisiana', 'LA', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Maine', 'ME', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Maryland', 'MD', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Massachusetts', 'MA', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Michigan', 'MI', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Minnesota', 'MN', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Mississippi', 'MS', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Missouri', 'MO', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Montana', 'MT', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Nebraska', 'NE', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Nevada', 'NV', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'New Hampshire', 'NH', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'New Jersey', 'NJ', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'New Mexico', 'NM', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'New York', 'NY', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'North Carolina', 'NC', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'North Dakota', 'ND', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Ohio', 'OH', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Oklahoma', 'OK', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Oregon', 'OR', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Pennsylvania', 'PA', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Rhode Island', 'RI', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'South Carolina', 'SC', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'South Dakota', 'SD', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Tennessee', 'TN', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Texas', 'TX', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Utah', 'UT', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Vermont', 'VT', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Virginia', 'VA', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Washington', 'WA', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Washington DC', 'DC', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'West Virginia', 'WV', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Wisconsin', 'WI', '0')" ); - $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '136', 'Wyoming', 'WY', '0')" ); - } - - if ( $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `code`=''" ) > 0 ) { - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'AB' WHERE `name` IN('Alberta') LIMIT 1 ;" ); - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'BC' WHERE `name` IN('British Columbia') LIMIT 1 ;" ); - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'MB' WHERE `name` IN('Manitoba') LIMIT 1 ;" ); - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'NK' WHERE `name` IN('New Brunswick') LIMIT 1 ;" ); - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'NF' WHERE `name` IN('Newfoundland') LIMIT 1 ;" ); - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'NT' WHERE `name` IN('Northwest Territories') LIMIT 1 ;" ); - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'NS' WHERE `name` IN('Nova Scotia') LIMIT 1 ;" ); - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'ON' WHERE `name` IN('Ontario') LIMIT 1 ;" ); - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'PE' WHERE `name` IN('Prince Edward Island') LIMIT 1 ;" ); - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'PQ' WHERE `name` IN('Quebec') LIMIT 1 ;" ); - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'SN' WHERE `name` IN('Saskatchewan') LIMIT 1 ;" ); - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'YT' WHERE `name` IN('Yukon') LIMIT 1 ;" ); - $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `code` = 'NU' WHERE `name` IN('Nunavut') LIMIT 1 ;" ); - } -} /** * wpsc_add_checkout_fields function, converts values to decimal to satisfy mySQL strict mode diff --git a/wpsc-includes/country-and-region-data.php b/wpsc-includes/country-and-region-data.php new file mode 100644 index 0000000000..f27a4ace5f --- /dev/null +++ b/wpsc-includes/country-and-region-data.php @@ -0,0 +1,3475 @@ + array( + 'name' => __('Mauritania', 'wpsc'), + 'isocode' => 'MR', + 'currency_name' => __('Mauritanian Ouguiya', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MRO', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 2 => array( + 'name' => __('Martinique (French)', 'wpsc'), + 'isocode' => 'MQ', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 3 => array( + 'name' => __('Malta', 'wpsc'), + 'isocode' => 'MT', + 'currency_name' => __('Maltese Lira', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MTL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 4 => array( + 'name' => __('Marshall Islands', 'wpsc'), + 'isocode' => 'MH', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 5 => array( + 'name' => __('Mali', 'wpsc'), + 'isocode' => 'ML', + 'currency_name' => __('CFA Franc BCEAO', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XOF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 6 => array( + 'name' => __('Maldives', 'wpsc'), + 'isocode' => 'MV', + 'currency_name' => __('Maldive Rufiyaa', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MVR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 7 => array( + 'name' => __('Malaysia', 'wpsc'), + 'isocode' => 'MY', + 'currency_name' => __('Malaysian Ringgit', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MYR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 8 => array( + 'name' => __('Malawi', 'wpsc'), + 'isocode' => 'MW', + 'currency_name' => __('Malawi Kwacha', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MWK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 9 => array( + 'name' => __('Madagascar', 'wpsc'), + 'isocode' => 'MG', + 'currency_name' => __('Malagasy Franc', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MGF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 10 => array( + 'name' => __('Macau', 'wpsc'), + 'isocode' => 'MO', + 'currency_name' => __('Macau Pataca', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MOP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 11 => array( + 'name' => __('Macedonia', 'wpsc'), + 'isocode' => 'MK', + 'currency_name' => __('Denar', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MKD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 12 => array( + 'name' => __('Luxembourg', 'wpsc'), + 'isocode' => 'LU', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 13 => array( + 'name' => __('Lithuania', 'wpsc'), + 'isocode' => 'LT', + 'currency_name' => __('Lithuanian Litas', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'LTL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 14 => array( + 'name' => __('Liechtenstein', 'wpsc'), + 'isocode' => 'LI', + 'currency_name' => __('Swiss Franc', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'CHF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 15 => array( + 'name' => __('Libya', 'wpsc'), + 'isocode' => 'LY', + 'currency_name' => __('Libyan Dinar', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'LYD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 16 => array( + 'name' => __('Liberia', 'wpsc'), + 'isocode' => 'LR', + 'currency_name' => __('Liberian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'LRD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 17 => array( + 'name' => __('Lesotho', 'wpsc'), + 'isocode' => 'LS', + 'currency_name' => __('Lesotho Loti', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'LSL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 18 => array( + 'name' => __('Lebanon', 'wpsc'), + 'isocode' => 'LB', + 'currency_name' => __('Lebanese Pound', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'LBP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 19 => array( + 'name' => __('Latvia', 'wpsc'), + 'isocode' => 'LV', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 20 => array( + 'name' => __('Laos', 'wpsc'), + 'isocode' => 'LA', + 'currency_name' => __('Lao Kip', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'LAK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 21 => array( + 'name' => __('Kyrgyzstan', 'wpsc'), + 'isocode' => 'KG', + 'currency_name' => __('Som', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'KGS', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 22 => array( + 'name' => __('Kuwait', 'wpsc'), + 'isocode' => 'KW', + 'currency_name' => __('Kuwaiti Dinar', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'KWD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 23 => array( + 'name' => __('Korea, South', 'wpsc'), + 'isocode' => 'KR', + 'currency_name' => __('Korean Won', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'KRW', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 24 => array( + 'name' => __('Korea, North', 'wpsc'), + 'isocode' => 'KP', + 'currency_name' => __('North Korean Won', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'KPW', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 25 => array( + 'name' => __('Kiribati', 'wpsc'), + 'isocode' => 'KI', + 'currency_name' => __('Australian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'AUD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 26 => array( + 'name' => __('Kenya', 'wpsc'), + 'isocode' => 'KE', + 'currency_name' => __('Kenyan Shilling', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'KES', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 27 => array( + 'name' => __('Kazakhstan', 'wpsc'), + 'isocode' => 'KZ', + 'currency_name' => __('Kazakhstan Tenge', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'KZT', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 28 => array( + 'name' => __('Jordan', 'wpsc'), + 'isocode' => 'JO', + 'currency_name' => __('Jordanian Dinar', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'JOD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 29 => array( + 'name' => __('Jersey', 'wpsc'), + 'isocode' => 'JE', + 'currency_name' => __('Pound Sterling', 'wpsc'), + 'currency_symbol' => __( '£', 'wpsc' ), + 'currency_symbol_html' => '£', + 'currency_code' => 'GBP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 30 => array( + 'name' => __('Japan', 'wpsc'), + 'isocode' => 'JP', + 'currency_name' => __('Japanese Yen', 'wpsc'), + 'currency_symbol' => __( '¥', 'wpsc' ), + 'currency_symbol_html' => '¥', + 'currency_code' => 'JPY', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 31 => array( + 'name' => __('Jamaica', 'wpsc'), + 'isocode' => 'JM', + 'currency_name' => __('Jamaican Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'JMD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 32 => array( + 'name' => __('Ivory Coast', 'wpsc'), + 'isocode' => 'CI', + 'currency_name' => __('CFA Franc BCEAO', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XOF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 33 => array( + 'name' => __('Italy', 'wpsc'), + 'isocode' => 'IT', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 34 => array( + 'name' => __('Isle of Man', 'wpsc'), + 'isocode' => 'IM', + 'currency_name' => __('Pound Sterling', 'wpsc'), + 'currency_symbol' => __( '£', 'wpsc' ), + 'currency_symbol_html' => '£', + 'currency_code' => 'GBP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 35 => array( + 'name' => __('Israel', 'wpsc'), + 'isocode' => 'IL', + 'currency_name' => __('Israeli New Shekel', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'ILS', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 36 => array( + 'name' => __('Ireland', 'wpsc'), + 'isocode' => 'IE', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 37 => array( + 'name' => __('Iraq', 'wpsc'), + 'isocode' => 'IQ', + 'currency_name' => __('Iraqi Dinar', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'IQD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 38 => array( + 'name' => __('Indonesia', 'wpsc'), + 'isocode' => 'ID', + 'currency_name' => __('Indonesian Rupiah', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'IDR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 39 => array( + 'name' => __('Iran', 'wpsc'), + 'isocode' => 'IR', + 'currency_name' => __('Iranian Rial', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'IRR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 40 => array( + 'name' => __('India', 'wpsc'), + 'isocode' => 'IN', + 'currency_name' => __('Indian Rupee', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'INR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 41 => array( + 'name' => __('Iceland', 'wpsc'), + 'isocode' => 'IS', + 'currency_name' => __('Iceland Krona', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'ISK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 42 => array( + 'name' => __('Hungary', 'wpsc'), + 'isocode' => 'HU', + 'currency_name' => __('Hungarian Forint', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'HUF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 43 => array( + 'name' => __('Hong Kong', 'wpsc'), + 'isocode' => 'HK', + 'currency_name' => __('Hong Kong Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'HKD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 44 => array( + 'name' => __('Honduras', 'wpsc'), + 'isocode' => 'HN', + 'currency_name' => __('Honduran Lempira', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'HNL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 45 => array( + 'name' => __('Heard Island and McDonald Islands', 'wpsc'), + 'isocode' => 'HM', + 'currency_name' => __('Australian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'AUD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 46 => array( + 'name' => __('Haiti', 'wpsc'), + 'isocode' => 'HT', + 'currency_name' => __('Haitian Gourde', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'HTG', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 47 => array( + 'name' => __('Guyana', 'wpsc'), + 'isocode' => 'GY', + 'currency_name' => __('Guyana Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'GYD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 48 => array( + 'name' => __('Guinea Bissau', 'wpsc'), + 'isocode' => 'GW', + 'currency_name' => __('Guinea-Bissau Peso', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'GWP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 49 => array( + 'name' => __('Guinea', 'wpsc'), + 'isocode' => 'GN', + 'currency_name' => __('Guinea Franc', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'GNF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 50 => array( + 'name' => __('Guernsey', 'wpsc'), + 'isocode' => 'GF', + 'currency_name' => __('Pound Sterling', 'wpsc'), + 'currency_symbol' => __( '£', 'wpsc' ), + 'currency_symbol_html' => '£', + 'currency_code' => 'GBP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 51 => array( + 'name' => __('Guatemala', 'wpsc'), + 'isocode' => 'GT', + 'currency_name' => __('Guatemalan Quetzal', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'QTQ', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 52 => array( + 'name' => __('Guam (USA)', 'wpsc'), + 'isocode' => 'GU', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 53 => array( + 'name' => __('Grenada', 'wpsc'), + 'isocode' => 'GD', + 'currency_name' => __('East Carribean Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'XCD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 54 => array( + 'name' => __('Guadeloupe (French)', 'wpsc'), + 'isocode' => 'GP', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 55 => array( + 'name' => __('Greenland', 'wpsc'), + 'isocode' => 'GL', + 'currency_name' => __('Danish Krone', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'DKK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 56 => array( + 'name' => __('Greece', 'wpsc'), + 'isocode' => 'GR', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '19', + 'continent' => 'europe', + 'visible' => true + ), + 57 => array( + 'name' => __('Gibraltar', 'wpsc'), + 'isocode' => 'GI', + 'currency_name' => __('Gibraltar Pound', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'GIP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 58 => array( + 'name' => __('Ghana', 'wpsc'), + 'isocode' => 'GH', + 'currency_name' => __('Ghanaian Cedi', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'GHC', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 59 => array( + 'name' => __('Germany', 'wpsc'), + 'isocode' => 'DE', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 60 => array( + 'name' => __('Georgia', 'wpsc'), + 'isocode' => 'GE', + 'currency_name' => __('Georgian Lari', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'GEL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 61 => array( + 'name' => __('Gambia', 'wpsc'), + 'isocode' => 'GM', + 'currency_name' => __('Gambian Dalasi', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'GMD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 62 => array( + 'name' => __('Gabon', 'wpsc'), + 'isocode' => 'GA', + 'currency_name' => __('CFA Franc BEAC', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XAF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 63 => array( + 'name' => __('French Southern Territories', 'wpsc'), + 'isocode' => 'TF', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 64 => array( + 'name' => __('France', 'wpsc'), + 'isocode' => 'FR', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 65 => array( + 'name' => __('Finland', 'wpsc'), + 'isocode' => 'FI', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 66 => array( + 'name' => __('Fiji', 'wpsc'), + 'isocode' => 'FJ', + 'currency_name' => __('Fiji Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'FJD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 67 => array( + 'name' => __('Faroe Islands', 'wpsc'), + 'isocode' => 'FO', + 'currency_name' => __('Danish Krone', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'DKK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 68 => array( + 'name' => __('Falkland Islands', 'wpsc'), + 'isocode' => 'FK', + 'currency_name' => __('Falkland Islands Pound', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'FKP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 69 => array( + 'name' => __('Ethiopia', 'wpsc'), + 'isocode' => 'ET', + 'currency_name' => __('Ethiopian Birr', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'ETB', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 70 => array( + 'name' => __('Estonia', 'wpsc'), + 'isocode' => 'EE', + 'currency_name' => __('Estonian Kroon', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'EEK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 71 => array( + 'name' => __('Eritrea', 'wpsc'), + 'isocode' => 'ER', + 'currency_name' => __('Eritrean Nakfa', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'ERN', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 72 => array( + 'name' => __('Equatorial Guinea', 'wpsc'), + 'isocode' => 'GQ', + 'currency_name' => __('CFA Franc BEAC', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XAF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 73 => array( + 'name' => __('El Salvador', 'wpsc'), + 'isocode' => 'SV', + 'currency_name' => __('El Salvador Colon', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SVC', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 74 => array( + 'name' => __('Egypt', 'wpsc'), + 'isocode' => 'EG', + 'currency_name' => __('Egyptian Pound', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'EGP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 75 => array( + 'name' => __('Ecuador', 'wpsc'), + 'isocode' => 'EC', + 'currency_name' => __('Ecuador Sucre', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'ECS', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 76 => array( + 'name' => __('East Timor', 'wpsc'), + 'isocode' => 'TP', + 'currency_name' => __('Timor Escudo', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'TPE', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 77 => array( + 'name' => __('Dominican Republic', 'wpsc'), + 'isocode' => 'DO', + 'currency_name' => __('Dominican Peso', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'DOP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 78 => array( + 'name' => __('Dominica', 'wpsc'), + 'isocode' => 'DM', + 'currency_name' => __('East Caribbean Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'XCD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 79 => array( + 'name' => __('Djibouti', 'wpsc'), + 'isocode' => 'DJ', + 'currency_name' => __('Djibouti Franc', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'DJF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 80 => array( + 'name' => __('Denmark', 'wpsc'), + 'isocode' => 'DK', + 'currency_name' => __('Danish Krone', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'DKK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 81 => array( + 'name' => __('Democratic Republic of Congo', 'wpsc'), + 'isocode' => 'CD', + 'currency_name' => __('Francs', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'CDF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 82 => array( + 'name' => __('Czech Rep.', 'wpsc'), + 'isocode' => 'CZ', + 'currency_name' => __('Czech Koruna', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'CZK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 83 => array( + 'name' => __('Cyprus', 'wpsc'), + 'isocode' => 'CY', + 'currency_name' => __('Cyprus Pound', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'CYP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 84 => array( + 'name' => __('Cuba', 'wpsc'), + 'isocode' => 'CU', + 'currency_name' => __('Cuban Peso', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'CUP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 85 => array( + 'name' => __('Croatia', 'wpsc'), + 'isocode' => 'HR', + 'currency_name' => __('Croatian Kuna', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'HRK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 86 => array( + 'name' => __('Costa Rica', 'wpsc'), + 'isocode' => 'CR', + 'currency_name' => __('Costa Rican Colon', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'CRC', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 87 => array( + 'name' => __('Cook Islands', 'wpsc'), + 'isocode' => 'CK', + 'currency_name' => __('New Zealand Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'NZD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 88 => array( + 'name' => __('Congo', 'wpsc'), + 'isocode' => 'CG', + 'currency_name' => __('CFA Franc BEAC', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XAF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 89 => array( + 'name' => __('Comoros', 'wpsc'), + 'isocode' => 'KM', + 'currency_name' => __('Comoros Franc', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'KMF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 90 => array( + 'name' => __('Colombia', 'wpsc'), + 'isocode' => 'CO', + 'currency_name' => __('Colombian Peso', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'COP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 91 => array( + 'name' => __('Cocos (Keeling) Islands', 'wpsc'), + 'isocode' => 'CC', + 'currency_name' => __('Australian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'AUD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 92 => array( + 'name' => __('Christmas Island', 'wpsc'), + 'isocode' => 'CX', + 'currency_name' => __('Australian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'AUD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 93 => array( + 'name' => __('Chile', 'wpsc'), + 'isocode' => 'CL', + 'currency_name' => __('Chilean Peso', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'CLP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 94 => array( + 'name' => __('China', 'wpsc'), + 'isocode' => 'CN', + 'currency_name' => __('Yuan Renminbi', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'CNY', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 95 => array( + 'name' => __('Chad', 'wpsc'), + 'isocode' => 'TD', + 'currency_name' => __('CFA Franc BEAC', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XAF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 96 => array( + 'name' => __('Central African Republic', 'wpsc'), + 'isocode' => 'CF', + 'currency_name' => __('CFA Franc BEAC', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XAF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 97 => array( + 'name' => __('Cayman Islands', 'wpsc'), + 'isocode' => 'KY', + 'currency_name' => __('Cayman Islands Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'KYD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 98 => array( + 'name' => __('Cape Verde', 'wpsc'), + 'isocode' => 'CV', + 'currency_name' => __('Cape Verde Escudo', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'CVE', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 99 => array( + 'name' => __('Cameroon', 'wpsc'), + 'isocode' => 'CM', + 'currency_name' => __('CFA Franc BEAC', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XAF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 100 => array( + 'name' => __('Canada', 'wpsc'), + 'isocode' => 'CA', + 'currency_name' => __('Canadian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'CAD', + 'has_regions' => true, + 'tax' => '', + 'continent' => 'northamerica', + 'visible' => true + ), + 101 => array( + 'name' => __('Cambodia', 'wpsc'), + 'isocode' => 'KH', + 'currency_name' => __('Kampuchean Riel', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'KHR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 102 => array( + 'name' => __('Burundi', 'wpsc'), + 'isocode' => 'BI', + 'currency_name' => __('Burundi Franc', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'BIF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 103 => array( + 'name' => __('Burkina Faso', 'wpsc'), + 'isocode' => 'BF', + 'currency_name' => __('CFA Franc BCEAO', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XOF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 104 => array( + 'name' => __('Bulgaria', 'wpsc'), + 'isocode' => 'BG', + 'currency_name' => __('Bulgarian Lev', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'BGL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 105 => array( + 'name' => __('Brunei Darussalam', 'wpsc'), + 'isocode' => 'BN', + 'currency_name' => __('Brunei Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'BND', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 106 => array( + 'name' => __('British Indian Ocean Territory', 'wpsc'), + 'isocode' => 'IO', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 107 => array( + 'name' => __('Brazil', 'wpsc'), + 'isocode' => 'BR', + 'currency_name' => __('Brazilian Real', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'BRL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 108 => array( + 'name' => __('Bouvet Island', 'wpsc'), + 'isocode' => 'BV', + 'currency_name' => __('Norwegian Krone', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'NOK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 109 => array( + 'name' => __('Botswana', 'wpsc'), + 'isocode' => 'BW', + 'currency_name' => __('Botswana Pula', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'BWP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 110 => array( + 'name' => __('Bosnia-Herzegovina', 'wpsc'), + 'isocode' => 'BA', + 'currency_name' => __('Marka', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'BAM', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 111 => array( + 'name' => __('Bolivia', 'wpsc'), + 'isocode' => 'BO', + 'currency_name' => __('Boliviano', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'BOB', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 112 => array( + 'name' => __('Bhutan', 'wpsc'), + 'isocode' => 'BT', + 'currency_name' => __('Bhutan Ngultrum', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'BTN', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 113 => array( + 'name' => __('Bermuda', 'wpsc'), + 'isocode' => 'BM', + 'currency_name' => __('Bermudian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'BMD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 114 => array( + 'name' => __('Benin', 'wpsc'), + 'isocode' => 'BJ', + 'currency_name' => __('CFA Franc BCEAO', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XOF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 115 => array( + 'name' => __('Belize', 'wpsc'), + 'isocode' => 'BZ', + 'currency_name' => __('Belize Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'BZD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 116 => array( + 'name' => __('Belgium', 'wpsc'), + 'isocode' => 'BE', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 117 => array( + 'name' => __('Belarus', 'wpsc'), + 'isocode' => 'BY', + 'currency_name' => __('Belarussian Ruble', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'BYB', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 118 => array( + 'name' => __('Barbados', 'wpsc'), + 'isocode' => 'BB', + 'currency_name' => __('Barbados Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'BBD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 119 => array( + 'name' => __('Bangladesh', 'wpsc'), + 'isocode' => 'BD', + 'currency_name' => __('Bangladeshi Taka', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'BDT', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 120 => array( + 'name' => __('Bahrain', 'wpsc'), + 'isocode' => 'BH', + 'currency_name' => __('Bahraini Dinar', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'BHD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 121 => array( + 'name' => __('Bahamas', 'wpsc'), + 'isocode' => 'BS', + 'currency_name' => __('Bahamian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'BSD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 122 => array( + 'name' => __('Azerbaijan', 'wpsc'), + 'isocode' => 'AZ', + 'currency_name' => __('Azerbaijanian Manat', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'AZM', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 123 => array( + 'name' => __('Austria', 'wpsc'), + 'isocode' => 'AT', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 124 => array( + 'name' => __('Aruba', 'wpsc'), + 'isocode' => 'AW', + 'currency_name' => __('Aruban Guilder', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'AWG', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 125 => array( + 'name' => __('Armenia', 'wpsc'), + 'isocode' => 'AM', + 'currency_name' => __('Armenian Dram', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'AMD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 126 => array( + 'name' => __('Argentina', 'wpsc'), + 'isocode' => 'AR', + 'currency_name' => __('Argentine Peso', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'ARS', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 127 => array( + 'name' => __('Antigua and Barbuda', 'wpsc'), + 'isocode' => 'AG', + 'currency_name' => __('East Caribbean Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'XCD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 128 => array( + 'name' => __('Antarctica', 'wpsc'), + 'isocode' => 'AQ', + 'currency_name' => __('Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'ATA', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'antarctica', + 'visible' => true + ), + 129 => array( + 'name' => __('Anguilla', 'wpsc'), + 'isocode' => 'AI', + 'currency_name' => __('East Caribbean Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'XCD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 130 => array( + 'name' => __('Angola', 'wpsc'), + 'isocode' => 'AO', + 'currency_name' => __('Angolan New Kwanza', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'AON', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 131 => array( + 'name' => __('Andorra', 'wpsc'), + 'isocode' => 'AD', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 132 => array( + 'name' => __('American Samoa', 'wpsc'), + 'isocode' => 'AS', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 133 => array( + 'name' => __('Algeria', 'wpsc'), + 'isocode' => 'DZ', + 'currency_name' => __('Algerian Dinar', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'DZD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 134 => array( + 'name' => __('Albania', 'wpsc'), + 'isocode' => 'AL', + 'currency_name' => __('Albanian Lek', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'ALL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 135 => array( + 'name' => __('Afghanistan', 'wpsc'), + 'isocode' => 'AF', + 'currency_name' => __('Afghanistan Afghani', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'AFA', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 136 => array( + 'name' => __('USA', 'wpsc'), + 'isocode' => 'US', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => true, + 'tax' => '', + 'continent' => 'northamerica', + 'visible' => true + ), + 137 => array( + 'name' => __('Australia', 'wpsc'), + 'isocode' => 'AU', + 'currency_name' => __('Australian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'AUD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 138 => array( + 'name' => __('United Kingdom', 'wpsc'), + 'isocode' => 'GB', + 'currency_name' => __('Pound Sterling', 'wpsc'), + 'currency_symbol' => __( '£', 'wpsc' ), + 'currency_symbol_html' => '£', + 'currency_code' => 'GBP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 139 => array( + 'name' => __('Mauritius', 'wpsc'), + 'isocode' => 'MU', + 'currency_name' => __('Mauritius Rupee', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 140 => array( + 'name' => __('Mayotte', 'wpsc'), + 'isocode' => 'YT', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 141 => array( + 'name' => __('Mexico', 'wpsc'), + 'isocode' => 'MX', + 'currency_name' => __('Mexican Nuevo Peso', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MXN', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 142 => array( + 'name' => __('Micronesia', 'wpsc'), + 'isocode' => 'FM', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 143 => array( + 'name' => __('Moldova', 'wpsc'), + 'isocode' => 'MD', + 'currency_name' => __('Moldovan Leu', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MDL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 144 => array( + 'name' => __('Monaco', 'wpsc'), + 'isocode' => 'MC', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 145 => array( + 'name' => __('Mongolia', 'wpsc'), + 'isocode' => 'MN', + 'currency_name' => __('Mongolian Tugrik', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MNT', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 146 => array( + 'name' => __('Montserrat', 'wpsc'), + 'isocode' => 'MS', + 'currency_name' => __('East Caribbean Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'XCD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 147 => array( + 'name' => __('Morocco', 'wpsc'), + 'isocode' => 'MA', + 'currency_name' => __('Moroccan Dirham', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MAD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 148 => array( + 'name' => __('Mozambique', 'wpsc'), + 'isocode' => 'MZ', + 'currency_name' => __('Mozambique Metical', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MZM', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 149 => array( + 'name' => __('Myanmar', 'wpsc'), + 'isocode' => 'MM', + 'currency_name' => __('Myanmar Kyat', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MMK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 150 => array( + 'name' => __('Namibia', 'wpsc'), + 'isocode' => 'NA', + 'currency_name' => __('Namibian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'NAD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 151 => array( + 'name' => __('Nauru', 'wpsc'), + 'isocode' => 'NR', + 'currency_name' => __('Australian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'AUD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 152 => array( + 'name' => __('Nepal', 'wpsc'), + 'isocode' => 'NP', + 'currency_name' => __('Nepalese Rupee', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'NPR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 153 => array( + 'name' => __('Netherlands', 'wpsc'), + 'isocode' => 'NL', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 154 => array( + 'name' => __('Netherlands Antilles', 'wpsc'), + 'isocode' => 'AN', + 'currency_name' => __('Netherlands Antillean Guilder', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'ANG', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 155 => array( + 'name' => __('New Caledonia (French)', 'wpsc'), + 'isocode' => 'NC', + 'currency_name' => __('CFP Franc', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XPF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 156 => array( + 'name' => __('New Zealand', 'wpsc'), + 'isocode' => 'NZ', + 'currency_name' => __('New Zealand Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'NZD', + 'has_regions' => false, + 'tax' => '12.5', + 'continent' => 'asiapacific', + 'visible' => true + ), + 157 => array( + 'name' => __('Nicaragua', 'wpsc'), + 'isocode' => 'NI', + 'currency_name' => __('Nicaraguan Cordoba Oro', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'NIC', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 158 => array( + 'name' => __('Niger', 'wpsc'), + 'isocode' => 'NE', + 'currency_name' => __('CFA Franc BCEAO', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XOF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 159 => array( + 'name' => __('Nigeria', 'wpsc'), + 'isocode' => 'NG', + 'currency_name' => __('Nigerian Naira', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'NGN', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 160 => array( + 'name' => __('Niue', 'wpsc'), + 'isocode' => 'NU', + 'currency_name' => __('New Zealand Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'NZD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 161 => array( + 'name' => __('Norfolk Island', 'wpsc'), + 'isocode' => 'NF', + 'currency_name' => __('Australian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'AUD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 162 => array( + 'name' => __('Northern Mariana Islands', 'wpsc'), + 'isocode' => 'MP', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 163 => array( + 'name' => __('Norway', 'wpsc'), + 'isocode' => 'NO', + 'currency_name' => __('Norwegian Krone', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'NOK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 164 => array( + 'name' => __('Oman', 'wpsc'), + 'isocode' => 'OM', + 'currency_name' => __('Omani Rial', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'OMR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 165 => array( + 'name' => __('Pakistan', 'wpsc'), + 'isocode' => 'PK', + 'currency_name' => __('Pakistan Rupee', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'PKR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 166 => array( + 'name' => __('Palau', 'wpsc'), + 'isocode' => 'PW', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 167 => array( + 'name' => __('Panama', 'wpsc'), + 'isocode' => 'PA', + 'currency_name' => __('Panamanian Balboa', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'PAB', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 168 => array( + 'name' => __('Papua New Guinea', 'wpsc'), + 'isocode' => 'PG', + 'currency_name' => __('Papua New Guinea Kina', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'PGK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 169 => array( + 'name' => __('Paraguay', 'wpsc'), + 'isocode' => 'PY', + 'currency_name' => __('Paraguay Guarani', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'PYG', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 170 => array( + 'name' => __('Peru', 'wpsc'), + 'isocode' => 'PE', + 'currency_name' => __('Peruvian Nuevo Sol', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'PEN', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 171 => array( + 'name' => __('Philippines', 'wpsc'), + 'isocode' => 'PH', + 'currency_name' => __('Philippine Peso', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'PHP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 172 => array( + 'name' => __('Pitcairn Island', 'wpsc'), + 'isocode' => 'PN', + 'currency_name' => __('New Zealand Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'NZD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 173 => array( + 'name' => __('Poland', 'wpsc'), + 'isocode' => 'PL', + 'currency_name' => __('Polish Zloty', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'PLN', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 174 => array( + 'name' => __('Polynesia (French)', 'wpsc'), + 'isocode' => 'PF', + 'currency_name' => __('CFP Franc', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XPF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 175 => array( + 'name' => __('Portugal', 'wpsc'), + 'isocode' => 'PT', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 176 => array( + 'name' => __('Puerto Rico', 'wpsc'), + 'isocode' => 'PR', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 177 => array( + 'name' => __('Qatar', 'wpsc'), + 'isocode' => 'QA', + 'currency_name' => __('Qatari Rial', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'QAR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 178 => array( + 'name' => __('Reunion (French)', 'wpsc'), + 'isocode' => 'RE', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 179 => array( + 'name' => __('Romania', 'wpsc'), + 'isocode' => 'RO', + 'currency_name' => __('Romanian Leu', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'RON', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 180 => array( + 'name' => __('Russia', 'wpsc'), + 'isocode' => 'RU', + 'currency_name' => __('Russian Ruble', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'RUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 181 => array( + 'name' => __('Rwanda', 'wpsc'), + 'isocode' => 'RW', + 'currency_name' => __('Rwanda Franc', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'RWF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 182 => array( + 'name' => __('Saint Helena', 'wpsc'), + 'isocode' => 'SH', + 'currency_name' => __('St. Helena Pound', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SHP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 183 => array( + 'name' => __('Saint Kitts & Nevis Anguilla', 'wpsc'), + 'isocode' => 'KN', + 'currency_name' => __('East Caribbean Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'XCD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 184 => array( + 'name' => __('Saint Lucia', 'wpsc'), + 'isocode' => 'LC', + 'currency_name' => __('East Caribbean Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'XCD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 185 => array( + 'name' => __('Saint Pierre and Miquelon', 'wpsc'), + 'isocode' => 'PM', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 186 => array( + 'name' => __('Saint Vincent & Grenadines', 'wpsc'), + 'isocode' => 'VC', + 'currency_name' => __('East Caribbean Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'XCD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 187 => array( + 'name' => __('Samoa', 'wpsc'), + 'isocode' => 'WS', + 'currency_name' => __('Samoan Tala', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'WST', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 188 => array( + 'name' => __('San Marino', 'wpsc'), + 'isocode' => 'SM', + 'currency_name' => __('Italian Lira', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'ITL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 189 => array( + 'name' => __('Sao Tome and Principe', 'wpsc'), + 'isocode' => 'ST', + 'currency_name' => __('Dobra', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'STD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 190 => array( + 'name' => __('Saudi Arabia', 'wpsc'), + 'isocode' => 'SA', + 'currency_name' => __('Saudi Riyal', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SAR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 191 => array( + 'name' => __('Senegal', 'wpsc'), + 'isocode' => 'SN', + 'currency_name' => __('CFA Franc BCEAO', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XOF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 192 => array( + 'name' => __('Seychelles', 'wpsc'), + 'isocode' => 'SC', + 'currency_name' => __('Seychelles Rupee', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SCR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 193 => array( + 'name' => __('Sierra Leone', 'wpsc'), + 'isocode' => 'SL', + 'currency_name' => __('Sierra Leone Leone', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SLL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 194 => array( + 'name' => __('Singapore', 'wpsc'), + 'isocode' => 'SG', + 'currency_name' => __('Singapore Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'SGD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 195 => array( + 'name' => __('Slovakia', 'wpsc'), + 'isocode' => 'SK', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 196 => array( + 'name' => __('Slovenia', 'wpsc'), + 'isocode' => 'SI', + 'currency_name' => __('Slovenian Tolar', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SIT', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 197 => array( + 'name' => __('Solomon Islands', 'wpsc'), + 'isocode' => 'SB', + 'currency_name' => __('Solomon Islands Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'SBD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 198 => array( + 'name' => __('Somalia', 'wpsc'), + 'isocode' => 'SO', + 'currency_name' => __('Somali Shilling', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SOD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 199 => array( + 'name' => __('South Africa', 'wpsc'), + 'isocode' => 'ZA', + 'currency_name' => __('South African Rand', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'ZAR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 200 => array( + 'name' => __('South Georgia & South Sandwich Islands', 'wpsc'), + 'isocode' => 'GS', + 'currency_name' => __('Pound Sterling', 'wpsc'), + 'currency_symbol' => __( '£', 'wpsc' ), + 'currency_symbol_html' => '£', + 'currency_code' => 'GBP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 201 => array( + 'name' => __('Spain', 'wpsc'), + 'isocode' => 'ES', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 202 => array( + 'name' => __('Sri Lanka', 'wpsc'), + 'isocode' => 'LK', + 'currency_name' => __('Sri Lanka Rupee', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'LKR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 203 => array( + 'name' => __('Sudan', 'wpsc'), + 'isocode' => 'SD', + 'currency_name' => __('Sudanese Dinar', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SDD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 204 => array( + 'name' => __('Suriname', 'wpsc'), + 'isocode' => 'SR', + 'currency_name' => __('Surinam Guilder', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SRG', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 205 => array( + 'name' => __('Svalbard and Jan Mayen Islands', 'wpsc'), + 'isocode' => 'SJ', + 'currency_name' => __('Norwegian Krone', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'NOK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => '', + 'visible' => true + ), + 206 => array( + 'name' => __('Swaziland', 'wpsc'), + 'isocode' => 'SZ', + 'currency_name' => __('Swaziland Lilangeni', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SZL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 207 => array( + 'name' => __('Sweden', 'wpsc'), + 'isocode' => 'SE', + 'currency_name' => __('Swedish Krona', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SEK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 208 => array( + 'name' => __('Switzerland', 'wpsc'), + 'isocode' => 'CH', + 'currency_name' => __('Swiss Franc', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'CHF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 209 => array( + 'name' => __('Syria', 'wpsc'), + 'isocode' => 'SY', + 'currency_name' => __('Syrian Pound', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SYP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 210 => array( + 'name' => __('Taiwan', 'wpsc'), + 'isocode' => 'TW', + 'currency_name' => __('Taiwan Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'TWD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 211 => array( + 'name' => __('Tajikistan', 'wpsc'), + 'isocode' => 'TJ', + 'currency_name' => __('Tajik Ruble', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'TJR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 212 => array( + 'name' => __('Tanzania', 'wpsc'), + 'isocode' => 'TZ', + 'currency_name' => __('Tanzanian Shilling', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'TZS', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 213 => array( + 'name' => __('Thailand', 'wpsc'), + 'isocode' => 'TH', + 'currency_name' => __('Thai Baht', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'THB', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 214 => array( + 'name' => __('Togo', 'wpsc'), + 'isocode' => 'TG', + 'currency_name' => __('CFA Franc BCEAO', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XOF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 215 => array( + 'name' => __('Tokelau', 'wpsc'), + 'isocode' => 'TK', + 'currency_name' => __('New Zealand Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'NZD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 216 => array( + 'name' => __('Tonga', 'wpsc'), + 'isocode' => 'TO', + 'currency_name' => __('Tongan Paʻanga', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'TOP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 217 => array( + 'name' => __('Trinidad and Tobago', 'wpsc'), + 'isocode' => 'TT', + 'currency_name' => __('Trinidad and Tobago Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'TTD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 218 => array( + 'name' => __('Tunisia', 'wpsc'), + 'isocode' => 'TN', + 'currency_name' => __('Tunisian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'TND', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 219 => array( + 'name' => __('Turkey', 'wpsc'), + 'isocode' => 'TR', + 'currency_name' => __('Turkish Lira', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'TRL', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 220 => array( + 'name' => __('Turkmenistan', 'wpsc'), + 'isocode' => 'TM', + 'currency_name' => __('Manat', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'TMM', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 221 => array( + 'name' => __('Turks and Caicos Islands', 'wpsc'), + 'isocode' => 'TC', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 222 => array( + 'name' => __('Tuvalu', 'wpsc'), + 'isocode' => 'TV', + 'currency_name' => __('Australian Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'AUD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 223 => array( + 'name' => __('U.K.', 'wpsc'), + 'isocode' => 'UK', + 'currency_name' => __('Pound Sterling', 'wpsc'), + 'currency_symbol' => __( '£', 'wpsc' ), + 'currency_symbol_html' => '£', + 'currency_code' => 'GBP', + 'has_regions' => false, + 'tax' => '17.5', + 'continent' => 'europe', + 'visible' => true + ), + 224 => array( + 'name' => __('Uganda', 'wpsc'), + 'isocode' => 'UG', + 'currency_name' => __('Uganda Shilling', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'UGS', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 225 => array( + 'name' => __('Ukraine', 'wpsc'), + 'isocode' => 'UA', + 'currency_name' => __('Ukraine Hryvnia', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'UAG', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 226 => array( + 'name' => __('United Arab Emirates', 'wpsc'), + 'isocode' => 'AE', + 'currency_name' => __('Arab Emirates Dirham', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'AED', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 227 => array( + 'name' => __('Uruguay', 'wpsc'), + 'isocode' => 'UY', + 'currency_name' => __('Uruguayan Peso', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'UYP', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'southamerica', + 'visible' => true + ), + 228 => array( + 'name' => __('USA Minor Outlying Islands', 'wpsc'), + 'isocode' => 'UM', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => '', + 'visible' => true + ), + 229 => array( + 'name' => __('Uzbekistan', 'wpsc'), + 'isocode' => 'UZ', + 'currency_name' => __('Uzbekistan Sum', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'UZS', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 230 => array( + 'name' => __('Vanuatu', 'wpsc'), + 'isocode' => 'VU', + 'currency_name' => __('Vanuatu Vatu', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'VUV', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 231 => array( + 'name' => __('Vatican', 'wpsc'), + 'isocode' => 'VA', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 232 => array( + 'name' => __('Venezuela', 'wpsc'), + 'isocode' => 'VE', + 'currency_name' => __('Venezuelan Bolivar', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'VUB', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 233 => array( + 'name' => __('Vietnam', 'wpsc'), + 'isocode' => 'VN', + 'currency_name' => __('Vietnamese Dong', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'VND', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 234 => array( + 'name' => __('Virgin Islands (British)', 'wpsc'), + 'isocode' => 'VG', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 235 => array( + 'name' => __('Virgin Islands (USA)', 'wpsc'), + 'isocode' => 'VI', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'northamerica', + 'visible' => true + ), + 236 => array( + 'name' => __('Wallis and Futuna Islands', 'wpsc'), + 'isocode' => 'WF', + 'currency_name' => __('CFP Franc', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'XPF', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 237 => array( + 'name' => __('Western Sahara', 'wpsc'), + 'isocode' => 'EH', + 'currency_name' => __('Moroccan Dirham', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'MAD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 238 => array( + 'name' => __('Yemen', 'wpsc'), + 'isocode' => 'YE', + 'currency_name' => __('Yemeni Rial', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'YER', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'asiapacific', + 'visible' => true + ), + 239 => array( + 'name' => __('Yugoslavia', 'wpsc'), + 'isocode' => 'YU', + 'currency_name' => __('Yugoslav New Dinar', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'YUN', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'europe', + 'visible' => true + ), + 240 => array( + 'name' => __('Zambia', 'wpsc'), + 'isocode' => 'ZM', + 'currency_name' => __('Zambian Kwacha', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'ZMK', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 241 => array( + 'name' => __('Zimbabwe', 'wpsc'), + 'isocode' => 'ZW', + 'currency_name' => __('Zimbabwe Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'ZWD', + 'has_regions' => false, + 'tax' => '0', + 'continent' => 'africa', + 'visible' => true + ), + 242 => array( + 'name' => __('South Sudan', 'wpsc'), + 'isocode' => 'SS', + 'currency_name' => __('South Sudanese Pound', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'SSP', + 'has_regions' => '', + 'tax' => '', + 'continent' => 'africa', + 'visible' => true + ), + 243 => array( + 'name' => __('Serbia', 'wpsc'), + 'isocode' => 'RS', + 'currency_name' => __('Serbian Dinar', 'wpsc'), + 'currency_symbol' => '', + 'currency_symbol_html' => '', + 'currency_code' => 'RSD', + 'has_regions' => '', + 'tax' => '', + 'continent' => 'europe', + 'visible' => true + ), + 244 => array( + 'name' => __('Montenegro', 'wpsc'), + 'isocode' => 'ME', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => '', + 'tax' => '', + 'continent' => 'europe', + 'visible' => true + ), + 245 => array( + 'name' => __('Timor-Leste', 'wpsc'), + 'isocode' => 'TL', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => '', + 'tax' => '', + 'continent' => 'asiapacific', + 'visible' => true + ), + 246 => array( + 'name' => __('Aland Islands', 'wpsc'), + 'isocode' => 'AX', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => '', + 'tax' => '', + 'continent' => 'europe', + 'visible' => true + ), + 247 => array( + 'name' => __('Saint Barthelemy', 'wpsc'), + 'isocode' => 'BL', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => '', + 'tax' => '', + 'continent' => 'europe', + 'visible' => true + ), + 248 => array( + 'name' => __('Bonaire, Sint Eustatius and Saba', 'wpsc'), + 'isocode' => 'BQ', + 'currency_name' => __('US Dollar', 'wpsc'), + 'currency_symbol' => __( '$', 'wpsc' ), + 'currency_symbol_html' => '$', + 'currency_code' => 'USD', + 'has_regions' => '', + 'tax' => '', + 'continent' => 'southamerica', + 'visible' => true + ), + 249 => array( + 'name' => __('Curacao', 'wpsc'), + 'isocode' => 'CW', + 'currency_name' => __('Netherlands Antillean Guilder', 'wpsc'), + 'currency_symbol' => __( 'ƒ', 'wpsc' ), + 'currency_symbol_html' => 'ƒ', + 'currency_code' => 'ANG', + 'has_regions' => '', + 'tax' => '', + 'continent' => 'southamerica', + 'visible' => true + ), + 250 => array( + 'name' => __('Saint Martin (French Part)', 'wpsc'), + 'isocode' => 'MF', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => '', + 'tax' => '', + 'continent' => 'southamerica', + 'visible' => true + ), + 251 => array( + 'name' => __('Palestinian Territories', 'wpsc'), + 'isocode' => 'PS', + 'currency_name' => __('Israeli New Sheqel', 'wpsc'), + 'currency_symbol' => __( '?', 'wpsc' ), + 'currency_symbol_html' => '₪', + 'currency_code' => 'ILS', + 'has_regions' => '', + 'tax' => '', + 'continent' => 'asiapacific', + 'visible' => true + ), + 252 => array( + 'name' => __('Sint Maarten (Dutch Part)', 'wpsc'), + 'isocode' => 'SX', + 'currency_name' => __('Netherlands Antillean Guilder', 'wpsc'), + 'currency_symbol' => __( 'ƒ', 'wpsc' ), + 'currency_symbol_html' => 'ƒ', + 'currency_code' => 'ANG', + 'has_regions' => '', + 'tax' => '', + 'continent' => 'southamerica', + 'visible' => true + ), + 253 => array( + 'name' => __('French Guiana', 'wpsc'), + 'isocode' => 'GF', + 'currency_name' => __('Euro', 'wpsc'), + 'currency_symbol' => __( '€', 'wpsc' ), + 'currency_symbol_html' => '€', + 'currency_code' => 'EUR', + 'has_regions' => '', + 'tax' => '', + 'continent' => 'southamerica', + 'visible' => true + ), + ); + /** + * Get or modify the countries data used to initalize WP eCommerce ccuntries data structures + * + * @since 4.1 + * + * @param array array of associative arrays of country data, each array element should have the following required properties + * country_id + * country_name + * country_iso_code + * currency_name + * currency_symbol + * currency_symbol_html + * currency_text_code + * has_regions + * tax + * continent + * visible + */ + $countries = apply_filters('wpsc_get_countries_data_array', $countries); + + return $countries; +} + +function _wpsc_get_regions_data_array() +{ + $regions = array( + 1 => array( + 'country_id' => 100, + 'name' => __('Alberta', 'wpsc'), + 'code' => 'AB', + 'tax' => '0' + ), + 2 => array( + 'country_id' => 100, + 'name' => __('British Columbia', 'wpsc'), + 'code' => 'BC', + 'tax' => '0' + ), + 3 => array( + 'country_id' => 100, + 'name' => __('Manitoba', 'wpsc'), + 'code' => 'MB', + 'tax' => '0' + ), + 4 => array( + 'country_id' => 100, + 'name' => __('New Brunswick', 'wpsc'), + 'code' => 'NB', + 'tax' => '0' + ), + 5 => array( + 'country_id' => 100, + 'name' => 'Newfoundland and Labrador', + 'code' => 'NL', + 'tax' => '0' + ), + 6 => array( + 'country_id' => 100, + 'name' => __('Northwest Territories', 'wpsc'), + 'code' => 'NT', + 'tax' => '0' + ), + 7 => array( + 'country_id' => 100, + 'name' => __('Nova Scotia', 'wpsc'), + 'code' => 'NS', + 'tax' => '0' + ), + 8 => array( + 'country_id' => 100, + 'name' => __('Nunavut', 'wpsc'), + 'code' => 'NU', + 'tax' => '0' + ), + 8 => array( + 'country_id' => 100, + 'name' => __('Ontario', 'wpsc'), + 'code' => 'ON', + 'tax' => '0' + ), + 10 => array( + 'country_id' => 100, + 'name' => __('Prince Edward Island', 'wpsc'), + 'code' => 'PE', + 'tax' => '0' + ), + 11 => array( + 'country_id' => 100, + 'name' => __('Quebec', 'wpsc'), + 'code' => 'QC', + 'tax' => '0' + ), + 12 => array( + 'country_id' => 100, + 'name' => __('Saskatchewan', 'wpsc'), + 'code' => 'SK', + 'tax' => '0' + ), + 13 => array( + 'country_id' => 100, + 'name' => __('Yukon', 'wpsc'), + 'code' => 'YT', + 'tax' => '0' + ), + 14 => array( + 'country_id' => 136, + 'name' => __('Alabama', 'wpsc'), + 'code' => 'AL', + 'tax' => '0' + ), + 15 => array( + 'country_id' => 136, + 'name' => __('Alaska', 'wpsc'), + 'code' => 'AK', + 'tax' => '0' + ), + 16 => array( + 'country_id' => 136, + 'name' => __('Arizona', 'wpsc'), + 'code' => 'AZ', + 'tax' => '0' + ), + 17 => array( + 'country_id' => 136, + 'name' => __('Arkansas', 'wpsc'), + 'code' => 'AR', + 'tax' => '0' + ), + 18 => array( + 'country_id' => 136, + 'name' => __('California', 'wpsc'), + 'code' => 'CA', + 'tax' => '0' + ), + 19 => array( + 'country_id' => 136, + 'name' => __('Colorado', 'wpsc'), + 'code' => 'CO', + 'tax' => '0' + ), + 20 => array( + 'country_id' => 136, + 'name' => __('Connecticut', 'wpsc'), + 'code' => 'CT', + 'tax' => '0' + ), + 21 => array( + 'country_id' => 136, + 'name' => __('Delaware', 'wpsc'), + 'code' => 'DE', + 'tax' => '0' + ), + 22 => array( + 'country_id' => 136, + 'name' => __('Florida', 'wpsc'), + 'code' => 'FL', + 'tax' => '0' + ), + 23 => array( + 'country_id' => 136, + 'name' => __('Georgia', 'wpsc'), + 'code' => 'GA', + 'tax' => '0' + ), + 24 => array( + 'country_id' => 136, + 'name' => __('Hawaii', 'wpsc'), + 'code' => 'HI', + 'tax' => '0' + ), + 25 => array( + 'country_id' => 136, + 'name' => __('Idaho', 'wpsc'), + 'code' => 'ID', + 'tax' => '0' + ), + 26 => array( + 'country_id' => 136, + 'name' => __('Illinois', 'wpsc'), + 'code' => 'IL', + 'tax' => '0' + ), + 27 => array( + 'country_id' => 136, + 'name' => __('Indiana', 'wpsc'), + 'code' => 'IN', + 'tax' => '0' + ), + 28 => array( + 'country_id' => 136, + 'name' => __('Iowa', 'wpsc'), + 'code' => 'IA', + 'tax' => '0' + ), + 29 => array( + 'country_id' => 136, + 'name' => __('Kansas', 'wpsc'), + 'code' => 'KS', + 'tax' => '0' + ), + 30 => array( + 'country_id' => 136, + 'name' => __('Kentucky', 'wpsc'), + 'code' => 'KY', + 'tax' => '0' + ), + 31 => array( + 'country_id' => 136, + 'name' => __('Louisiana', 'wpsc'), + 'code' => 'LA', + 'tax' => '0' + ), + 32 => array( + 'country_id' => 136, + 'name' => __('Maine', 'wpsc'), + 'code' => 'ME', + 'tax' => '0' + ), + 33 => array( + 'country_id' => 136, + 'name' => __('Maryland', 'wpsc'), + 'code' => 'MD', + 'tax' => '0' + ), + 34 => array( + 'country_id' => 136, + 'name' => __('Massachusetts', 'wpsc'), + 'code' => 'MA', + 'tax' => '0' + ), + 35 => array( + 'country_id' => 136, + 'name' => __('Michigan', 'wpsc'), + 'code' => 'MI', + 'tax' => '0' + ), + 36 => array( + 'country_id' => 136, + 'name' => __('Minnesota', 'wpsc'), + 'code' => 'MN', + 'tax' => '0' + ), + 37 => array( + 'country_id' => 136, + 'name' => __('Mississippi', 'wpsc'), + 'code' => 'MS', + 'tax' => '0' + ), + 38 => array( + 'country_id' => 136, + 'name' => __('Missouri', 'wpsc'), + 'code' => 'MO', + 'tax' => '0' + ), + 39 => array( + 'country_id' => 136, + 'name' => __('Montana', 'wpsc'), + 'code' => 'MT', + 'tax' => '0' + ), + 40 => array( + 'country_id' => 136, + 'name' => __('Nebraska', 'wpsc'), + 'code' => 'NE', + 'tax' => '0' + ), + 41 => array( + 'country_id' => 136, + 'name' => __('Nevada', 'wpsc'), + 'code' => 'NV', + 'tax' => '0' + ), + 42 => array( + 'country_id' => 136, + 'name' => __('New Hampshire', 'wpsc'), + 'code' => 'NH', + 'tax' => '0' + ), + 43 => array( + 'country_id' => 136, + 'name' => __('New Jersey', 'wpsc'), + 'code' => 'NJ', + 'tax' => '0' + ), + 44 => array( + 'country_id' => 136, + 'name' => __('New Mexico', 'wpsc'), + 'code' => 'NM', + 'tax' => '0' + ), + 45 => array( + 'country_id' => 136, + 'name' => __('New York', 'wpsc'), + 'code' => 'NY', + 'tax' => '0' + ), + 46 => array( + 'country_id' => 136, + 'name' => __('North Carolina', 'wpsc'), + 'code' => 'NC', + 'tax' => '0' + ), + 47 => array( + 'country_id' => 136, + 'name' => __('North Dakota', 'wpsc'), + 'code' => 'ND', + 'tax' => '0' + ), + 48 => array( + 'country_id' => 136, + 'name' => __('Ohio', 'wpsc'), + 'code' => 'OH', + 'tax' => '0' + ), + 49 => array( + 'country_id' => 136, + 'name' => __('Oklahoma', 'wpsc'), + 'code' => 'OK', + 'tax' => '0' + ), + 50 => array( + 'country_id' => 136, + 'name' => __('Oregon', 'wpsc'), + 'code' => 'OR', + 'tax' => '0' + ), + 51 => array( + 'country_id' => 136, + 'name' => __('Pennsylvania', 'wpsc'), + 'code' => 'PA', + 'tax' => '0' + ), + 52 => array( + 'country_id' => 136, + 'name' => __('Rhode Island', 'wpsc'), + 'code' => 'RI', + 'tax' => '0' + ), + 53 => array( + 'country_id' => 136, + 'name' => __('South Carolina', 'wpsc'), + 'code' => 'SC', + 'tax' => '0' + ), + 54 => array( + 'country_id' => 136, + 'name' => __('South Dakota', 'wpsc'), + 'code' => 'SD', + 'tax' => '0' + ), + 55 => array( + 'country_id' => 136, + 'name' => __('Tennessee', 'wpsc'), + 'code' => 'TN', + 'tax' => '0' + ), + 56 => array( + 'country_id' => 136, + 'name' => __('Texas', 'wpsc'), + 'code' => 'TX', + 'tax' => '0' + ), + 57 => array( + 'country_id' => 136, + 'name' => __('Utah', 'wpsc'), + 'code' => 'UT', + 'tax' => '0' + ), + 58 => array( + 'country_id' => 136, + 'name' => __('Vermont', 'wpsc'), + 'code' => 'VT', + 'tax' => '0' + ), + 59 => array( + 'country_id' => 136, + 'name' => __('Virginia', 'wpsc'), + 'code' => 'VA', + 'tax' => '0' + ), + 60 => array( + 'country_id' => 136, + 'name' => __('Washington', 'wpsc'), + 'code' => 'WA', + 'tax' => '0' + ), + 61 => array( + 'country_id' => 136, + 'name' => __('Washington DC', 'wpsc'), + 'code' => 'DC', + 'tax' => '0' + ), + 62 => array( + 'country_id' => 136, + 'name' => __('West Virginia', 'wpsc'), + 'code' => 'WV', + 'tax' => '0' + ), + 63 => array( + 'country_id' => 136, + 'name' => __('Wisconsin', 'wpsc'), + 'code' => 'WI', + 'tax' => '0' + ), + 64 => array( + 'country_id' => 136, + 'name' => __('Wyoming', 'wpsc'), + 'code' => 'WY', + 'tax' => '0' + ), + ); + + /** + * Get or modify the countries data used to initalize WP eCommerce regions data structures + * + * @since 4.1 + * + * @param array array of associative arrays of country data, each array element should have the following required properties + * id + * country_id + * name + * code + * tax + */ + $regions = apply_filters('wpsc_get_regions_data_array', $regions); + + return $regions; +} + diff --git a/wpsc-includes/country-api.php b/wpsc-includes/country-api.php new file mode 100644 index 0000000000..5f6e547504 --- /dev/null +++ b/wpsc-includes/country-api.php @@ -0,0 +1,193 @@ +get_name(); + } else { + $country_name = ''; + } + + return $country_name; +} + +/** + * Get a region name using it's WP eCommerce integer region id + * + * @param int the WP eCommerce specific integer region id + * + * @since 3.8 + * + * @return WPSC_Country|boolean the country, or false on failure + */ +function wpsc_get_region( $region_identifier ) { + $wpsc_region = wpsc_get_region_object( $region_identifier ); + if ( $wpsc_region ) { + $region_name = $wpsc_region->get_name(); + } else { + $region_name = ''; + } + + return $region_name; +} + +/** + * Get a country object using it's unique indentfier + * + * @param int|string unique country identifier, the ISO code is preferred, but + * the WP eCommerce specific integer country id can also be used + * + * @since 4.1 + * + * @return WPSC_Country|boolean the country, or false on failure + */ +function wpsc_get_country_object( $country_identifier ) { + return WPSC_Countries::get_country( $country_identifier ); +} + +/** + * Get a region object using it's WP eCommerce integer region id + * + * @param int the WP eCommerce specific integer region id + * + * @since 4.1 + * + * @return WPSC_Country|boolean the country, or false on failure + */ +function wpsc_get_region_object( $region_id ) { + return WPSC_Countries::get_region( false, $region_id ); +} + +/** + * Chaneg the cisibility of all countries site wide + * + * @param int the WP eCommerce specific integer region id + * + * @since 4.1 + * + * @return WPSC_Country|boolean the country, or false on failure + */ +function wpsc_set_all_countries_visibility( $visibility = true ) { + WPSC_Countries::set_visibility( $visibility ); +} + +/** + * Get countries + * + * @param bool $include_invisible include the invisible countries in the result + * @param bool $sort_by_name sort the results by the country name + * + * @since 4.1 + * + * @return WPSC_Country[] + * + */ +function wpsc_get_country_objects( $include_invisible = false, $sort_by_name = true ) { + return WPSC_Countries::get_countries( $include_invisible, $sort_by_name ); +} + +/** + * Get all countries + * + * @param bool $include_invisible include the invisible countries in the result + * @param bool $sort_by_name sort the results by the country name + * + * @since 4.1 + * + * @return WPSC_Country[] + * + */ +function wpsc_get_all_countries( $sort_by_name = true ) { + return WPSC_Countries::get_countries( true, $sort_by_name ); +} + +/** + * Get visible countries + * + * @param bool $include_invisible include the invisible countries in the result + * @param bool $sort_by_name sort the results by the country name + * + * @since 4.1 + * + * @return WPSC_Country[] + * + */ +function wpsc_get_visible_countries( $sort_by_name = true ) { + return WPSC_Countries::get_countries( false, $sort_by_name ); +} + +/** + * Get all known regions + * + * @since 4.1 + * + * @return WPSC_Region[] + * + */ +function wpsc_get_all_regions() { + return WPSC_Countries::get_all_regions(); +} + +/** + * Get the country object correcposnding to the currently configured store currency type, might be the default + * currency type if store admin has not configured currency type + * + * @since 4.1 + * + * @return WPSC_Country|boolean the country, or false on failure + */ +function wpsc_get_currency_type_country_object() { + + $wpsc_country_of_currency_type = false; + + $currency_type_country_id = intval( get_option( 'currency_type', - 1 ) ); + + // get the country for the current currency type, make sure it is valid, if not + // we will move on as if a currency type was not set + if ( - 1 != $currency_type_country_id ) { + $wpsc_country_of_currency_type = wpsc_get_country_object( $currency_type_country_id ); + if ( ! $wpsc_country_of_currency_type ) { + $currency_type_country_id = - 1; + } + } + + if ( - 1 == $currency_type_country_id ) { + $wpsc_country_of_currency_type = wpsc_get_country_object( 'US' ); + if ( $wpsc_country_of_currency_type ) { + $currency_type_country_id = $wpsc_country_of_currency_type->get_id(); + } + } + + return $wpsc_country_of_currency_type; +} + + +/** + * Get the country id correcposnding to the currently configured store currency type, might be the default + * currency type countri id if store admin has not configured currency type + * + * @since 4.1 + * + * @return int country id matching the current currency type, 0 if there isn't a current value + */ +function wpsc_get_currency_type_country_id() { + + $wpsc_country_of_currency_type = wpsc_get_currency_type_country_object(); + if ( $wpsc_country_of_currency_type ) { + $currency_type_country_id = $wpsc_country_of_currency_type->get_id(); + } else { + $currency_type_country_id = 0; // should never happen + } + + return $currency_type_country_id; +} diff --git a/wpsc-includes/misc.functions.php b/wpsc-includes/misc.functions.php index 390562553b..b6a8050c13 100755 --- a/wpsc-includes/misc.functions.php +++ b/wpsc-includes/misc.functions.php @@ -168,16 +168,6 @@ function wpsc_get_country_form_id_by_type($type){ return $id; } -function wpsc_get_country( $country_code ) { - $wpsc_country = new WPSC_Country( $country_code ); - return $wpsc_country->get_name(); -} - -function wpsc_get_region( $region_id ) { - $country_id = WPSC_Countries::get_country_id_by_region_id( $region_id ); - $wpsc_region = new WPSC_Region( $country_id, $region_id ); - return $wpsc_region->get_name(); -} function nzshpcrt_display_preview_image() { global $wpdb; diff --git a/wpsc-includes/wpsc-countries.class.php b/wpsc-includes/wpsc-countries.class.php index fdcbccce77..8c3cb049dd 100644 --- a/wpsc-includes/wpsc-countries.class.php +++ b/wpsc-includes/wpsc-countries.class.php @@ -60,12 +60,84 @@ */ class WPSC_Countries { - const INCLUDE_INVISIBLE = true; + const INCLUDE_INVISIBLE = true; const DO_NOT_INCLUDE_INVISIBLE = false; /** Refers to a single instance of this class. */ private static $instance = null; + /** + * Array of visible countries, indexed by country id + * + * @access private + * @static + * + * @since 4.1 + * + * @var WPSC_Country[] + */ + private static $countries_by_id = array(); + + /** + * Array of unique known countries, indexed by is code + * + * @access private + * @static + * + * @since 4.1 + * + * @var WPSC_Country[] + */ + private static $countries_by_iso_code = array(); + + /** + * Array of visible countries, indexed by country id + * + * @access private + * @static + * + * @since 4.1 + * + * @var WPSC_Country[] + */ + private static $visible_countries_by_id = array(); + + /** + * Array of unique known regions, indexed by region id + * + * @access private + * @static + * + * @since 4.1 + * + * @var WPSC_Region[] + */ + private static $regions_by_region_id = array(); + + /** + * Array of unique known currencies, indexed by currency code + * + * @access private + * @static + * + * @since 4.1 + * + * @var WPSC_Currency[] + */ + private static $currencies = array(); + + /** + * Array of countryiso codes that have had thier visibility modified from the default + * + * @access private + * @static + * + * @since 4.1 + * + * @var bool[] + */ + private static $country_visibility_overrides; + /** * Creates or returns an instance of this class. * @@ -89,7 +161,7 @@ public static function get_instance() { * * @since 3.8.14 * - * @param int | string country being checked, if noon-numeric country is treated as an isocode, number is the country id + * @param int | string country being checked, if noon-numeric country is treated as an isocode, number is the country id * * @return int | boolean integer country id on success, false on failure */ @@ -98,15 +170,15 @@ public static function get_country_id( $country ) { // set default return value $country_id = false; - if ( ! self::confirmed_initialization() ) { - return 0; - } - if ( $country ) { if ( is_numeric( $country ) ) { $country_id = intval( $country ); } elseif ( is_string( $country ) ) { - $country_id = self::$country_id_by_iso_code->value( $country, $country_id ); + if ( isset( self::$countries_by_iso_code[ $country ] ) ) { + $country_id = self::$countries_by_iso_code[ $country ]->get_id(); + } else { + _wpsc_doing_it_wrong( 'WPSC_Countries::country_id', __( 'Method "get_country_id" of WPSC_Countries requires a valid integer country code or a string ISO code ', 'wpsc' ), '4.1' ); + } } else { _wpsc_doing_it_wrong( 'WPSC_Countries::country_id', __( 'Method "get_country_id" of WPSC_Countries requires an integer country code or a string ISO code ', 'wpsc' ), '3.8.14' ); } @@ -123,24 +195,20 @@ public static function get_country_id( $country ) { * * @since 3.8.14 * - * @param int|string $country country being checked, if noon-numeric country is treated as an isocode, number is the country id + * @param int|string $country country being checked, if noon-numeric country is treated as an isocode, number is the country id * * @return int|boolean integer country id on success, false on failure */ public static function get_country_isocode( $country ) { - $country_id = false; + $iso_code = false; - if ( ! self::confirmed_initialization() ) { - return 0; - } + $wpsc_country = self::get_country_using_code_or_id( $country ); - if ( is_numeric( $country ) ) { - $country_id = intval( $country ); - } else { - $country_id = self::$country_id_by_iso_code->value( $country ); + if ( $wpsc_country ) { + $iso_code = $wpsc_country->get_code(); } - return $country_id; + return $iso_code; } /** @@ -151,26 +219,21 @@ public static function get_country_isocode( $country ) { * * @since 3.8.14 * - * @param int|string $country country being checked, if non-numeric country is treated as an isocode, number is the country id - * @param int|string $region region being checked, if non-numeric region is treated as an code, number is the region id + * @param int|string $country country being checked, if non-numeric country is treated as an isocode, number is the country id + * @param int|string $region region being checked, if non-numeric region is treated as an code, number is the region id * - * @return int|boolean integer country id on success, false on failure + * @return int|boolean integer country id on success, false on failure */ public static function get_region_id( $country, $region ) { // set default return value $region_id = false; - if ( ! self::confirmed_initialization() ) { - return 0; - } - - $country_id = self::get_country_id( $country ); - if ( is_numeric( $region ) ) { $region_id = intval( $region ); } else { - $wpsc_country = self::$all_wpsc_country_by_country_id->value( $country_id, false ); + $wpsc_country = self::get_country_using_code_or_id( $country ); + if ( $wpsc_country && $wpsc_country->has_regions() ) { $region_id = $wpsc_country->get_region_id_by_region_code( $region ); } @@ -185,7 +248,7 @@ public static function get_region_id( $country, $region ) { * @access public * @since 3.8.14 * - * @param int|string|null optional if non-numeric country is treated as an ISO code, number is the country id + * @param int|string|null optional if non-numeric country is treated as an ISO code, number is the country id * * @param int|string required if non-numeric country is treated as an region code, number is the region id, * if the region id is passed then country_id is ignored @@ -195,27 +258,32 @@ public static function get_region_id( $country, $region ) { */ public static function get_region( $country, $region ) { - if ( ! self::confirmed_initialization() ) { - return false; - } - // set default return value $wpsc_region = false; + if ( is_numeric( $region ) ) { + $region_id = intval( $region ); + } else { + $wpsc_country = self::get_country_using_code_or_id( $country ); + + if ( $wpsc_country && $wpsc_country->has_regions() ) { + $region_id = $wpsc_country->get_region_id_by_region_code( $region ); + } + } + // we want to get to the unique region id to retrieve the region object, it might have been passed, or we // will have to figure it out from the country and the region if ( is_int( $region ) ) { - $region_id = $region; - $country_id = self::$country_id_by_region_id->value( $region_id, false ); + + $region_id = $region; + if ( isset( self::$regions_by_region_id[ $region ] ) ) { + $wpsc_region = self::$regions_by_region_id[ $region ]; + } } else { - $country_id = self::get_country_id( $country ); - $region_id = self::get_region_id( $country_id, $region ); - } + $wpsc_country = self::get_country_using_code_or_id( $country ); - if ( $country_id && $region_id ) { - $wpsc_country = self::$all_wpsc_country_by_country_id->value( $country_id, false ); - if ( $wpsc_country ) { - $wpsc_region = $wpsc_country->get_region( $region_id ); + if ( $wpsc_country && $wpsc_country->has_regions() ) { + $wpsc_region = $wpsc_country->get_region( $region ); } } @@ -228,26 +296,16 @@ public static function get_region( $country, $region ) { * @access public * @since 3.8.14 * - * @param int|string $country country being checked, if non-numeric country is treated as an isocode, + * @param int|string $country country being checked, if non-numeric country is treated as an isocode, * if number used as the country id * - * @param boolean $as_array return the result as an array, default is to return the result as an object + * @param boolean $as_array return the result as an array, default is to return the result as an object * * @return object|array|boolean country information, false on failure */ public static function get_country( $country, $as_array = false ) { - if ( ! self::confirmed_initialization() ) { - return 0; - } - - $country_id = self::get_country_id( $country ); - - // set default return value - $wpsc_country = false; - if ( $country_id ) { - $wpsc_country = self::$all_wpsc_country_by_country_id->value( $country_id, $wpsc_country ); - } + $wpsc_country = self::get_country_using_code_or_id( $country ); if ( $as_array && $wpsc_country ) { $wpsc_country = $wpsc_country->as_array(); @@ -262,26 +320,20 @@ public static function get_country( $country, $as_array = false ) { * @access public * @since 3.8.14 * - * @param int | string $country country being checked, if non-numeric country is treated as an isocode, + * @param int | string $country country being checked, if non-numeric country is treated as an isocode, * number is the country id * * @return string currency code for the specified country, or empty string if it is not defined */ public static function get_currency_code( $country ) { - if ( ! self::confirmed_initialization() ) { - return ''; - } - $country_id = self::get_country_id( $country ); + $wpsc_country = self::get_country_using_code_or_id( $country ); // set default return value $currency_code = ''; - if ( $country_id ) { - $wpsc_country = self::$all_wpsc_country_by_country_id->value( $country_id, false ); - if ( $wpsc_country ) { - $currency_code = $wpsc_country->get_currency_code(); - } + if ( $wpsc_country ) { + $currency_code = $wpsc_country->get_currency_code(); } return $currency_code; @@ -293,26 +345,18 @@ public static function get_currency_code( $country ) { * @access public * @since 3.8.14 * - * @param int | string $country country being checked, if non-numeric country is treated as an isocode, + * @param int | string $country country being checked, if non-numeric country is treated as an isocode, * number is the country id * * @return string currency symbol for the specified country, or empty string if it is not defined */ public static function get_currency_symbol( $country ) { - if ( ! self::confirmed_initialization() ) { - return ''; - } - - $country_id = self::get_country_id( $country ); - // set default return value $currency_symbol = ''; - if ( $country_id ) { - $wpsc_country = self::$all_wpsc_country_by_country_id->value( $country_id, false ); - if ( $wpsc_country ) { - $currency_symbol = $wpsc_country->get_currency_symbol(); - } + $wpsc_country = self::get_country_using_code_or_id( $country ); + if ( $wpsc_country ) { + $currency_symbol = $wpsc_country->get_currency_symbol(); } return $currency_symbol; @@ -324,26 +368,19 @@ public static function get_currency_symbol( $country ) { * @access public * @since 3.8.14 * - * @param int | string $country country being checked, if non-numeric country is treated as an isocode, + * @param int | string $country country being checked, if non-numeric country is treated as an isocode, * number is the country id * * @return string content for the country, or empty string if it is not defined */ public static function get_continent( $country ) { - if ( ! self::confirmed_initialization() ) { - return 0; - } - $country_id = self::get_country_id( $country ); - - // set default return value - $continent = ''; + $wpsc_country = self::get_country_using_code_or_id( $country ); - if ( $country_id ) { - $wpsc_country = self::$all_wpsc_country_by_country_id->value( $country_id, false ); - if ( $wpsc_country ) { - $continent = $wpsc_country->get_continent(); - } + if ( $wpsc_country ) { + $continent = $wpsc_country->get_continent(); + } else { + $continent = ''; } return $continent; @@ -355,25 +392,19 @@ public static function get_continent( $country ) { * @access public * @since 3.8.14 * - * @param int | string $country country being checked, if non-numeric country is treated as an isocode, + * @param int | string $country country being checked, if non-numeric country is treated as an isocode, * number is the country id * * @return string currency symbol HTML for the specified country, or empty string if it is not defined */ public static function get_currency_symbol_html( $country ) { - if ( ! self::confirmed_initialization() ) { - return 0; - } - $country_id = self::get_country_id( $country ); + $wpsc_country = self::get_country_using_code_or_id( $country ); - $currency_symbol = ''; - - if ( $country_id ) { - $wpsc_country = self::$all_wpsc_country_by_country_id->value( $country_id, false ); - if ( $wpsc_country ) { - $currency_symbol = $wpsc_country->symbol_html; - } + if ( $wpsc_country ) { + $currency_symbol = $wpsc_country->get_currency_symbol_html(); + } else { + $currency_symbol = ''; } return $currency_symbol; @@ -385,30 +416,29 @@ public static function get_currency_symbol_html( $country ) { * @access public * @since 3.8.14 * - * @param int | string $country country being checked, if non-numeric country is treated as an isocode, + * @param int | string $country country being checked, if non-numeric country is treated as an isocode, * number is the country id * - * @param boolean $as_array return the result as an array, default is to return the result as an object + * @param boolean $as_array return the result as an array, default is to return the result as an object * * @return string currency symbol HTML for the specified country, empty stdClass on failure */ public static function get_currency_data( $country, $as_array = false ) { - if ( ! self::confirmed_initialization() ) { - return 0; - } - $country_id = self::get_country_id( $country ); + $wpsc_country = self::get_country_using_code_or_id( $country ); $currency_data = new stdClass; - if ( $country_id ) { - $wpsc_country = self::$all_wpsc_country_by_country_id->value( $country_id, false ); - if ( $wpsc_country ) { - $currency_data->code = $wpsc_country->get_currency_code(); - $currency_data->symbol = $wpsc_country->get_currency_symbol(); - $currency_data->symbol_html = $wpsc_country->get_currency_symbol_html(); - $currency_data->currency = $wpsc_country->get_currency_name(); - } + if ( $wpsc_country ) { + $currency_data->code = $wpsc_country->get_currency_code(); + $currency_data->symbol = $wpsc_country->get_currency_symbol(); + $currency_data->symbol_html = $wpsc_country->get_currency_symbol_html(); + $currency_data->currency = $wpsc_country->get_currency_name(); + } else { + $currency_data->code = ''; + $currency_data->symbol = ''; + $currency_data->symbol_html = ''; + $currency_data->currency = ''; } if ( $as_array ) { @@ -425,28 +455,21 @@ public static function get_currency_data( $country, $as_array = false ) { * @access public * @since 3.8.14 * - * @param int|string $country country being checked, if noon-numeric country is treated as an + * @param int|string $country country being checked, if noon-numeric country is treated as an * isocode, number is the country id * - * @param boolean $as_array the result as an array, default is to return the result as an object + * @param boolean $as_array the result as an array, default is to return the result as an object * * @return array of region objects index by region id, empty array if no regions */ public static function get_regions( $country, $as_array = false ) { - if ( ! self::confirmed_initialization() ) { - return array(); - } - - $country_id = self::get_country_id( $country ); - $regions = array(); + $wpsc_country = self::get_country_using_code_or_id( $country ); - if ( $country_id ) { - $wpsc_country = self::$all_wpsc_country_by_country_id->value( $country_id ); - - if ( $wpsc_country->has_regions() ) { - $regions = $wpsc_country->get_regions( $as_array ); - } + if ( $wpsc_country && $wpsc_country->has_regions() ) { + $regions = $wpsc_country->get_regions( $as_array ); + } else { + $regions = array(); } return $regions; @@ -458,18 +481,15 @@ public static function get_regions( $country, $as_array = false ) { * @access public * @since 3.8.14 * - * @param boolean $include_invisible return countries that are set to invisible - * @param boolean $sortbyname return countries ordered by name + * @param boolean $include_invisible return countries that are set to invisible + * @param boolean $sortbyname return countries ordered by name * - * @return array of region objects index by region idm sorted by country name + * @return WPSC_Country[] array of countires indexed by country id sorted by country name */ public static function get_countries( $include_invisible = false, $sortbyname = true ) { - if ( ! self::confirmed_initialization() ) { - return array(); - } if ( $include_invisible ) { - $countries = self::$all_wpsc_country_by_country_id->data(); + $countries = self::$countries_by_id; foreach ( $countries as $country_id => $wpsc_country ) { $country_is_legacy = (bool) $wpsc_country->get( '_is_country_legacy' ); if ( $country_is_legacy ) { @@ -477,7 +497,7 @@ public static function get_countries( $include_invisible = false, $sortbyname = } } } else { - $countries = self::$active_wpsc_country_by_country_id->data(); + $countries = self::$visible_countries_by_id; } if ( $sortbyname && ! empty( $countries ) ) { @@ -502,37 +522,38 @@ public static function get_countries( $include_invisible = false, $sortbyname = */ public static function get_countries_array( $include_invisible = false, $sortbyname = true ) { - $countries = self::get_countries( $include_invisible, $sortbyname ); + $countries = self::get_countries( $include_invisible, $sortbyname ); $countries_list = array(); - foreach ( $countries as $country_key => $wpsc_country ) { - $country = get_object_vars( $wpsc_country ); - - $keys = array_keys( $country ); - foreach ( $keys as $index => $key ) { - // clear out the data map classes from the array - if ( is_a( $country[$key], 'WPSC_Data_Map' ) ) { - unset( $country[$key] ); - } - } - - $keys = array_keys( $country ); - foreach ( $keys as $index => $key ) { - if ( substr( $key, 0, 1 ) == '_' ) { - $keys[$index] = substr( $key, 1 ); - } - } + foreach ( $countries as $country_id => $wpsc_country ) { + $countries_list[ $country_id ] = $wpsc_country->get_array(); + } - $country = array_combine( $keys, array_values( $country ) ); + return apply_filters( 'wpsc_get_countries_array', $countries_list ); - // the return value is supporting legacy code that may look for the - // country name using 'country' rather than name, put it there - $country['country'] = $country['name']; + } - $countries_list[] = $country; + /* + * Get a WPSC_country using the numeric country id or the string country code + * + * @param int|string $country country being checked, if non-numeric country is treated as an isocode, + * number is the country id + * + * return WPSC_Country + */ + private static function get_country_using_code_or_id( $country_code_or_id ) { + $wpsc_country = false; + if ( is_numeric( $country_code_or_id ) ) { + if ( isset( self::$countries_by_id[ $country_code_or_id ] ) ) { + $wpsc_country = self::$countries_by_id[ $country_code_or_id ]; + } + } else { + if ( isset( self::$countries_by_iso_code[ $country_code_or_id ] ) ) { + $wpsc_country = self::$countries_by_iso_code[ $country_code_or_id ]; + } } - return apply_filters( 'wpsc_get_countries_array', $countries_list ); + return $wpsc_country; } /** @@ -541,24 +562,18 @@ public static function get_countries_array( $include_invisible = false, $sortbyn * @access public * @since 3.8.14 * - * @param int|string $country country being checked, if non-numeric country is treated as an isocode, + * @param int|string $country country being checked, if non-numeric country is treated as an isocode, * number is the country id * * @return int count of regions in a country, if region is invalid 0 is returned */ public static function get_region_count( $country ) { - if ( ! self::confirmed_initialization() ) { - return 0; - } - $region_count = 0; - if ( $country_id = self::get_country_id( $country ) ) { - $wpsc_country = self::$all_wpsc_country_by_country_id->value( $country_id, false ); + $wpsc_country = self::get_country_using_code_or_id( $country ); - if ( $wpsc_country ) { - $region_count = $wpsc_country->get_region_count(); - } + if ( $wpsc_country ) { + $region_count = $wpsc_country->get_region_count(); } return $region_count; @@ -570,25 +585,20 @@ public static function get_region_count( $country ) { * @access public * @since 3.8.14 * - * @param int|string $country country being checked, if noon-numeric country is treated as an isocode, + * @param int|string $country country being checked, if noon-numeric country is treated as an isocode, * number is the country * * @return true if the country has regions, false otherwise */ public static function country_has_regions( $country ) { - if ( ! self::confirmed_initialization() ) { - return false; - } // set default return value $has_regions = false; - if ( $country_id = self::get_country_id( $country ) ) { - $wpsc_country = self::$all_wpsc_country_by_country_id->value( $country_id, false ); + $wpsc_country = self::get_country_using_code_or_id( $country ); - if ( $wpsc_country ) { - $has_regions = $wpsc_country->has_regions(); - } + if ( $wpsc_country ) { + $has_regions = $wpsc_country->has_regions(); } return $has_regions; @@ -606,13 +616,14 @@ public static function country_has_regions( $country ) { * @return array country list with index as country, value as name, sorted by country name */ public static function get_country_names() { - if ( ! self::confirmed_initialization() ) { - return array(); + $country_names = array(); + + foreach ( self::$countries_by_iso_code as $country_id => $wpsc_country ) { + $country_names[ $country_id ] = $wpsc_country->get_name(); } - $country_names = array_flip( self::$country_id_by_country_name->data() ); + asort( $country_names ); - // we have the return value in our country name to id map, all we have to do is swap the keys with the values return $country_names; } @@ -625,22 +636,28 @@ public static function get_country_names() { * * @since 3.8.14 * - * @param boolean return the result as an array, default is to return the result as an object + * @param $code $as_array return the result as an array, default is to return the result as an object + * @param boolean $as_array return the result as an array, default is to return the result as an object * - * @return array country list with index as country, value as name, sorted by country name + * @return boolean|WPSC_Currency|array */ public static function get_currency( $code, $as_array = false ) { - if ( ! self::confirmed_initialization() ) { - return 0; - } - $wpsc_currency = self::$currencies->value( $code, false ); + if ( isset( self::$currencies[$code] ) ) { + $wpsc_currency = self::$currencies[ $code ]; + + if ( $as_array && $wpsc_currency ) { + $wpsc_currency = $wpsc_currency->as_array(); + } + } else { + if ( $as_array ) { + $wpsc_currency = array(); + } else { + $wpsc_currency = false; + } - if ( $as_array && $wpsc_currency ) { - $wpsc_currency = $wpsc_currency->as_array(); } - // we have the return value in our country name to id map, all we have to do is swap the keys with the values return $wpsc_currency; } @@ -658,25 +675,23 @@ public static function get_currency( $code, $as_array = false ) { * @return array country list with index as country, value as name, sorted by country name */ public static function get_currencies( $as_array = false ) { - if ( ! self::confirmed_initialization() ) { - return 0; - } - $currencies = self::$currencies->data(); + $currencies = self::$currencies; if ( $as_array ) { $currencies_list = array(); foreach ( $currencies as $currencies_key => $currency ) { - $currency_array = get_object_vars( $currency ); - $currency_array['currency'] = $currency_array['name']; // some legacy code looks for 'currency' rather than name, so we put both in the array - $currencies_list[$currency_array['code']] = $currency_array; + $currency_array = get_object_vars( $currency ); + $currency_array['currency'] = $currency_array['name']; // some legacy code looks for 'currency' rather than name, so we put both in the array + $currencies_list[ $currency_array['code'] ] = $currency_array; } $currencies = $currencies_list; } - // we have the return value in our country name to id map, all we have to do is swap the keys with the values + // we have the return value in our country name to id map, + // all we have to do is swap the keys with the values return $currencies; } @@ -695,9 +710,6 @@ public static function get_currencies( $as_array = false ) { * @return int|boolean country identifier, false on failure */ public static function get_country_id_by_region_id( $region_id ) { - if ( ! self::confirmed_initialization() ) { - return false; - } if ( is_numeric( $region_id ) ) { $region_id = intval( $region_id ); @@ -707,10 +719,18 @@ public static function get_country_id_by_region_id( $region_id ) { if ( ! $region_id ) { _wpsc_doing_it_wrong( 'WPSC_Countries::get_country_id_by_region_id', __( 'Function "get_country_id_by_region_id" requires an integer $region_id', 'wpsc' ), '3.8.14' ); + return false; } - return self::$country_id_by_region_id->value( $region_id, false ); + if ( isset( self::$regions_by_region_id[ $region_id ] ) ) { + $wpsc_region = self::$regions_by_region_id[ $region_id ]; + $country_id = $wpsc_region->get_country_id(); + } else { + $country_id = false; + } + + return $country_id; } /** @@ -725,11 +745,14 @@ public static function get_country_id_by_region_id( $region_id ) { * @return int boolean id or false on failure */ public static function get_country_id_by_country_code( $country_code ) { - if ( ! self::confirmed_initialization() ) { - return false; + $wpsc_country = self::get_country_using_code_or_id( $country_code ); + if ( $wpsc_country ) { + $country_id = $wpsc_country->get_id(); + } else { + $country_id = false; } - return self::$country_code_by_country_id->value( $country_code, false ); + return $country_id; } /** @@ -745,875 +768,201 @@ public static function get_country_id_by_country_code( $country_code ) { private static $country_id_by_country_name = null; /** - * Array of unique known currencies, indexed by corrency code - * - * @access private - * @static + * Constructor of an WPSC_countries instance * + * @access protected * @since 3.8.14 * - * @var array */ - private static $currencies = array(); + protected function __construct() { + + self::$country_visibility_overrides = get_option( 'wpsc_country_visibility_overrides', array() ); + + if ( ! empty( self::$country_visibility_overrides ) ) { + add_action( 'wpsc_is_country_visible', array( &$this, '_get_country_visible_override' ) , 10, 2 ); + } + + self::$countries_by_id = array(); + self::$visible_countries_by_id = array(); + self::$countries_by_iso_code = array(); + + $countries_data_array = _wpsc_get_countries_data_array(); + + foreach ( $countries_data_array as $country_id => $country_data_array ) { + $country_data_array['id'] = $country_id; + $wpsc_country = new WPSC_Country( $country_data_array ); + + if ( $wpsc_country->get_id() && $wpsc_country->get_isocode() ) { + self::$countries_by_iso_code[ $wpsc_country->get_isocode() ] = $wpsc_country; + + self::$countries_by_id[ $wpsc_country->get_id() ] = $wpsc_country; + + if ( $wpsc_country->is_visible() ) { + self::$visible_countries_by_id[ $wpsc_country->get_id() ] = $wpsc_country; + } + + self::$currencies[ $country_data_array['currency_code'] ] = new WPSC_Currency( $country_data_array['currency_code'], $country_data_array['currency_symbol'], $country_data_array['currency_symbol_html'], $country_data_array['name'] ); + } + } + + $regions_data_arrays = _wpsc_get_regions_data_array(); + + foreach ( $regions_data_arrays as $region_id => $region_data_array ) { + $region_data_array['id'] = $region_id; + $wpsc_region = new WPSC_Region( $region_data_array['country_id'], $region_data_array ); + + self::$regions_by_region_id[ $wpsc_region->get_id() ] = $wpsc_region; + + if ( isset( self::$countries_by_id[ $wpsc_region->get_country_id() ] ) ) { + self::$countries_by_id[ $wpsc_region->get_country_id() ]->add_region( $wpsc_region ); + } + } + + add_action( 'wpsc_country_visibility_changed', array( &$this, 'save_country_visibility_override' ) , 10, 1 ); + } /** - * An array that maps from country isocode to country id - * - * @access private - * @static - * - * @since 3.8.14 - * - * @var array + * @param WPSC_Country $wpsc_country */ - private static $country_id_by_iso_code = null; + function _get_country_visible_override( $visibility, $wpsc_country ) { + if ( isset( self::$country_visibility_overrides[ $wpsc_country->get_isocode() ] ) ) { + $visibility = self::$country_visibility_overrides[ $wpsc_country->get_isocode() ]; + } + + return $visibility; + } + + + static function set_visibility( $visibility ) { + foreach ( self::$countries_by_id as $country_id => $wpsc_country ) { + $wpsc_country->set_visible( $visibility ); + } + } /** - * An array that maps from country code to country id - * - * @access private - * - * @static - * - * @since 3.8.14 + * Save any cahnges to a countries visibility persistantly * - * @var array + * @param WPSC_Country $wpsc_country */ - private static $country_code_by_country_id = null; + function save_country_visibility_override( $wpsc_country ) { + $update_saved_option = false; + + $country_visibility_overrides = get_option( 'wpsc_country_visibility_overrides', -1 ); + if ( -1 == $country_visibility_overrides ) { + // make sure the option is initialized + $update_saved_option = true; + $country_visibility_overrides = array(); + } + + if ( isset( $country_visibility_overrides[ $wpsc_country->get_isocode() ] ) ) { + if ( $wpsc_country->is_visible() == $wpsc_country->default_is_visible() ) { + unset( $country_visibility_overrides[ $wpsc_country->get_isocode() ] ); + $update_saved_option = true; + } + } else { + if ( $wpsc_country->is_visible() != $wpsc_country->default_is_visible() ) { + $country_visibility_overrides[ $wpsc_country->get_isocode() ] = $wpsc_country->is_visible(); + $update_saved_option = true; + } + } + + if ( $update_saved_option ) { + update_option( 'wpsc_country_visibility_overrides', $country_visibility_overrides ); + } + } + /** - * map of unique region id to WPSC_Region class object - * - * @access private - * - * @static - * - * @since 3.8.14 + * @param WPSC_Country $wpsc_country + * @param bool $default * - * @var WPSC_Data_Map object + * @return bool */ - private static $region_by_region_id = null; + private function get_country_visibilty_with_override( $wpsc_country, $default = true ) { + + $result = $default; + $country_visibility_overrides = get_option( 'wpsc_country_visibility_overrides', -1 ); + if ( is_array( $country_visibility_overrides ) && isset( $country_visibility_overrides[ $wpsc_country->get_isocode() ] ) ) { + $result = $country_visibility_overrides[ $wpsc_country->get_isocode() ]; + } + + return $result; + + } + + static function get_all_regions( ) { + return self::$regions_by_region_id; + } /** - * map of not necessarily unqiue region code from unique region id - * - * @access private - * @static + * Returns a count of how many fields are in the checkout form * + * @access public * @since 3.8.14 * - * @var WPSC_Data_Map object + * @return array */ - private static $region_code_by_region_id = null; + static function get_countries_count() { + return count( self::$countries_by_id ); + } /** - * map of unqiue region id to unique country id - * - * @access private + * Compare countries using country's name * - * @static - * - * @since 3.8.14 + * @param WPSC_Country $a instance of WPSC_Country class + * @param WPSC_Country $b instance of WPSC_Country class * - * @var WPSC_Data_Map object + * @return int 0 if country names are the same, -1 if country name of a comes before country b, 1 otherwise */ - private static $country_id_by_region_id = null; + private static function _compare_countries_by_name( $a, $b ) { + return strcmp( $a->get_name(), $b->get_name() ); + } + /** - * Have we initialized this global class? - * - * @access private - * - * @static + * Compare countries using country's id * - * @since 3.8.14 + * @param WPSC_Country $a instance of WPSC_Country class + * @param WPSC_Country $b instance of WPSC_Country class * - * @var bool - */ - private static $_initialized = false; - - /** - * Contains the countries data for active countries, potentially a much smaller data set than - * all countires - * - * @access private - * @static - * - * @since 3.8.14 - * - * @var object WPSC_Data_Map - */ - private static $active_wpsc_country_by_country_id = null; - - /** - * Contains the countries data for all countries, potentially a much bigger data set than - * active countires - * - * @access private - * - * @static - * - * @since 3.8.14 - * - * @var object WPSC_Data_Map - */ - private static $all_wpsc_country_by_country_id = null; - - /** - * Contains the regions data for all countries, potentially a much bigger data set than regions for - * active countires - * - * @access private - * - * @static - * - * @since 3.8.14 - * - * @var object WPSC_Data_Map - */ - private static $all_wpsc_region_by_region_id = null; - - /** - * Has the data in this class been changed - * - * @access private - * - * @static - * - * @since 3.8.14 - * - * @var boolean - */ - private static $_dirty = false; - - /** - * Constructor of an WPSC_countries instance - * - * @access private - * @since 3.8.14 - * - */ - public function __construct() { - - if ( ! is_a( self::$active_wpsc_country_by_country_id, 'WPSC_Data_Map' ) ) { - self::_clean_data_maps(); - self::restore(); - } - - // respect the notification that temporary data has been flushed, clear our own cache and ite will rebuild the - // country data structures on the next request - add_action( 'wpsc_core_flush_temporary_data', array( __CLASS__, 'clear_cache' ) ); - - // save our class data when processing is done - add_action( 'shutdown', array( __CLASS__, 'save' ) ); - self::$_initialized = true; - } - - /** - * Returns a count of how many fields are in the checkout form - * - * @access public - * @since 3.8.14 - * - * @param bool $exclude_heading Optional. Defaults to false. Whether to exclude heading - * fields from the output - * @return array - */ - static function get_countries_count() { - return count( self::get_countries() ); - } - - /** - * Create the empty maps used by this class to do it's work. - * - * This functions contributes greatly to the performance of the class. Data maps that are named - * can store and retrieve themselves at the time of the first request. That means they don't need to - * be rebuilt every time, nor does all of the data have to be loaded and waiting for a request that - * may never come. - * - * Because the geographic data managed by this class can be accessed hundreds or even - * thousands of times when creating WPeC pages, moderate gains here can translate into - * substantial gains in end user perfroamnce. For this reason this class will try to keep - * the smaller frequently references data sets (data maps) intact and always available. - * Potentially large data sets, such as the global list of all countires with all regions, - * are only loaded when they are accessed. The WPSC_Data_Map provides the transpernet - * loading and creating functions for these data sets. - * - * - * @access private - * - * @static - * - * @since 3.8.14 - * - */ - private static function _clean_data_maps() { - - /* - * maps without names will be loaded with the core class, we maintain - * a list as they are created - */ - self::$_maps_to_save_with_core_class = array(); - - // at 3.8.14 checked and this is about 1 KB of data - if ( is_a( self::$region_by_region_id, 'WPSC_Data_Map' ) ) { - self::$region_by_region_id->clear(); - } else { - self::$region_by_region_id = new WPSC_Data_Map( null, array( __CLASS__, '_create_region_by_region_id_map' ) ); - } - self::$_maps_to_save_with_core_class['region_by_region_id'] = true; - - // at 3.14 checked and this is about 1 KB of data - if ( is_a( self::$region_code_by_region_id, 'WPSC_Data_Map' ) ) { - self::$region_code_by_region_id->clear(); - } else { - self::$region_code_by_region_id = new WPSC_Data_Map( null, array( __CLASS__, '_create_region_code_by_region_id_map' ) ); - } - self::$_maps_to_save_with_core_class['region_code_by_region_id'] = true; - - // at 3.8.14 checked and this is about 1 KB of data - if ( is_a( self::$country_id_by_region_id, 'WPSC_Data_Map' ) ) { - self::$country_id_by_region_id->clear(); - } else { - self::$country_id_by_region_id = new WPSC_Data_Map( null, array( __CLASS__, '_create_country_id_by_region_id_map' ) ); - } - self::$_maps_to_save_with_core_class['country_id_by_region_id'] = true; - - // at 3.8.14 checked and this is about 1 KB of data - if ( is_a( self::$country_id_by_iso_code, 'WPSC_Data_Map' ) ) { - self::$country_id_by_iso_code->clear(); - } else { - self::$country_id_by_iso_code = new WPSC_Data_Map( null, array( __CLASS__, '_create_country_id_by_iso_code_map' ) ); - } - self::$_maps_to_save_with_core_class['country_id_by_iso_code'] = true; - - // at 3.8.14 checked and this is about 1 KB of data - if ( is_a( self::$country_code_by_country_id, 'WPSC_Data_Map' ) ) { - self::$country_code_by_country_id->clear(); - } else { - self::$country_code_by_country_id = new WPSC_Data_Map( null, array( __CLASS__, '_create_country_code_by_country_id' ) ); - } - self::$_maps_to_save_with_core_class['country_code_by_country_id'] = true; - - // at 3.8.14 checked and this is about 2KB of data with 7 countries active, including US and CA - if ( is_a( self::$active_wpsc_country_by_country_id, 'WPSC_Data_Map' ) ) { - self::$active_wpsc_country_by_country_id->clear(); - } else { - self::$active_wpsc_country_by_country_id = new WPSC_Data_Map( null, array( __CLASS__, '_create_active_countries_map' ) ); - } - self::$_maps_to_save_with_core_class['active_wpsc_country_by_country_id'] = true; - - // at 3.8.14 checked and this is about 1 KB of data - if ( is_a( self::$currencies, 'WPSC_Data_Map' ) ) { - self::$currencies->clear(); - } else { - self::$currencies = new WPSC_Data_Map( null, array( __CLASS__, '_create_currency_by_currency_code_map' ) ); - } - self::$_maps_to_save_with_core_class['currencies'] = true; - - - /* - * maps with names can optionally reload thier data themselves when the first request - * is processed, this class does not need to load/ re-load them because the WPSC_Data_Map - * class takes care of that transparently. This goes a long way towards keeping the size of - * of the transient used to cache this classes data small, making WPeC intitialization faster. - */ - - // at 3.14 checked and this is about 3KB of data, this map isn't as frequently used so we will load it if it - // needed - if ( is_a( self::$country_id_by_country_name, 'WPSC_Data_Map' ) ) { - self::$country_id_by_country_name->clear(); - } else { - self::$country_id_by_country_name = new WPSC_Data_Map( '$country_id_by_country_name', array( __CLASS__, '_create_country_id_by_country_name_map' ) ); - } - self::$_maps_to_save_with_core_class['country_id_by_country_name'] = false; - - // at 3.14 checked and this is about 23KB of data, not a big hit if there is a memory based object cache - // but impacts perfomance on lower end (default) configurations that use the database to store transients - if ( is_a( self::$all_wpsc_country_by_country_id, 'WPSC_Data_Map' ) ) { - self::$all_wpsc_country_by_country_id->clear(); - } else { - self::$all_wpsc_country_by_country_id = new WPSC_Data_Map( '$all_wpsc_country_by_country_id', array( __CLASS__, '_create_all_countries_map' ) ); - } - self::$_maps_to_save_with_core_class['all_wpsc_country_by_country_id'] = false; - } - - /** - * keeps track of which maps should be saved with the class - * - * @access private - * - * @since 3.8.14 - * - */ - private static $_maps_to_save_with_core_class = null; - - /** - * save the contents of this class as a transient - * - * @access private - * - * @since 3.8.14 - * - * @return none - */ - public static function save() { - if ( self::_dirty() ) { - $mydata = array(); - - // This all about which maps to we want to have available as soon as this class is initialized? - // Serialize those maps into the saved verison of this object. - - $mydata['_maps_to_save_with_core_class'] = self::$_maps_to_save_with_core_class; - - foreach ( self::$_maps_to_save_with_core_class as $map_name => $save_map ) { - if ( $save_map ) { - self::$$map_name->clear_dirty(); - $mydata[$map_name] = self::$$map_name; - } - } - - _wpsc_set_transient( self::transient_name(), $mydata ); - - self::$_dirty = false; - } - } - - /** - * Restore the structured country data from the cache int the class - * - * @access private - * - * @since 3.8.14 - * - * @return none - */ - private function restore() { - - // force a class load in php - $data = _wpsc_get_transient( self::transient_name() ); - $has_data = false; - - $transient_is_valid = is_array( $data ); - - foreach( self::$_maps_to_save_with_core_class as $map_name => $should_be_saved ) { - if ( $should_be_saved ) { - if ( ( null !== $data[ $map_name ] ) && ! is_a( $data[ $map_name ], 'WPSC_Data_Map' ) ) { - $transient_is_valid = false; - _wpsc_delete_transient( self::transient_name() ); - break; - } - } - } - - if ( $transient_is_valid ) { - if ( is_array( $data ) ) { - foreach ( $data as $variable => $value ) { - if ( property_exists( $this, $variable ) ) { - - if ( is_a( $value, 'WPSC_Data_Map' ) ) { - $value->clear_dirty(); - } - - self::$$variable = $value; - $has_data = true; - } else { - // something went wrong with save / restore - $has_data = false; - break; - } - } - - self::$_initialized = true; - } - } - - if ( $transient_is_valid && ! $has_data && ( $data !== false ) ) { - _wpsc_delete_transient( self::transient_name() ); - self::$_initialized = false; - } - - self::$_dirty = false; - - return $this; - } - - /** - * Clears the copy of the structured countries data we have cached - * - * @access public - * - * @since 3.8.14 - * - * @return none - */ - public static function clear_cache() { - - // delete anthing that is stored in the transient cache - _wpsc_delete_transient( self::transient_name() ); - - // when we clear the cached copy of the sdata, we also clear the resident copy of the data - // so it is rebuilt and stays in sync - self::_clean_data_maps(); - - self::$_initialized = false; - self::$_dirty = false; - } - - /** - * has any data in this object or child objects changd - * - * @access private - * - * @since 3.8.14 - * - * @return none - */ - private static function _dirty() { - $dirty = self::$_dirty; - - foreach ( self::$_maps_to_save_with_core_class as $map_name => $save_map ) { - $map = &self::$$map_name; - if ( is_a( $map, 'WPSC_Data_Map' ) ) { - if ( $map->dirty() ) { - $dirty = true; - } - } - } - - return $dirty; - } - - /** - * Comapre countries using country's name - * - * @param unknown $a instance of WPSC_Country class - * @param unknown $b instance of WPSC_Country class - * - * @return 0 if country names are the same, -1 if country name of a comes before country b, 1 otherwise - */ - private static function _compare_countries_by_name( $a, $b ) { - return strcmp( $a->get_name(), $b->get_name() ); - } - - - /** - * Comapre countries using country's id - * - * @param unknown $a instance of WPSC_Country class - * @param unknown $b instance of WPSC_Country class - * - * @return 0 if country id's are the same, -1 if country id of a comes before country b, 1 otherwise + * @return int if country id's are the same, -1 if country id of a comes before country b, 1 otherwise */ private static function _compare_countries_by_id( $a, $b ) { if ( $a->get_id() == $b->get_id() ) { return 0; } - return ( $a->get_id() < $b->get_id() ) ? -1 : 1; - } - - - /** - * the identifier for the transient used to cache country data - * - * @access private - * - * @since 3.8.14 - * - * @return none - */ - private static function transient_name() { - return strtolower( __CLASS__ . '-' . WPSC_DB_VERSION ); - } - - /** - * Confirm the class is initialized - * - * @access private - * - * @since 3.8.14 - * - * @return none - */ - private static function confirmed_initialization() { - - if ( ! self::$_initialized ) { - $countries = new WPSC_Countries(); - self::$_initialized = (bool) $countries; - } - - return self::$_initialized; - } - - - ///////////////////////////////////////////////////////////////////////////////////////// - // - // class internal functions used to create the data maps used to provide fast access to - // global country / region / currency data. - // - //////////////////////////////////////////////////////////////////////////////////////// - - /** - * create a map that lets us find the country iso code using a numeric country id - * - * This function should be rarely called as the results are cached with the class - * data. But because caches can be cleared at any time and for multitudes of reasons - * we provide this callback to recreate the data. We use the data in other data maps - * so that we don't have to query the database for this maps data. - * - * @param WPSC_Data_Map $data_map Data map object being intitilized - * - */ - static function _create_country_code_by_country_id_map( $data_map ) { - $all_countries_data = self::$all_wpsc_country_by_country_id->data(); - - foreach ( $all_countries_data as $country_id => $wpsc_country ) { - $data_map->map( $wpsc_country->isocode, $country_id ); - } - } - - /** - * create a map that lets us find the numeric country code using a country's iso code - * - * This function should be rarely called as the results are cached with the class - * data. But because caches can be cleared at any time and for multitudes of reasons - * we provide this callback to recreate the data. We use the data in other data maps - * so that we don't have to query the database for this maps data. - * - * @param WPSC_Data_Map $data_map Data map object being intitilized - * - */ - static function _create_country_id_by_iso_code_map( $data_map ) { - $all_countries_data = self::$all_wpsc_country_by_country_id->data(); - - foreach ( $all_countries_data as $country_id => $wpsc_country ) { - $data_map->map( $wpsc_country->get_isocode(), $country_id ); - } - } - - - /** - * create a map that lets us find the numeric country code using a country's name - * - * This function should be rarely called as the results are cached with the class - * data. But because caches can be cleared at any time and for multitudes of reasons - * we provide this callback to recreate the data. We use the data in other data maps - * so that we don't have to query the database for this maps data. - * - * @param WPSC_Data_Map $data_map Data map object being intitilized - * - */ - static function _create_country_id_by_country_name_map( $data_map ) { - $all_countries_data = self::$all_wpsc_country_by_country_id->data(); - - foreach ( $all_countries_data as $country_id => $wpsc_country ) { - $data_map->map( $wpsc_country->get_name(), $country_id ); - } - } - - /** - * create a map that lets us find the numeric country id using a numeric region id - * - * This function should be rarely called as the results are cached with the class - * data. But because caches can be cleared at any time and for multitudes of reasons - * we provide this callback to recreate the data. We use the data in other data maps - * so that we don't have to query the database for this maps data. - * - * @param WPSC_Data_Map $data_map Data map object being intitilized - * - */ - static function _create_country_id_by_region_id_map( $data_map ) { - - $all_countries_data = self::$all_wpsc_country_by_country_id->data(); - - foreach ( $all_countries_data as $country_id => $wpsc_country ) { - - if ( $wpsc_country->has_regions() ) { - $regions = $wpsc_country->get_regions(); - foreach ( $regions as $region_id => $wpsc_region ) { - $data_map->map( $region_id, $country_id ); - } - } - } - } - - /** - * create a map that lets us find the WPSC_Region using a numeric region id - * - * This function should be rarely called as the results are cached with the class - * data. But because caches can be cleared at any time and for multitudes of reasons - * we provide this callback to recreate the data. We use the data in other data maps - * so that we don't have to query the database for this maps data. - * - * @param WPSC_Data_Map $data_map Data map object being intitilized - * - */ - static function _create_region_by_region_id_map( $data_map ) { - $all_countries_data = self::$all_wpsc_country_by_country_id->data(); - - foreach ( $all_countries_data as $country_id => $wpsc_country ) { - - if ( $wpsc_country->has_regions() ) { - $regions = $wpsc_country->get_regions(); - foreach ( $regions as $region_id => $wpsc_region ) { - $data_map->map( $region_id, $wpsc_region ); - } - } - } - } - - /** - * create a map that lets us find the region code using a numeric region id - * - * This function should be rarely called as the results are cached with the class - * data. But because caches can be cleared at any time and for multitudes of reasons - * we provide this callback to recreate the data. We use the data in other data maps - * so that we don't have to query the database for this maps data. - * - * @param WPSC_Data_Map $data_map Data map object being intitilized - * - */ - static function _create_region_code_by_region_id_map( $data_map ) { - - $all_countries_data = self::$all_wpsc_country_by_country_id->data(); - - foreach ( $all_countries_data as $country_id => $wpsc_country ) { - - if ( $wpsc_country->has_regions() ) { - $regions = $wpsc_country->get_regions(); - foreach ( $regions as $region_id => $wpsc_region ) { - $data_map->map( $region_id, $wpsc_region->get_code() ); - } - } - } - } - - /** - * create a map that lets us find the country iso code using a numeric country id - * - * This function should be rarely called as the results are cached with the class - * data. But because caches can be cleared at any time and for multitudes of reasons - * we provide this callback to recreate the data. We use the data in other data maps - * so that we don't have to query the database for this maps data. - * - * @param WPSC_Data_Map $data_map Data map object being intitilized - * - */ - static function _create_currency_by_currency_code_map( $data_map ) { - global $wpdb; - - // build a global active currency list - $sql = 'SELECT DISTINCT code, symbol, symbol_html, currency FROM `' . WPSC_TABLE_CURRENCY_LIST . '` ORDER BY code ASC'; - $currencies = $wpdb->get_results( $sql, OBJECT_K ); - - foreach ( $currencies as $currency_code => $currency ) { - $wpsc_currency = new WPSC_Currency( $currency->code, $currency->symbol, $currency->symbol_html, $currency->currency ); - $data_map->map( $currency_code, $wpsc_currency ); - } - - } - - /** - * callback that creates / re-creates the data map mapping all known country ids to all know countries - * - * @access private - * @since 3.8.14 - * - * @param WPSC_Data_Map $data_map Data map object being intitilized - */ - public static function _create_all_countries_map( $data_map ) { - - global $wpdb; - - // there are also invisible countries - $sql = 'SELECT ' - . ' id, country, isocode, currency, symbol, symbol_html, code, has_regions, tax, continent, visible ' - . ' FROM `' . WPSC_TABLE_CURRENCY_LIST - . '` ORDER BY id ASC'; - - $countries_array = $wpdb->get_results( $sql, OBJECT_K ); - - // build an array to map from iso code to country, while we do this get any region data for the country - foreach ( $countries_array as $country_id => $country ) { - - // create a new empty country object, add the properties we know about, then we add our region info - $wpsc_country = new WPSC_Country( null ); - $wpsc_country->_copy_properties_from_stdclass( $country ); - - if ( $country->has_regions ) { - $sql = 'SELECT id, code, country_id, name, tax ' - . ' FROM `' . WPSC_TABLE_REGION_TAX . '` ' - . ' WHERE `country_id` = %d ' - . ' ORDER BY code ASC '; - - // put the regions list into our country object - $regions = $wpdb->get_results( $wpdb->prepare( $sql, $country_id ), OBJECT_K ); - - // any properties that came in as text that should be numbers or boolean get adjusted here, we also - // build - // an array to map from region code to region id - foreach ( $regions as $region_id => $region ) { - $region->id = intval( $region_id ); - $region->country_id = intval( $region->country_id ); - $region->tax = floatval( $region->tax ); - - // create a new empty region object, then copy our region data into it. - $wpsc_region = new WPSC_Region( null, null ); - $wpsc_region->_copy_properties_from_stdclass( $region ); - $wpsc_country->_regions->map( $region->id, $wpsc_region ); - $wpsc_country->_region_id_by_region_code->map( $region->code, $region->id ); - $wpsc_country->_region_id_by_region_name->map( strtolower( $region->name ), $region->id ); - } - } - - $data_map->map( $country_id, $wpsc_country ); - } - - self::$_dirty = true; + return ( $a->get_id() < $b->get_id() ) ? - 1 : 1; } /** - * callback that creates / re-creates the data map mapping all active country ids to all active countries + * Private clone method to prevent cloning of the instance of the this instance. * - * @access private - * @since 3.8.14 - * - * @param WPSC_Data_Map $data_map Data map object being intitilized + * @return void */ - public static function _create_active_countries_map( $data_map ) { - - global $wpdb; - - // there are also invisible countries - $sql = 'SELECT ' - . ' id, country, isocode, currency, symbol, symbol_html, code, has_regions, tax, continent, visible ' - . ' FROM `' . WPSC_TABLE_CURRENCY_LIST - . '` WHERE `visible`= "1" ' - . ' ORDER BY id ASC'; - - - $countries_array = $wpdb->get_results( $sql, OBJECT_K ); - - // build an array to map from iso code to country, while we do this get any region data for the country - foreach ( $countries_array as $country_id => $country ) { - - // create a new empty country object, add the properties we know about, then we add our region info - $wpsc_country = new WPSC_Country( null ); - $wpsc_country->_copy_properties_from_stdclass( $country ); - - if ( $country->has_regions ) { - $sql = 'SELECT id, code, country_id, name, tax ' - . ' FROM `' . WPSC_TABLE_REGION_TAX . '` ' - . ' WHERE `country_id` = %d ' - . ' ORDER BY code ASC '; - - // put the regions list into our country object - $regions = $wpdb->get_results( $wpdb->prepare( $sql, $country_id ), OBJECT_K ); - - /* - * any properties that came in as text that should be numbers or boolean - * get adjusted here, we also build an array to map from region code to region id - */ - foreach ( $regions as $region_id => $region ) { - $region->id = intval( $region_id ); - $region->country_id = intval( $region->country_id ); - $region->tax = floatval( $region->tax ); - - // create a new empty region object, then copy our region data into it. - $wpsc_region = new WPSC_Region( null, null ); - $wpsc_region->_copy_properties_from_stdclass( $region ); - $wpsc_country->_regions->map( $region->id, $wpsc_region ); - $wpsc_country->_region_id_by_region_code->map( $region->code, $region->id ); - $wpsc_country->_region_id_by_region_name->map( strtolower( $region->name ), $region->id ); - } - } - - $data_map->map( $country_id, $wpsc_country ); - } - - self::$_dirty = true; + private function __clone() { } - /** - * saves country data to the database - * - * @access WPeC private + * Private unserialize method to prevent unserializing of the this instance. * - * @since 3.8.14 - * - * @param array key/value pairs that are put into the database columns - * - * @return int|boolean country_id on success, false on failure + * @return void */ - public static function _save_country_data( $country_data ) { - global $wpdb; - - /* - * We need to figure out if we are updating an existing country. There are three - * possible unique identifiers for a country. Look for a row that has any of the - * identifiers. - */ - $country_id = isset( $country_data['id'] ) ? intval( $country_data['id'] ) : 0; - $country_iso_code = isset( $country_data['isocode'] ) ? $country_data['isocode'] : ''; - - /* - * If at least one of the key feilds ins't present we aren'y going to continue, we can't reliably update - * a row in the table, nor could we insrt a row that could reliably be updated. - */ - if ( empty( $country_id ) && empty( $country_iso_code ) ) { - _wpsc_doing_it_wrong( __FUNCTION__, __( 'To insert a country either country id or country ISO code must be specified.', 'wpsc' ), '3.8.11' ); - return false; - } - - // check the database to find the country id - $sql = $wpdb->prepare( - 'SELECT id FROM ' . WPSC_TABLE_CURRENCY_LIST . ' WHERE (`id` = %d ) OR ( `isocode` = %s ) ', - $country_id, - $country_iso_code - ); - - $country_id_from_db = $wpdb->get_var( $sql ); - - // do a little data clean up prior to inserting into the database - if ( isset( $country_data['has_regions'] ) ) { - $country_data['has_regions'] = $country_data['has_regions'] ? 1:0; - } - - if ( isset( $country_data['visible'] ) ) { - $country_data['visible'] = $country_data['visible'] ? 1 : 0; - } - - // insert or update the information - if ( empty( $country_id_from_db ) ) { - // we are doing an insert of a new country - $result = $wpdb->insert( WPSC_TABLE_CURRENCY_LIST, $country_data ); - if ( $result ) { - $country_id_from_db = $wpdb->insert_id; - } - } else { - // we are doing an update of an existing country - if ( isset( $country_data['id'] ) ) { - // no nead to update the id to itself - unset( $country_data['id'] ); - } - $wpdb->update( WPSC_TABLE_CURRENCY_LIST, $country_data, array( 'id' => $country_id_from_db, ), '%s', array( '%d', ) ); - } - - // clear the cached data, force a rebuild by getting a country - self::clear_cache(); - - return $country_id_from_db; + private function __wakeup() { } - } -add_action( 'init', '_wpsc_make_countries_data_available', 10 ,1 ); - +/** + * Make the countries data available to WP eCommerce + * + * @return void + */ function _wpsc_make_countries_data_available() { $wpsc_countries = WPSC_Countries::get_instance(); } +add_action( 'wpsc_loaded', '_wpsc_make_countries_data_available' ); + + diff --git a/wpsc-includes/wpsc-country.class.php b/wpsc-includes/wpsc-country.class.php index 86d9e82c23..6c2896e163 100644 --- a/wpsc-includes/wpsc-country.class.php +++ b/wpsc-includes/wpsc-country.class.php @@ -1,4 +1,5 @@ _regions_by_region_id = array(); + $this->_regions_by_region_name = array(); + $this->_regions_by_region_code = array(); + + if ( is_array( $country ) ) { + + $this->_id = $country['id']; + + if ( isset( $country['country'] ) ) { + $this->_name = $country['country']; // backwards compatibility to before 3.8.14 + _wpsc_deprecated_argument( __FUNCTION__, '3.8.14', $this->_parameter_no_longer_used_message( 'country', __FUNCTION__ ) ); + } + + if ( isset( $country['name'] ) ) { + $this->_name = $country['name']; + } + + if ( isset( $country['isocode'] ) ) { + $this->_isocode = $country['isocode']; + } + + if ( isset( $country['has_regions'] ) ) { + $this->_has_regions = $country['has_regions']; + } + + if ( isset( $country['tax'] ) ) { + $this->_tax = $country['tax']; + } + + if ( isset( $country['continent'] ) ) { + $this->_continent = $country['continent']; + } - if ( is_array( $country ) ) { - // if we get an array as an argument we are making a new country - $country_id_or_isocode = WPSC_Countries::_save_country_data( $country ); - } else { - // we are constructing a country using a numeric id or ISO code - $country_id_or_isocode = $country; + if ( isset( $country['visible'] ) ) { + $this->_visible = $country['visible']; } + // TODO: Perhaps the currency data belongs in a WPSC_Currency object? + if ( isset( $country['currency_name'] ) ) { + $this->_currency_name = $country['currency_name']; + } + + if ( isset( $country['currency_symbol'] ) ) { + $this->_currency_symbol = $country['currency_symbol']; + } + + if ( isset( $country['currency_symbol_html'] ) ) { + $this->_currency_symbol_html = $country['currency_symbol_html']; + } + + if ( isset( $country['currency_code'] ) ) { + $this->_currency_code = $country['currency_code']; + } + + // we are going to keep track of the default visibility so that we can + // save changes to the visibilty persistantly + if ( ! isset( $country['_default_visible'] ) && isset( $country['_visible'] ) ) { + $this->_default_visible = $this->_visible; + } + + // NOTE: when initializing an object using an array od data the regions data requires additional + // calls to setup. see the WPSC_Countries calss for initialization examples. + + } else { + + $country_id_or_isocode = $country; + // make sure we have a valid country id $country_id = WPSC_Countries::get_country_id( $country_id_or_isocode ); if ( $country_id > 0 ) { @@ -45,19 +102,6 @@ public function __construct( $country, $deprecated = null ) { } } - // if the regions maps has not been initialized we should create an empty map now - if ( empty( $this->_regions ) ) { - $this->_regions = new WPSC_Data_Map(); - } - - if ( empty( $this->_region_id_by_region_code ) ){ - $this->_region_id_by_region_code = new WPSC_Data_Map(); - } - - if ( empty( $this->_region_id_by_region_name ) ){ - $this->_region_id_by_region_name = new WPSC_Data_Map(); - } - ///////////////////////////////////////////////////////////////////////////////////////////////////////// // As a result of merging the legacy WPSC_Country class we no longer need the "col" constructor parameter @@ -78,18 +122,21 @@ public function __construct( $country, $deprecated = null ) { // setup default properties filter add_filter( 'wpsc_country_get_property', array( __CLASS__, '_wpsc_country_default_properties' ), 10, 2 ); + + $this->_visible = apply_filters( 'wpsc_is_country_visible', $this->_visible, $this ); } + /** * sets the default global values for any custom properties when they are retrieved * * @since 3.8.14 * - * @param mixed $property_value - * @param string $property_name + * @param mixed $property_value + * @param string $property_name * - * @return mixed the new proprty value - */ + * @return mixed the new proprty value + */ public static function _wpsc_country_default_properties( $property_value, $property_name ) { switch ( $property_name ) { @@ -105,7 +152,6 @@ public static function _wpsc_country_default_properties( $property_value, $prope } - /** * get nation's(country's) name * @@ -113,7 +159,7 @@ public static function _wpsc_country_default_properties( $property_value, $prope * * @since 3.8.14 * - * @return string nation name + * @return string nation name */ public function get_name() { return $this->_name; @@ -152,7 +198,7 @@ public function get_isocode() { * * @since 3.8.14 * - * @return WPSC_Currency country's currency + * @return WPSC_Currency country's currency */ public function get_currency() { return new WPSC_Currency( $this->_currency_code ); @@ -165,7 +211,7 @@ public function get_currency() { * * @since 3.8.14 * - * @return string nation's (country's) currency name + * @return string nation's (country's) currency name */ public function get_currency_name() { return $this->_currency_name; @@ -178,7 +224,7 @@ public function get_currency_name() { * * @since 3.8.14 * - * @return string currency symbol + * @return string currency symbol */ public function get_currency_symbol() { return $this->_currency_symbol; @@ -191,7 +237,7 @@ public function get_currency_symbol() { * * @since 3.8.14 * - * @return string nation's (country's) currency symbol HTML + * @return string nation's (country's) currency symbol HTML */ public function get_currency_symbol_html() { return $this->_currency_symbol_html; @@ -204,7 +250,7 @@ public function get_currency_symbol_html() { * * @since 3.8.14 * - * @return string nation's (country's) currency code + * @return string nation's (country's) currency code */ public function get_currency_code() { return $this->_currency_code; @@ -219,10 +265,10 @@ public function get_currency_code() { * * @param * - * @return boolean true if we have a region lsit for the nation, false otherwise + * @return boolean true if we have a region lsit for the nation, false otherwise */ public function has_regions() { - return ( $this->_regions->count() > 0 ); + return ( count( $this->_regions_by_region_id ) ); } /** @@ -232,9 +278,9 @@ public function has_regions() { * * @since 3.8.14 * - * @param int|string $region region id, or string region name. If string is used comparison is case insensitive + * @param int|string $region region id, or string region name. If string is used comparison is case insensitive * - * @return boolean true if the region is valid for the country, false otherwise + * @return boolean true if the region is valid for the country, false otherwise */ public function has_region( $region ) { return false !== $this->get_region( $region ); @@ -247,7 +293,7 @@ public function has_region( $region ) { * * @since 3.8.14 * - * @return float nations tax rate + * @return float nations tax rate */ public function get_tax() { return $this->_tax; @@ -262,7 +308,7 @@ public function get_tax() { * * @param * - * @return string nation's continent + * @return string nation's continent */ public function get_continent() { return $this->_continent; @@ -281,6 +327,36 @@ public function is_visible() { return $this->_visible; } + /** + * should the country be displayed to the user + * + * @access public + * + * @since 3.8.14 + * + * @return boolean true if the country should be displayed, false otherwise + */ + public function default_is_visible() { + return $this->_default_visible; + } + + /** + * should the country be displayed to the user + * + * @access public + * + * @since 3.8.14 + * + * @return boolean true if the country should be displayed, false otherwise + */ + public function set_visible( $visibility = true ) { + if ( $this->_visible != $visibility ) { + $this->_visible = $visibility; + do_action( 'wpsc_country_visibility_changed', $this ); + } + } + + /** * returns a country's property matching the key, either a well know property or a property defined elsewhere * @@ -288,7 +364,7 @@ public function is_visible() { * * @since 3.8.14 * - * @return varies value of the property. Returns NULL for nonexistent property. + * @return varies value of the property. Returns NULL for nonexistent property. */ public function get( $key ) { @@ -331,12 +407,12 @@ public function set( $property, $value = '' ) { $value = $this->$property_name; _wpsc_doing_it_wrong( __FUNCTION__, __( 'Using set to change a well-known WPSC_Country property is deprecated as of version 3.8.14. Use the class constructor and specify all properties together to perform and insert or an update.', 'wpsc' ), '3.8.14' ); if ( defined( 'WPSC_LOAD_DEPRECATED' ) && WPSC_LOAD_DEPRECATED ) { - $country_array = $this->as_array(); - $country_array[$key] = $value; - $this->_save_country_data( $country_array ); + $country_array = $this->as_array(); + $country_array[ $key ] = $value; + WPSC_Countries::_save_country_data( $country_array ); } } else { - wpsc_update_meta( $this->_id, $key, $value, __CLASS__ ); + wpsc_update_meta( $this->_id, $key, $value, __CLASS__ ); } } @@ -350,7 +426,7 @@ public function set( $property, $value = '' ) { * * @since 3.8.14 * - * @param int|string required $region_identifier The region identifier, can be the text region code, or the numeric region id + * @param int|string required $region_identifier The region identifier, can be the text region code, or the numeric region id * * @return WPSC_Region|boolean The region, or false if the region code is not valid for the country */ @@ -361,16 +437,19 @@ public function get_region( $region ) { if ( $region ) { if ( is_numeric( $region ) ) { $region_id = intval( $region ); - $wpsc_region = $this->_regions->value( $region_id, $wpsc_region ); + if ( isset( $this->_regions_by_region_id[ $region_id ] ) ) { + $wpsc_region = $this->_regions_by_region_id[ $region_id ]; + } else { + $wpsc_region = false; + } } else { // check to see if it is a valid region code - if ( $region_id = $this->_region_id_by_region_code->value( $region ) ) { - $wpsc_region = $this->_regions->value( $region_id, $wpsc_region ); + if ( isset( $this->_regions_by_region_code[ $region ] ) ) { + $wpsc_region = $this->_regions_by_region_code[ $region ]; + } else if ( isset( $this->_regions_by_region_name[ strtolower( $region ) ] ) ) { + $wpsc_region = $this->_regions_by_region_name[ strtolower( $region ) ]; } else { - // check to see if we have a valid region name - if ( $region_id = $this->_region_id_by_region_name->value( strtolower( $region ) ) ) { - $wpsc_region = $this->_regions->value( $region_id, $wpsc_region ); - } + $wpsc_region = false; } } } @@ -385,7 +464,7 @@ public function get_region( $region ) { * * @since 3.8.14 * - * @param int|string required the region identifier, can be the text region code, or the numeric region id + * @param int|string required the region identifier, can be the text region code, or the numeric region id * * @return int */ @@ -405,31 +484,36 @@ public function get_region_count() { * @return WPSC_Region[] objects, indexed by region id, sorted by region */ public function get_regions( $as_array = false ) { - $regions_list = $this->_regions->data(); - - uasort( $regions_list, array( __CLASS__, '_compare_regions_by_name' ) ); - - if ( $as_array ) { + $regions_list = $this->_regions_by_region_id; - foreach ( $regions_list as $region_key => $wpsc_region ) { - $region = get_object_vars( $wpsc_region ); + if ( ! empty( $regions_list ) ) { + uasort( $regions_list, array( __CLASS__, '_compare_regions_by_name' ) ); - $keys = array_keys( $region ); - foreach ( $keys as $index => $key ) { - if ( substr( $key, 0, 1 ) == '_' ) { - $keys[$index] = substr( $key, 1 ); - } + if ( $as_array ) { + foreach ( $regions_list as $region_key => $wpsc_region ) { + $regions_list[ $region_key ] = $wpsc_region->as_array(); } - - $region = array_combine( $keys, array_values( $region ) ); - - $regions_list[$region_key] = $region; } + } else { + $regions_list = array(); } return $regions_list; } + /** + * @param WPSC_Region $wpsc_region + * + * @return $this + */ + public function add_region( &$wpsc_region ) { + $this->_regions_by_region_id[ $wpsc_region->get_id() ] = $wpsc_region; + $this->_regions_by_region_code[ $wpsc_region->get_code() ] = $wpsc_region; + $this->_regions_by_region_name[ strtolower( $wpsc_region->get_name() ) ] = $wpsc_region; + + return $this; + } + /** * get a list of regions for this country as an array of arrays * @@ -444,6 +528,7 @@ public function get_regions( $as_array = false ) { public function get_regions_array() { $regions = $this->get_regions( true ); + return $regions; } @@ -463,7 +548,7 @@ public function get_region_code_by_region_id( $region_id ) { $region_code = false; if ( isset( $this->_regions[ $region_id ] ) ) { - $region_code = $this->_region_id_to_region_code_map[$region_id]; + $region_code = $this->_region_id_to_region_code_map[ $region_id ]; } return $region_code; @@ -476,15 +561,17 @@ public function get_region_code_by_region_id( $region_id ) { * * @since 3.8.14 * - * @param string $region_name the name of the region for which we are looking for an id, case insensitive! + * @param string $region_name the name of the region for which we are looking for an id, case insensitive! * - * @return int region id + * @return int|bool region id or false if region does not exist */ public function get_region_id_by_region_code( $region_code ) { - $region_id = false; - if ( $region_code ) { - $region_id = $this->_region_id_by_region_code->value( $region_code, $region_id ); + if ( $region_code && isset( $this->_regions_by_region_code[ $region_code ] ) ) { + $wpsc_region = $this->_regions_by_region_code[ $region_code ]; + $region_id = $wpsc_region->get_id(); + } else { + $region_id = false; } return $region_id; @@ -497,15 +584,17 @@ public function get_region_id_by_region_code( $region_code ) { * * @since 3.8.14 * - * @param string $region_name the name of the region for which we are looking for an id, case insensitive! + * @param string $region_name the name of the region for which we are looking for an id, case insensitive! * * @return int region id */ public function get_region_id_by_region_name( $region_name ) { - $region_id = false; - if ( $region_name ) { - $region_id = $this->_region_id_by_region_name->value( strtolower( $region_name ) ); + if ( $region_name && isset( $this->_regions_by_region_code[ strtolower( $region_name ) ] ) ) { + $wpsc_region = $this->_regions_by_region_name[ strtolower( $region_name ) ]; + $region_id = $wpsc_region->get_id(); + } else { + $region_id = false; } return $region_id; @@ -525,19 +614,19 @@ public function get_region_id_by_region_name( $region_name ) { */ public function _copy_properties_from_stdclass( $country ) { - $this->_id = $country->id; - $this->_name = $country->country; - $this->_isocode = $country->isocode; - $this->_currency_name = $country->currency; - $this->_has_regions = $country->has_regions; - $this->_tax = $country->tax; - $this->_continent = $country->continent; - $this->_visible = $country->visible; - - // TODO: perhaps the currency information embedded in a country should reference a WPSC_Currency object by code? - $this->_currency_symbol = $country->symbol; + $this->_id = $country->id; + $this->_name = $country->country; + $this->_isocode = $country->isocode; + $this->_currency_name = $country->currency; + $this->_has_regions = $country->has_regions; + $this->_tax = $country->tax; + $this->_continent = $country->continent; + $this->_visible = $country->visible; + + // TODO: perhaps the currency information embedded in a country should reference a WPSC_Currency object by currency code? + $this->_currency_symbol = $country->symbol; $this->_currency_symbol_html = $country->symbol_html; - $this->_currency_code = $country->code; + $this->_currency_code = $country->code; if ( property_exists( $country, '_region_id_to_region_code_map' ) ) { $this->_region_id_to_region_code_map = $country->_region_id_to_region_code_map; @@ -560,19 +649,19 @@ public function _copy_properties_from_stdclass( $country ) { public function as_array() { $result = array( - 'id' => $this->_id, - 'country' => $this->_name, - 'name' => $this->_name, // backwards compatibility to before 3.8.14 - 'isocode' => $this->_isocode, - 'currency_name' => $this->_currency_name, - 'currency_symbol' => $this->_currency_symbol, + 'id' => $this->_id, + 'country' => $this->_name, + 'name' => $this->_name, // backwards compatibility to before 3.8.14 + 'isocode' => $this->_isocode, + 'currency_name' => $this->_currency_name, + 'currency_symbol' => $this->_currency_symbol, 'currency_symbol_html' => $this->_currency_symbol_html, - 'currency_code' => $this->_currency_code, - 'has_regions' => $this->_has_regions, - 'tax' => $this->_tax, + 'currency_code' => $this->_currency_code, + 'has_regions' => $this->_has_regions, + 'tax' => $this->_tax, 'continent' => $this->_continent, 'visible' => $this->_visible, - ); + ); return $result; } @@ -590,33 +679,81 @@ private static function _compare_regions_by_name( $a, $b ) { } /** - * A country's private properties, these are private to this class (notice the prefix '_'!). They are marked as public so that - * object serialization will work properly + * A country's private properties, these are private to this class (notice the prefix '_'!). * * @access public * * @since 3.8.14 * - * @param + */ + private $_id = null; + private $_name = null; + private $_isocode = null; + private $_currency_name = ''; + private $_currency_code = ''; + private $_currency_symbol = ''; + private $_currency_symbol_html = ''; + private $_code = ''; + private $_has_regions = false; + private $_tax = ''; + private $_continent = ''; + private $_visible = true; + private $_default_visible = true; + + /** + * Array of regions, indexed by region id * - * @return void + * @access private + * @static + * + * @since 4.1 + * + * @var WPSC_Region[] + */ + private $_regions_by_region_id = array(); + + /** + * Array of regions, indexed by lower case of region name + * + * @access private + * @static + * + * @since 4.1 + * + * @var WPSC_Region[] + */ + private $_regions_by_region_name = array(); + + /** + * Array of regions, indexed by region code + * + * @access private + * @static + * + * @since 4.1 + * + * @var WPSC_Region[] */ - public $_id = null; - public $_name = null; - public $_isocode = null; - public $_currency_name = ''; - public $_currency_code = ''; - public $_currency_symbol = ''; - public $_currency_symbol_html = ''; - public $_code = ''; - public $_has_regions = false; - public $_tax = ''; - public $_continent = ''; - public $_visible = true; - public $_region_id_by_region_code = null; - public $_region_id_by_region_name = null; - public $_region_id_to_region_code_map = null; - public $_regions = null; + private $_regions_by_region_code = array(); + + + public function get_array() { + return array( + 'id' => $this->_id, + 'name' => $this->_name, + 'country' => $this->_name, // backwards compatability + 'isocode' => $this->_isocode, + 'currency_name' => $this->_currency_name, + 'currency_code' => $this->_currency_code, + 'currency_symbol' => $this->_currency_symbol, + 'currency_symbol_html' => $this->_currency_symbol_html, + 'code' => $this->_code, + 'has_regions' => $this->_has_regions, + 'tax' => $this->_tax, + 'continent' => $this->_continent, + 'visible' => $this->_visible, + ); + } ///////////////////////////////////////////////////////////////////////////////////////////////////////// // As a result of merging the legacy WPSC_Country class we no longer need several of the public class @@ -634,11 +771,11 @@ private static function _compare_regions_by_name( $a, $b ) { public static function get_outdated_isocodes() { // TODO: Move this to the database $outdated_isocodes = array( - 'YU', - 'UK', - 'AN', - 'TP', - 'GF', + 'YU', + 'UK', + 'AN', + 'TP', + 'GF', ); return $outdated_isocodes; @@ -650,12 +787,13 @@ public static function get_outdated_isocodes() { */ public static function get_all( $include_invisible = false ) { - $function = __CLASS__ . '::' . __FUNCTION__ . '()'; + $function = __CLASS__ . '::' . __FUNCTION__ . '()'; $replacement = 'WPSC_Countries::get_country()'; _wpsc_deprecated_function( $function, '3.8.14', $replacement ); if ( defined( 'WPSC_LOAD_DEPRECATED' ) && WPSC_LOAD_DEPRECATED ) { $list = WPSC_Countries::get_countries( $include_invisible ); + return apply_filters( 'wpsc_country_get_all_countries', $list ); } } @@ -665,13 +803,14 @@ public static function get_all( $include_invisible = false ) { */ public static function get_cache( $value = null, $col = 'id' ) { - $function = __CLASS__ . '::' . __FUNCTION__ . '()'; + $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' ) + 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) @@ -719,7 +858,7 @@ public function get_data() { */ public function save() { if ( defined( 'WPSC_LOAD_DEPRECATED' ) && WPSC_LOAD_DEPRECATED ) { - _wpsc_doing_it_wrong( __FUNCTION__, __( 'As of version 3.8.14 calling WPSC_Country class method "save" is not required. Changes to WPSC_Country properties are saved automatically.', 'wpsc' ), '3.8.14' ); + _wpsc_doing_it_wrong( __FUNCTION__, __( 'As of version 3.8.14 calling WPSC_Country class method "save" is not required. Changes to WPSC_Country properties are saved automatically.', 'wpsc' ), '3.8.14' ); } } @@ -738,21 +877,21 @@ public function exists() { private static function _function_not_available_message( $function = 'called', $replacement = '' ) { $message = sprintf( - __( 'As of version 3.8.14 the function "%s" is no longer available in class %s. Use %s instead', 'wpsc' ), - $function, - __CLASS__, - $replacement - ); + __( 'As of version 3.8.14 the function "%s" is no longer available in class %s. Use %s instead', 'wpsc' ), + $function, + __CLASS__, + $replacement + ); return $message; } private static function _parameter_no_longer_used_message( $parameter, $function = 'called' ) { $message = sprintf( - __( 'As of version 3.8.14 the parameter "%s" for function %s is no longer used in class %s.', 'wpsc' ), - $parameter, - $function, - __CLASS__ + __( 'As of version 3.8.14 the parameter "%s" for function %s is no longer used in class %s.', 'wpsc' ), + $parameter, + $function, + __CLASS__ ); return $message; diff --git a/wpsc-includes/wpsc-data-map.class.php b/wpsc-includes/wpsc-data-map.class.php deleted file mode 100644 index dac6a2a655..0000000000 --- a/wpsc-includes/wpsc-data-map.class.php +++ /dev/null @@ -1,323 +0,0 @@ -_map_name = $map_name; - $this->_map_callback = $map_callback; - - // if our map is names it means we want to save the map for use some time in the future - if ( ! empty( $this->_map_name ) ) { - add_action( 'shutdown', array( &$this, '_save_map' ) ); - } - } - - /** - * Count of items in the map - * - * @access public - * - * @since 3.8.14 - * - * @return int - */ - public function data() { - if ( $this->_confirm_data_ready() ) { - if ( is_array( $this->_map_data ) ) { - return $this->_map_data; - } else { - return array(); - } - } - } - - /** - * Count of items in the map - * - * @access public - * - * @since 3.8.14 - * - * @return int - */ - public function count() { - $count = 0; - - if ( $this->_confirm_data_ready() ) { - if ( is_array( $this->_map_data ) ) { - $count = count( $this->_map_data ); - } - } - - return $count; - } - - /** - * Clear the cached map - * - * @access public - * - * @since 3.8.14 - * - * @return string a map name to uniquely identify this map so it can be saved and restored - */ - public function clear() { - if ( ! empty( $this->_map_name ) ) { - _wpsc_delete_transient( $this->_map_name ); - } - - $this->_map_data = null; - $this->_dirty = false; - } - - /** - * Get the value associated with a key from the map, or null on failure - * - * @access public - * - * @since 3.8.14 - * - * @param string|int $key for which the value will be retrieved - * @param any (including callable) $default what to return if the key is not found - * - * @return string the value from the data map if it is there, otherwise the value of the default parameter, or null - */ - public function value( $key, $default = null ) { - if ( $this->_confirm_data_ready() ) { - if ( isset( $this->_map_data[$key] ) ) { - $value = &$this->_map_data[$key]; - } else { - if ( $default === null ) { - $value = null; - } elseif ( is_callable( $default ) ) { - $value = call_user_func( $default ); - } else { - $value = $default; - } - } - } - - return $value; - } - - /** - * Get the value associated with a key from the map, or null on failure - * - * @access public - * - * @since 3.8.14 - * - * @param string $key the key value for the map - * @param varied $value to store in the map - * - * @return boolean true if the map data has been modified byt this or previous operations, false otherwise - */ - public function map( $key_or_array_of_key_values, $value = null ) { - - if ( $this->_confirm_data_ready() ) { - // if we got a single value add it to the map - if ( ! is_array( $key_or_array_of_key_values ) ) { - $key = $key_or_array_of_key_values; - if ( ! (isset( $this->_map_data[$key] ) && ( $this->_map_data[$key] == $value ) ) ) { - $this->_map_data[$key] = $value; - $this->_dirty = true; - } - } else { - // add map entry for each element - foreach ( $key_or_array_of_key_values as $key => $value ) { - $this->map( $key, $value ); - } - } - } - - return $this->_dirty; - } - - - /** - * Save the map- if this map has been given a name it means we will save it as a transient when - * requested or when we shutdown - * - * @access private - * - * @since 3.8.14 - * - * @return string a map name to uniquely identify this map so it can be saved and restored - */ - public function _save_map() { - if ( $this->_dirty ) { - - // we sort the data before storing it, just to be neat - ksort( $this->_map_data ); - - // if the map is named we will save it for next time, unless it is empty, we give an - // expiration so that transient storage mechanisms can destroy the map if space is needed - if ( ! empty ( $this->_map_name ) ) { - if ( ! empty( $this->_map_data ) ) { - _wpsc_set_transient( $this->_map_name, $this->_map_data, 13 * WEEK_IN_SECONDS ); - } else { - _wpsc_delete_transient( $this->_map_name ); - } - } - - $this->_dirty = false; - } - - } - - /** - * Make sure the data is available - * - * @access public - * - * @since 3.8.14 - * - * @return string a map name to uniquely identify this map so it can be saved and restored - */ - private function _confirm_data_ready() { - - if ( ! is_array( $this->_map_data ) ) { - - // if this is a named map we can try to restore it from the transient store - if ( ! empty ( $this->_map_name ) ) { - // TODO: Maybe figure out why this causes problems with APC caches, or maybe it doesn't? - // In any case because transients can be deleted at any time commenting this out should - // merely force a rebuild. - // see https://wordpress.org/support/topic/fatal-error-wpsc_countries/page/2?replies=49#post-6812338 - $this->_map_data = _wpsc_get_transient( $this->_map_name ); - } - - // if we still don't have a valid map and there is a constructor callback use it - if ( ! is_array( $this->_map_data ) && ! empty( $this->_map_callback ) && is_callable( $this->_map_callback ) ) { - static $already_invoking_callback = array(); - - // the callback could be a string or an array, we can keep track of - // who's call we are processing tp avoid a recursion problem, just in case! - $callback_unique_key = md5( json_encode( $this->_map_callback ) ); - - if ( ! array_key_exists( $callback_unique_key, $already_invoking_callback ) ) { - $already_invoking_callback[$callback_unique_key] = true; - - $this->_map_data = array(); - - // callback has a single parameter, the data map - call_user_func( $this->_map_callback, $this ); - - if ( ! is_array( $this->_map_data ) ) { - $this->_map_data = array(); - } - - if ( ! empty ( $this->_map_name ) ) { - _wpsc_set_transient( $this->_map_name, $this->_map_data ); - } - - // we just loaded and saved the data, that makes it not dirty - $this->_dirty = false; - - } else { - if ( is_array( $this->_map_callback ) ) { - $function = $this->_map_callback[0] . '::'. $this->_map_callback[1]; - } else { - $function = $this->_map_callback; - } - _wpsc_doing_it_wrong( $function , __( 'WPSC_Data_Map map creation callback is recursively calling itself.', 'wpsc' ), '3.8.14' ); - } - - unset( $already_invoking_callback[$callback_unique_key] ); - - } - - // if we still don't have valid map data create an empty array - if ( ! is_array( $this->_map_data ) ) { - $this->_map_data = array(); - } - } - - return is_array( $this->_map_data ); - } - - /** - * is the data map initialized - * - * @access public - * - * @since 3.8.14 - * - * @return boolean true if the data in the map has been initialized and the map is ready to use, false otherwise - */ - public function initialized() { - return is_array( $this->_map_data ); - } - - /** - * is the data map dirty - * - * @access public - * - * @since 3.8.14 - * - * @return boolean true if the data in the map has been modified, false otherwise - */ - public function dirty() { - return $this->_dirty; - } - - /** - * clear the dirty flag - * - * @access public - * - * @since 3.8.14 - * - * @return boolean true if the data in the map has been modified, false otherwise - */ - public function clear_dirty() { - return $this->_dirty = false; - } - - /** - * Private properties for this class, they are declared as public so that objects of this class - * can be serialized, not to provide access to the outside world. - * - * @access private - * - * @since 3.8.14 - * - */ - public $_map_name = null; - public $_map_callback = null; - public $_map_data = null; - private $_dirty = false; -} \ No newline at end of file diff --git a/wpsc-includes/wpsc-region.class.php b/wpsc-includes/wpsc-region.class.php index aa5799b529..9369b46307 100644 --- a/wpsc-includes/wpsc-region.class.php +++ b/wpsc-includes/wpsc-region.class.php @@ -1,4 +1,5 @@ _save_region_data( $region ); - } else { - $region_id_or_code = $region; - } + if ( ! empty( $country ) ) { + $this->_country_id = $country; + } else { + $this->_country_id = $region['country_id']; + } + + if ( isset( $region['id'] ) ) { + $this->_id = $region['id']; + } + + if ( isset( $region['code'] ) ) { + $this->_code = $region['code']; + } + + if ( isset( $region['name'] ) ) { + $this->_name = $region['name']; + } + + if ( isset( $region['tax'] ) ) { + $this->_tax = $region['tax']; + } - // if we have both a country country id and a region id/code we can construct this object - if ( $country && $region_id_or_code ) { - $region_id = WPSC_Countries::get_region_id( $country_id, $region_id_or_code ); + } else { - if ( $country_id && $region_id ) { - $wpsc_country = new WPSC_Country( $country_id ); - $wpsc_region = $wpsc_country->get_region( $region_id ); + $region_id_or_code = $region; - if ( $wpsc_region ) { - $this->_code = $wpsc_region->_code; - $this->_id = $wpsc_region->_id; - $this->_country_id = $wpsc_region->_country_id; - $this->_name = $wpsc_region->_name; - $this->_tax = $wpsc_region->_tax; + // if we have both a country country id and a region id/code we can construct this object + if ( $country && $region_id_or_code ) { + $region_id = WPSC_Countries::get_region_id( $country_id, $region_id_or_code ); + + if ( $country_id && $region_id ) { + $this->wpsc_country = WPSC_Countries::get_country( $country_id ); + $wpsc_region = $this->wpsc_country->get_region( $region_id ); + + if ( $wpsc_region ) { + $this->_code = $wpsc_region->_code; + $this->_id = $wpsc_region->_id; + $this->_country_id = $wpsc_region->_country_id; + $this->_name = $wpsc_region->_name; + $this->_tax = $wpsc_region->_tax; + } } } } @@ -135,6 +159,16 @@ public function get_country_id() { return $this->_country_id; } + /** + * Get the country that this region belongs within + * + * @since 4.1 + * + * @return WPSC_Country + */ + public function get_country() { + return $this->wpsc_country; + } /** * get a region's information as an array @@ -147,35 +181,16 @@ public function get_country_id() { */ public function as_array() { $result = array( - 'id' => $this->_id, - 'country_id' => $this->_country_id, - 'name' => $this->_name, - 'code' => $this->_code, - 'tax' => $this->_tax, + 'id' => $this->_id, + 'country_id' => $this->_country_id, + 'name' => $this->_name, + 'code' => $this->_code, + 'tax' => $this->_tax, ); - return $result; - } - /** - * a back-door constructor used to copy data into the class after it is retrieved from the database - * - * @access private - * - * @since 3.8.14 - * - * @param stdClass required data from WPeC distribution to be put into region - * - * @return void - */ - public function _copy_properties_from_stdclass( $region ) { - $this->_country_id = $region->country_id; - $this->_name = $region->name; - $this->_code = $region->code; - $this->_id = $region->id; - $this->_tax = $region->tax; + return $result; } - /** * returns a property matching the key, either a well know property or a property defined elsewhere * @@ -183,7 +198,7 @@ public function _copy_properties_from_stdclass( $region ) { * * @since 3.8.14 * - * @return varies value of the property + * @return varies value of the property */ public function get( $key ) { @@ -231,7 +246,7 @@ public function set( $property, $value = '' ) { $this->_save_region_data( $country_array ); } } else { - wpsc_update_meta( $this->_id, $key, $value, __CLASS__ ); + wpsc_update_meta( $this->_id, $key, $value, __CLASS__ ); } } @@ -239,68 +254,6 @@ public function set( $property, $value = '' ) { } - /** - * saves region data to the database - * - * @access private - * - * @since 3.8.14 - * - * @param array key/value pairs that are put into the database columns - * - * @return int|boolean country_id on success, false on failure - */ - private function _save_region_data( $region_data ) { - global $wpdb; - - /* - * We need to figure out if we are updating an existing country. There are three - * possible unique identifiers for a country. Look for a row that has any of the - * identifiers. - */ - $region_id = isset( $region_data['id'] ) ? intval( $region_data['id'] ) : 0; - $country_id = isset( $region_data['country_id'] ) ? intval( $region_data['country_id'] ) : 0; - $region_code = isset( $region_data['code'] ) ? $region_data['code'] : ''; - $region_name = isset( $region_data['code'] ) ? $region_data['code'] : ''; - - $region_id_from_db = false; - - /* - * If at least one of the key feilds ins't present we aren'y going to continue, we can't reliably update - * a row in the table, nor could we insrt a row that could reliably be updated. - */ - if ( empty( $country_id ) || empty( $region_code ) || empty( $region_name ) ) { - _wpsc_doing_it_wrong( __FUNCTION__, __( 'Creating a new region requires country id, region code and region name.', 'wpsc' ), '3.8.11' ); - return $region_id_from_db; - } - - if ( $region_id ) { - $sql = $wpdb->prepare( 'SELECT id FROM ' . WPSC_TABLE_REGION_TAX . ' WHERE (`id` = %d )', $region_id ); - $region_id_from_db = $wpdb->get_var( $sql ); - } - - if ( empty( $region_id_from_db ) ) { - // we are doing an insert of a new country - $result = $wpdb->insert( WPSC_TABLE_REGION_TAX, $region_data ); - if ( $result ) { - $region_id_from_db = $wpdb->insert_id; - } - } else { - // we are doing an update of an existing country - if ( isset( $region_data['id'] ) ) { - // no need to update the id to itself, don't want to allow changing of region id's either - unset( $region_data['id'] ); - } - - $wpdb->update( WPSC_TABLE_REGION_TAX, $region_data, array( 'id' => $region_id_from_db, ), '%s', array( '%d', ) ); - } - - // clear the cached data, force a rebuild - WPSC_Countries::clear_cache(); - - return $region_id_from_db; - } - /** * private region class properties - note that they are marked as public so this object can * be serialized, not to provide access. Consider yourself warned! @@ -310,10 +263,11 @@ private function _save_region_data( $region_data ) { * @since 3.8.14 * */ - public $_id = false; - public $_country_id = ''; - public $_name = ''; - public $_code = ''; - public $_tax = 0; + private $_id = false; + private $_country_id = ''; + private $_name = ''; + private $_code = ''; + private $_tax = 0; + private $wpsc_country = null; } diff --git a/wpsc-merchants/paypal-express.merchant.php b/wpsc-merchants/paypal-express.merchant.php index dd30d53b8b..195c384b09 100755 --- a/wpsc-merchants/paypal-express.merchant.php +++ b/wpsc-merchants/paypal-express.merchant.php @@ -544,7 +544,6 @@ function form_paypal_express() { // TODO verify that this query is correct, the WPSC_Countries call that repalced it was coded to duplicate the results, but // why are currecies of inactive countries being returned?? - //$old_currency_list = $wpdb->get_results( "SELECT DISTINCT `code`, `currency` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `code` IN ('" . implode( "','", $paypal_currency_list ) . "')", ARRAY_A ); $paypal_currency_list = array_map( 'esc_sql', $wpsc_gateways['wpsc_merchant_paypal_express']['supported_currencies']['currency_list'] ); $currency_list = WPSC_Countries::get_currencies( true ); $currency_codes_in_commmon = array_intersect( array_keys( $currency_list ), $paypal_currency_list ); diff --git a/wpsc-taxes/models/taxes.class.php b/wpsc-taxes/models/taxes.class.php index bd3d41ab1a..d93cefb7d1 100644 --- a/wpsc-taxes/models/taxes.class.php +++ b/wpsc-taxes/models/taxes.class.php @@ -212,23 +212,30 @@ function wpec_taxes_get_included_rate( $taxes_band_index, $country_code, $region } // wpec_taxes_get_included_rate /** - * @description: wpec_taxes_get_countries - retrieves an array of countries + * @description wpec_taxes_get_countries - retrieves an array of countries * - * @param: visibility (optional) - set to 'visible' or 'hidden' to retrieve + * @param string visibility (optional) - set to 'visible' or 'hidden' to retrieve * visible or hidden countries. Default action * is to retrieve any country. - * @return: array or false + * @return array * */ function wpec_taxes_get_countries( $visibility = 'any' ) { switch ( $visibility ) { - case 'visible': $where = array( 'visible' => 1 ); + case 'hidden': + $wpsc_countries = wpsc_get_all_countries(); break; - case 'hidden': $where = array( 'visible' => 0 ); + + case 'visible': + default: + $wpsc_countries = wpsc_get_visible_countries(); break; - default: $where = array(); - }// switch - $returnable = $this->wpec_taxes_get_country_information( array( 'country', 'isocode' ), $where, 'country' ); + } // switch + + $returnable = array(); + foreach ( $wpsc_countries as $countri_id => $wpsc_country ) { + $returnable[] = array( 'country' => $wpsc_country->get_name(), 'isocode' => $wpsc_country->get_isocode() ); + } //add all markets array_unshift( $returnable, array( 'isocode' => 'all-markets', 'country' => __( 'All Markets', 'wpsc' ) ) ); @@ -237,75 +244,35 @@ function wpec_taxes_get_countries( $visibility = 'any' ) { } // wpec_taxes_get_countries /** - * @description: wpec_get_country_information - retrieves information about a country. + * @description wpec_get_country_information - retrieves information about a country. * Note: If only one column is specified this function will return the value * of that column. If two or more columns are specified the results are * returned in an array. - * @param: columns(optional) - specify a column name or multiple column names in an array. + * @param array columns(optional) - specify a column name or multiple column names in an array. * Default action is to return all columns. - * @param: where(optional) - specify where conditions in array format. Key is column + * @param string where(optional) - specify where conditions in array format. Key is column * and value is column value. * Example: wpec_taxes_get_country_information('id', array('isocode'=>'CA')) * Default action is to not limit results. * Note: this function only compares using the equals sign (=). - * @param: order_by(optional) - specify a column name or multiple column names in an array. + * @param string order_by(optional) - specify a column name or multiple column names in an array. * Default action is to not include an order by statement. - * @return: array, int, string or false + * + * @deprecated 4.1 + * @return array, int, string or false * */ function wpec_taxes_get_country_information( $columns = false, $where = array(), $order_by = false ) { - //check for all-markets - if ( 'country' == $columns && 1 == count( $where ) && 'all-markets' == $where['isocode'] ) { - $returnable = 'All Markets'; - } else { - //database connection - global $wpdb; - - //if columns are not set select everything - $columns = ($columns) ? $columns : array( '*' ); - - //change columns to array if not an array - if ( ! is_array( $columns ) ) - $columns = array( $columns ); - - $columns = array_map( 'esc_sql', $columns ); - - //if where is set then formulate conditions - if ( ! empty( $where ) ) { - foreach ( $where as $column => $condition ) { - $condition = esc_sql( $condition ); - $where_query[] = ( is_numeric( $condition ) ) ? "{$column}={$condition}" : "{$column}='{$condition}'"; - }// foreach - }// if - - //formulate query - $query = 'SELECT ' . implode( ',', $columns ) . ' FROM ' . WPSC_TABLE_CURRENCY_LIST; - - if ( isset( $where_query ) ) - $query .= ' WHERE ' . implode( ' AND ', $where_query ); - - //if order_by is set, add to query - if ( $order_by ) { - if ( ! is_array( $order_by ) ) - $order_by = array( $order_by ); - - $order_by = array_map( 'esc_sql', $order_by ); - $query .= ' ORDER BY ' . implode( ',', $order_by ); - }// if - - $returnable = ( count( $columns ) > 1 ) ? $wpdb->get_results( $query, ARRAY_A ) : $wpdb->get_var( $query ); - }// if - - //return the result - return $returnable; + _wpsc_deprecated_function( __FUNCTION__, '4.1', 'WPSC_Countries' ); + return array(); } // wpec_taxes_get_country_information /** - * @description: wpec_taxes_get_region_information - given a region code and column + * @description wpec_taxes_get_region_information - given a region code and column * this function will return the resulting value. - * @param: region_code - code for this region - * @param: attribute (optional) - specify a column to retrieve + * @param region_code - code for this region + * @param attribute (optional) - specify a column to retrieve * Default action is to retrieve the id column. - * @return: int, string, or false + * @return int, string, or false * */ function wpec_taxes_get_region_information( $region, $attribute = 'id', $country = null ) { @@ -383,7 +350,7 @@ function wpec_taxes_get_region_code_by_id( $region ) { if ( ! empty( $region ) ) { $country_id = WPSC_Countries::get_country_id_by_region_id( $region ); if ( $country_id ) { - $wpsc_country = new WPSC_Country( $country_id ); + $wpsc_country = wpsc_get_country_object( $country_id ); } if ( isset( $wpsc_country ) ) { diff --git a/wpsc-updates/database_template.php b/wpsc-updates/database_template.php index 3bd8ba0683..cad51ab36d 100755 --- a/wpsc-updates/database_template.php +++ b/wpsc-updates/database_template.php @@ -72,25 +72,6 @@ $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}collect_data_forms"; -// code to create or update the {$wpdb->prefix}wpsc_currency_list table -$table_name = WPSC_TABLE_CURRENCY_LIST; /* !wpsc_currency_list */ -$wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment"; -$wpsc_database_template[$table_name]['columns']['country'] = "varchar(255) NOT NULL DEFAULT '' "; -$wpsc_database_template[$table_name]['columns']['isocode'] = "char(2) NULL DEFAULT '' "; -$wpsc_database_template[$table_name]['columns']['currency'] = "varchar(255) NOT NULL DEFAULT '' "; -$wpsc_database_template[$table_name]['columns']['symbol'] = "varchar(10) NOT NULL DEFAULT '' "; -$wpsc_database_template[$table_name]['columns']['symbol_html'] = "varchar(10) NOT NULL DEFAULT '' "; -$wpsc_database_template[$table_name]['columns']['code'] = "char(3) NOT NULL DEFAULT '' "; -$wpsc_database_template[$table_name]['columns']['has_regions'] = "char(1) NOT NULL DEFAULT '0' "; -$wpsc_database_template[$table_name]['columns']['tax'] = "varchar(8) NOT NULL DEFAULT '' "; -$wpsc_database_template[$table_name]['columns']['continent'] = "varchar(20) NOT NULL DEFAULT '' "; -$wpsc_database_template[$table_name]['columns']['visible'] = "varchar(1) NOT NULL DEFAULT '1' "; -$wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )"; -$wpsc_database_template[$table_name]['actions']['after']['all'] = "wpsc_add_currency_list"; -$wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}currency_list"; - - - // code to create or update the {$wpdb->prefix}wpsc_download_status table $table_name = WPSC_TABLE_DOWNLOAD_STATUS; $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment"; @@ -154,20 +135,6 @@ $wpsc_database_template[$table_name]['indexes']['gateway'] = " KEY `gateway` ( `gateway` )"; $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}purchase_logs"; - -// code to create or update the {$wpdb->prefix}wpsc_region_tax table -$table_name = WPSC_TABLE_REGION_TAX; /* !wpsc_region_tax */ -$wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment"; -$wpsc_database_template[$table_name]['columns']['country_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' "; -$wpsc_database_template[$table_name]['columns']['name'] = "varchar(64) NOT NULL DEFAULT '' "; -$wpsc_database_template[$table_name]['columns']['code'] = "char(2) NOT NULL DEFAULT '' "; -$wpsc_database_template[$table_name]['columns']['tax'] = "float NOT NULL DEFAULT '0' "; -$wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )"; -$wpsc_database_template[$table_name]['indexes']['country_id'] = " KEY `country_id` ( `country_id` )"; -$wpsc_database_template[$table_name]['actions']['after']['all'] = "wpsc_add_region_list"; -$wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}region_tax"; - - // code to create or update the {$wpdb->prefix}wpsc_submited_form_data table $table_name = WPSC_TABLE_SUBMITTED_FORM_DATA; /* !wpsc_submitted_form_data */ $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment"; diff --git a/wpsc-widgets/admin_menu_widget.php b/wpsc-widgets/admin_menu_widget.php index 9b8b87927e..80a42a4e22 100755 --- a/wpsc-widgets/admin_menu_widget.php +++ b/wpsc-widgets/admin_menu_widget.php @@ -15,7 +15,7 @@ function WP_Widget_Admin_Menu() { 'description' => __( 'Admin Menu Widget', 'wpsc' ) ); - $this->WP_Widget( 'wpsc_admin_menu', __( 'Admin Menu', 'wpsc' ), $widget_ops ); + parent::__construct( 'wpsc_admin_menu', __( 'Admin Menu', 'wpsc' ), $widget_ops ); }