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 ) ):
?>
|