WP eCommerce - Version 3.8.2

Version Description

  • Add: Currency display for Google RSS feed
  • Add: Third-party plugins can now filter 'wpsc-tax_rate' to provide their own tax solution
  • Change: Merchant subclasses now have access to $this->address_keys
  • Change: Grid Settings are now always visible
  • Change: Total Shipping is no longer included in notification email when shipping is disabled
  • Change: Thumbnail size for single product view now defaults to Single Product Page thumbnail size option
  • Change: wpsc_the_product_thumbnail() defaults to 'medium-single-product' size when in single product view
  • Fix: Update notice being displayed when it has already been completed
  • Fix: Broken image in latest products widget
  • Fix: Custom checkout field not always saved
  • Fix: Downloadable file list not updated after existing files are selected
  • Fix: Already attached downloadable files are duplicated each time you select an existing downloadable file
  • Fix: Inconsistent behavior when adding a new field to a checkout form set
  • Fix: Custom product slug not editable
  • Fix: Incompatibility issues with shipping helper and modules
  • Fix: Product meta are not included in Google product feed
  • Fix: Incorrect variation "from" price
  • Fix: Shortcode not working in single product description
  • Fix: Item cost not correctly calculated in paypal-standard-merchant
  • Fix: Invalid SSL URL for some images
  • Fix: Select from wrong table in WPSC_Merchant::get_authcode()
  • Fix: Wrong use of get_query_var() in wpsc_category_id()
  • Fix: Table wordpress.wp_wpsc_product_list doesn't exist
  • Fix: ?items_per_page=all is ignored
  • Fix: Duplicate transaction result emails
  • Fix: Wrong filter in wpsc_item_add_preview_file()
  • Fix: Wrong display type when using advanced search view mode and viewing a category
  • Fix: Category list is displayed in tag archive
  • Fix: wpsc_display_products_page() outputs "Fail" when the product shortcode is used 10 times (no kidding)
  • Fix: Single product view's thumbnail size is incorrect
  • Fix: Wrong featured thumbnail is displayed in Single Product View when there are multiple attached product images
  • Fix: Incorrect condition statements in WPSC_Coupons::compare_logic()
  • Fix: Can't add new field to checkout form set in IE
  • Fix: Missing trash icon when adding custom options to dropdowns in checkout form
  • Fix: Custom select, checkbox and radio fields are displayed as textbox on [userlog] page
  • Fix: Custom checkboxes, radios and select fields are not properly populated in Checkout form
  • Fix: Attachment metadata are not properly generated when converting product thumbnails from 3.7.x to 3.8
Download this release

Release Info

Developer garyc40
Plugin Icon 128x128 WP eCommerce
Version 3.8.2
Comparing to
See all releases

Code changes from version 3.8.1 to 3.8.2

Files changed (41) hide show
  1. readme.txt +40 -1
  2. wp-shopping-cart.php +1 -1
  3. wpsc-admin/ajax-and-init.php +26 -19
  4. wpsc-admin/display-items.page.php +3 -3
  5. wpsc-admin/display-update.page.php +3 -2
  6. wpsc-admin/display-upgrades.page.php +26 -13
  7. wpsc-admin/includes/display-items-functions.php +17 -9
  8. wpsc-admin/includes/product-functions.php +30 -21
  9. wpsc-admin/includes/save-data.functions.php +13 -8
  10. wpsc-admin/includes/settings-pages/presentation.php +35 -32
  11. wpsc-admin/includes/updating-functions.php +2 -10
  12. wpsc-admin/js/admin.js +17 -32
  13. wpsc-core/js/wp-e-commerce.js +8 -16
  14. wpsc-core/js/wpsc_colorbox.js +17 -1
  15. wpsc-core/wpsc-constants.php +8 -11
  16. wpsc-core/wpsc-deprecated.php +1 -1
  17. wpsc-core/wpsc-functions.php +10 -4
  18. wpsc-core/wpsc-installer.php +17 -15
  19. wpsc-includes/ajax.functions.php +3 -4
  20. wpsc-includes/cart.class.php +26 -19
  21. wpsc-includes/category.functions.php +8 -10
  22. wpsc-includes/checkout.class.php +34 -30
  23. wpsc-includes/coupons.class.php +7 -7
  24. wpsc-includes/form-display.functions.php +3 -4
  25. wpsc-includes/merchant.class.php +25 -24
  26. wpsc-includes/processing.functions.php +1 -1
  27. wpsc-includes/product-template.php +105 -54
  28. wpsc-includes/productfeed.php +34 -23
  29. wpsc-includes/shipping.helper.php +17 -2
  30. wpsc-includes/theme.functions.php +2 -8
  31. wpsc-includes/variations.class.php +1 -1
  32. wpsc-merchants/paypal-standard.merchant.php +1 -1
  33. wpsc-shipping/ups_20.php +8 -1
  34. wpsc-shipping/usps_20.php +48 -15
  35. wpsc-taxes/models/taxes.class.php +5 -1
  36. wpsc-theme/functions/wpsc-transaction_results_functions.php +15 -8
  37. wpsc-theme/functions/wpsc-user_log_functions.php +42 -7
  38. wpsc-theme/wpsc-category_widget.php +1 -1
  39. wpsc-theme/wpsc-grid_view.php +1 -1
  40. wpsc-widgets/category_widget.php +4 -1
  41. wpsc-widgets/latest_product_widget.php +1 -1
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://getshopped.org
4
  Tags: e-commerce, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
5
  Requires at least: 3.0
6
  Tested up to: 3.1.1
7
- Stable tag: 3.8.1
8
 
9
  WP e-Commerce is a Web 2.0 application designed with usability, aesthetics, and presentation in mind.
10
 
@@ -37,6 +37,45 @@ After upgrading from earlier versions look for link "Update Store". This will up
37
 
38
 
39
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  = 3.8.1 =
41
  * Fix: Special price mix-up when ugprade to 3.8
42
  * Fix: Missing database update notice
4
  Tags: e-commerce, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
5
  Requires at least: 3.0
6
  Tested up to: 3.1.1
7
+ Stable tag: 3.8.2
8
 
9
  WP e-Commerce is a Web 2.0 application designed with usability, aesthetics, and presentation in mind.
10
 
37
 
38
 
39
  == Changelog ==
40
+ = 3.8.2 =
41
+ * Add: Currency display for Google RSS feed
42
+ * Add: Third-party plugins can now filter 'wpsc-tax_rate' to provide their own tax solution
43
+ * Change: Merchant subclasses now have access to $this->address_keys
44
+ * Change: Grid Settings are now always visible
45
+ * Change: Total Shipping is no longer included in notification email when shipping is disabled
46
+ * Change: Thumbnail size for single product view now defaults to Single Product Page thumbnail size option
47
+ * Change: wpsc_the_product_thumbnail() defaults to 'medium-single-product' size when in single product view
48
+ * Fix: Update notice being displayed when it has already been completed
49
+ * Fix: Broken image in latest products widget
50
+ * Fix: Custom checkout field not always saved
51
+ * Fix: Downloadable file list not updated after existing files are selected
52
+ * Fix: Already attached downloadable files are duplicated each time you select an existing downloadable file
53
+ * Fix: Inconsistent behavior when adding a new field to a checkout form set
54
+ * Fix: Custom product slug not editable
55
+ * Fix: Incompatibility issues with shipping helper and modules
56
+ * Fix: Product meta are not included in Google product feed
57
+ * Fix: Incorrect variation "from" price
58
+ * Fix: Shortcode not working in single product description
59
+ * Fix: Item cost not correctly calculated in paypal-standard-merchant
60
+ * Fix: Invalid SSL URL for some images
61
+ * Fix: Select from wrong table in WPSC_Merchant::get_authcode()
62
+ * Fix: Wrong use of get_query_var() in wpsc_category_id()
63
+ * Fix: Table `wordpress.wp_wpsc_product_list` doesn't exist
64
+ * Fix: ?items_per_page=all is ignored
65
+ * Fix: Duplicate transaction result emails
66
+ * Fix: Wrong filter in wpsc_item_add_preview_file()
67
+ * Fix: Wrong display type when using advanced search view mode and viewing a category
68
+ * Fix: Category list is displayed in tag archive
69
+ * Fix: wpsc_display_products_page() outputs "Fail" when the product shortcode is used 10 times (no kidding)
70
+ * Fix: Single product view's thumbnail size is incorrect
71
+ * Fix: Wrong featured thumbnail is displayed in Single Product View when there are multiple attached product images
72
+ * Fix: Incorrect condition statements in WPSC_Coupons::compare_logic()
73
+ * Fix: Can't add new field to checkout form set in IE
74
+ * Fix: Missing trash icon when adding custom options to dropdowns in checkout form
75
+ * Fix: Custom select, checkbox and radio fields are displayed as textbox on [userlog] page
76
+ * Fix: Custom checkboxes, radios and select fields are not properly populated in Checkout form
77
+ * Fix: Attachment metadata are not properly generated when converting product thumbnails from 3.7.x to 3.8
78
+
79
  = 3.8.1 =
80
  * Fix: Special price mix-up when ugprade to 3.8
81
  * Fix: Missing database update notice
wp-shopping-cart.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WP e-Commerce
4
  * Plugin URI: http://getshopped.org/
5
  * Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://getshopped.org" target="_blank">GetShopped.org</a> | <a href="http://getshopped.org/forums/" target="_blank">Support Forum</a> | <a href="http://docs.getshopped.org/" target="_blank">Documentation</a>
6
- * Version: 3.8.1
7
  * Author: Instinct Entertainment
8
  * Author URI: http://getshopped.org/
9
  **/
3
  * Plugin Name: WP e-Commerce
4
  * Plugin URI: http://getshopped.org/
5
  * Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://getshopped.org" target="_blank">GetShopped.org</a> | <a href="http://getshopped.org/forums/" target="_blank">Support Forum</a> | <a href="http://docs.getshopped.org/" target="_blank">Documentation</a>
6
+ * Version: 3.8.2
7
  * Author: Instinct Entertainment
8
  * Author URI: http://getshopped.org/
9
  **/
wpsc-admin/ajax-and-init.php CHANGED
@@ -361,7 +361,7 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
361
  function wpsc_admin_ajax() {
362
  global $wpdb;
363
 
364
- if ( $_POST['action'] == 'product-page-order' ) {
365
  $current_order = get_option( 'wpsc_product_page_order' );
366
  $new_order = $_POST['order'];
367
 
@@ -377,19 +377,19 @@ function wpsc_admin_ajax() {
377
  }
378
 
379
 
380
- if ( ($_POST['save_image_upload_state'] == "true") && is_numeric( $_POST['image_upload_state'] ) ) {
381
  $upload_state = (int)(bool)$_POST['image_upload_state'];
382
  update_option( 'wpsc_use_flash_uploader', $upload_state );
383
  exit( "done" );
384
  }
385
 
386
- if ( ($_POST['remove_variation_value'] == "true") && is_numeric( $_POST['variation_value_id'] ) ) {
387
  $value_id = absint( $_GET['variation_value_id'] );
388
  echo wp_delete_term( $value_id, 'wpsc-variation' );
389
  exit();
390
  }
391
 
392
- if ( ($_POST['remove_form_field'] == "true") && is_numeric( $_POST['form_id'] ) ) {
393
  if ( current_user_can( 'manage_options' ) ) {
394
  $wpdb->query( $wpdb->prepare( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `active` = '0' WHERE `id` = %d LIMIT 1 ;", $_POST['form_id'] ) );
395
  exit( ' ' );
@@ -397,7 +397,7 @@ function wpsc_admin_ajax() {
397
  }
398
 
399
 
400
- if ( $_POST['hide_ecom_dashboard'] == 'true' ) {
401
  require_once (ABSPATH . WPINC . '/rss.php');
402
  $rss = fetch_rss( 'http://www.instinct.co.nz/feed/' );
403
  $rss->items = array_slice( $rss->items, 0, 5 );
@@ -406,7 +406,7 @@ function wpsc_admin_ajax() {
406
  exit( 1 );
407
  }
408
 
409
- if ( ($_POST['remove_meta'] == 'true') && is_numeric( $_POST['meta_id'] ) ) {
410
  $meta_id = (int)$_POST['meta_id'];
411
  if ( delete_meta( $meta_id ) ) {
412
  echo $meta_id;
@@ -416,7 +416,7 @@ function wpsc_admin_ajax() {
416
  exit();
417
  }
418
 
419
- if ( ($_REQUEST['log_state'] == "true") && is_numeric( $_POST['id'] ) && is_numeric( $_POST['value'] ) ) {
420
  $newvalue = $_POST['value'];
421
  if ( $_REQUEST['suspend'] == 'true' ) {
422
  if ( $_REQUEST['value'] == 1 && function_exists('wpsc_member_dedeactivate_subscriptions'))
@@ -1126,7 +1126,7 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
1126
  function prod_upload() {
1127
  global $wpdb;
1128
  $product_id = absint( $_POST["product_id"] );
1129
-
1130
  foreach ( $_POST["select_product_file"] as $selected_file ) {
1131
  // if we already use this file, there is no point doing anything more.
1132
 
@@ -1134,11 +1134,6 @@ function prod_upload() {
1134
  $file_post_data = $wpdb->get_row( $sql, ARRAY_A );
1135
  $selected_file_path = WPSC_FILE_DIR . basename( $selected_file );
1136
 
1137
- if ( isset( $attached_files_by_file[$selected_file] ) ) {
1138
- $file_is_attached = true;
1139
- }
1140
-
1141
- //if(is_file($selected_file_path)) {
1142
  if ( empty( $file_post_data ) ) {
1143
  $type = wpsc_get_mimetype( $selected_file_path );
1144
  $attachment = array(
@@ -1151,6 +1146,9 @@ function prod_upload() {
1151
  );
1152
  $id = wp_insert_post( $attachment );
1153
  } else {
 
 
 
1154
  $type = $file_post_data["post_mime_type"];
1155
  $url = $file_post_data["guid"];
1156
  $title = $file_post_data["post_title"];
@@ -1168,9 +1166,18 @@ function prod_upload() {
1168
  // Save the data
1169
  $id = wp_insert_post( $attachment );
1170
  }
1171
- //}
1172
- echo "$id\n";
 
 
 
 
 
 
 
1173
  }
 
 
1174
  }
1175
  if ( isset( $_GET['wpsc_admin_action'] ) && ($_GET['wpsc_admin_action'] == 'product_files_upload') )
1176
  add_action( 'admin_init', 'prod_upload' );
@@ -1255,7 +1262,7 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
1255
  function wpsc_checkout_settings() {
1256
  global $wpdb;
1257
  $wpdb->show_errors = true;
1258
- $filter = isset( $_POST['wpsc_form_set'] ) ? $_POST['wpsc_form_set'] : 0;
1259
 
1260
  if ( $_POST['new_form_set'] != null ) {
1261
  $checkout_sets = get_option( 'wpsc_checkout_form_sets' );
@@ -1488,9 +1495,9 @@ function wpsc_update_variations() {
1488
 
1489
  //Setup postdata
1490
  $post_data = array( );
1491
- $post_data['edit_var_val'] = $_POST["edit_var_val"];
1492
- $post_data['description'] = $_POST["description"];
1493
- $post_data['additional_description'] = $_POST['additional_description'];
1494
  $post_data['name'] = (!empty($_POST['name']))?$_POST['name']:$_POST["post_title"];
1495
 
1496
  //Add or delete variations
361
  function wpsc_admin_ajax() {
362
  global $wpdb;
363
 
364
+ if ( isset( $_POST['action'] ) && $_POST['action'] == 'product-page-order' ) {
365
  $current_order = get_option( 'wpsc_product_page_order' );
366
  $new_order = $_POST['order'];
367
 
377
  }
378
 
379
 
380
+ if ( isset( $_POST['save_image_upload_state'] ) && $_POST['save_image_upload_state'] == 'true' && is_numeric( $_POST['image_upload_state'] ) ) {
381
  $upload_state = (int)(bool)$_POST['image_upload_state'];
382
  update_option( 'wpsc_use_flash_uploader', $upload_state );
383
  exit( "done" );
384
  }
385
 
386
+ if ( isset( $_POST['remove_variation_value'] ) && $_POST['remove_variation_value'] == "true" && is_numeric( $_POST['variation_value_id'] ) ) {
387
  $value_id = absint( $_GET['variation_value_id'] );
388
  echo wp_delete_term( $value_id, 'wpsc-variation' );
389
  exit();
390
  }
391
 
392
+ if ( isset( $_POST['remove_form_field'] ) && $_POST['remove_form_field'] == "true" && is_numeric( $_POST['form_id'] ) ) {
393
  if ( current_user_can( 'manage_options' ) ) {
394
  $wpdb->query( $wpdb->prepare( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `active` = '0' WHERE `id` = %d LIMIT 1 ;", $_POST['form_id'] ) );
395
  exit( ' ' );
397
  }
398
 
399
 
400
+ if ( isset( $_POST['hide_ecom_dashboard'] ) && $_POST['hide_ecom_dashboard'] == 'true' ) {
401
  require_once (ABSPATH . WPINC . '/rss.php');
402
  $rss = fetch_rss( 'http://www.instinct.co.nz/feed/' );
403
  $rss->items = array_slice( $rss->items, 0, 5 );
406
  exit( 1 );
407
  }
408
 
409
+ if ( isset( $_POST['remove_meta'] ) && $_POST['remove_meta'] == 'true' && is_numeric( $_POST['meta_id'] ) ) {
410
  $meta_id = (int)$_POST['meta_id'];
411
  if ( delete_meta( $meta_id ) ) {
412
  echo $meta_id;
416
  exit();
417
  }
418
 
419
+ if ( isset( $_REQUEST['log_state'] ) && $_REQUEST['log_state'] == "true" && is_numeric( $_POST['id'] ) && is_numeric( $_POST['value'] ) ) {
420
  $newvalue = $_POST['value'];
421
  if ( $_REQUEST['suspend'] == 'true' ) {
422
  if ( $_REQUEST['value'] == 1 && function_exists('wpsc_member_dedeactivate_subscriptions'))
1126
  function prod_upload() {
1127
  global $wpdb;
1128
  $product_id = absint( $_POST["product_id"] );
1129
+ $output = '';
1130
  foreach ( $_POST["select_product_file"] as $selected_file ) {
1131
  // if we already use this file, there is no point doing anything more.
1132
 
1134
  $file_post_data = $wpdb->get_row( $sql, ARRAY_A );
1135
  $selected_file_path = WPSC_FILE_DIR . basename( $selected_file );
1136
 
 
 
 
 
 
1137
  if ( empty( $file_post_data ) ) {
1138
  $type = wpsc_get_mimetype( $selected_file_path );
1139
  $attachment = array(
1146
  );
1147
  $id = wp_insert_post( $attachment );
1148
  } else {
1149
+ // already attached
1150
+ if ( $file_post_data['post_parent'] == $product_id )
1151
+ continue;
1152
  $type = $file_post_data["post_mime_type"];
1153
  $url = $file_post_data["guid"];
1154
  $title = $file_post_data["post_title"];
1166
  // Save the data
1167
  $id = wp_insert_post( $attachment );
1168
  }
1169
+
1170
+ $deletion_url = wp_nonce_url( "admin.php?wpsc_admin_action=delete_file&amp;file_name={$attachment['post_title']}&amp;product_id={$product_id}", 'delete_file_' . $attachment['post_title'] );
1171
+
1172
+ $output .= "<p id='select_product_file_row_id_" . $id . "'>\n";
1173
+ $output .= " <a class='file_delete_button' href='{$deletion_url}' >\n";
1174
+ $output .= " <img src='" . WPSC_CORE_IMAGES_URL . "/cross.png' />\n";
1175
+ $output .= " </a>\n";
1176
+ $output .= " <label for='select_product_file_row_id_" . $id . "'>" . $attachment['post_title'] . "</label>\n";
1177
+ $output .= "</p>\n";
1178
  }
1179
+
1180
+ echo $output;
1181
  }
1182
  if ( isset( $_GET['wpsc_admin_action'] ) && ($_GET['wpsc_admin_action'] == 'product_files_upload') )
1183
  add_action( 'admin_init', 'prod_upload' );
1262
  function wpsc_checkout_settings() {
1263
  global $wpdb;
1264
  $wpdb->show_errors = true;
1265
+ $filter = isset( $_POST['selected_form_set'] ) ? $_POST['selected_form_set'] : 0;
1266
 
1267
  if ( $_POST['new_form_set'] != null ) {
1268
  $checkout_sets = get_option( 'wpsc_checkout_form_sets' );
1495
 
1496
  //Setup postdata
1497
  $post_data = array( );
1498
+ $post_data['edit_var_val'] = isset( $_POST['edit_var_val'] ) ? $_POST["edit_var_val"] : '';
1499
+ $post_data['description'] = isset( $_POST['description'] ) ? $_POST["description"] : '';
1500
+ $post_data['additional_description'] = isset( $_POST['additional_description'] ) ? $_POST['additional_description'] : '';
1501
  $post_data['name'] = (!empty($_POST['name']))?$_POST['name']:$_POST["post_title"];
1502
 
1503
  //Add or delete variations
wpsc-admin/display-items.page.php CHANGED
@@ -23,7 +23,7 @@ require_once(WPSC_FILE_PATH . '/wpsc-admin/includes/products.php');
23
  function wpsc_additional_column_names( $columns ){
24
  $columns = array();
25
 
26
- $columns['cb'] = '<input type="checkbox">';
27
  $columns['image'] = '';
28
  $columns['title'] = __('Name', 'wpsc');
29
  $columns['weight'] = __('Weight', 'wpsc');
@@ -176,7 +176,7 @@ function wpsc_additional_column_data( $column ) {
176
  }
177
  else
178
  echo wpsc_product_variation_price_available( $post->ID ).'+';
179
- echo '<input type="hidden" value="'.$has_var.'" name=""inline_' . $post->ID . '_has_var"" id="inline_' . $post->ID . '_has_var" />';
180
 
181
  break;
182
  case 'sale_price' :
@@ -287,7 +287,7 @@ function wpsc_cats_restrict_manage_posts_print_terms($taxonomy, $parent = 0, $le
287
  $terms = get_terms( $taxonomy, array( 'parent' => $parent ) );
288
  if( !($terms instanceof WP_Error) && !empty($terms) )
289
  foreach ( $terms as $term ){
290
- echo '<option value='. $term->slug, ( isset($_GET[$term->taxonomy]) && $_GET[$term->taxonomy] == $term->slug) ? ' selected="selected"' : '','>' . $prefix . $term->name .' (' . $term->count .')</option>';
291
  wpsc_cats_restrict_manage_posts_print_terms($taxonomy, $term->term_id, $level+1);
292
  }
293
  }
23
  function wpsc_additional_column_names( $columns ){
24
  $columns = array();
25
 
26
+ $columns['cb'] = '<input type="checkbox" />';
27
  $columns['image'] = '';
28
  $columns['title'] = __('Name', 'wpsc');
29
  $columns['weight'] = __('Weight', 'wpsc');
176
  }
177
  else
178
  echo wpsc_product_variation_price_available( $post->ID ).'+';
179
+ echo '<input type="hidden" value="'.$has_var.'" name="inline_' . $post->ID . '_has_var" id="inline_' . $post->ID . '_has_var" />';
180
 
181
  break;
182
  case 'sale_price' :
287
  $terms = get_terms( $taxonomy, array( 'parent' => $parent ) );
288
  if( !($terms instanceof WP_Error) && !empty($terms) )
289
  foreach ( $terms as $term ){
290
+ echo '<option value="'. $term->slug . '"', ( isset($_GET[$term->taxonomy]) && $_GET[$term->taxonomy] == $term->slug) ? ' selected="selected"' : '','>' . $prefix . $term->name .' (' . $term->count .')</option>';
291
  wpsc_cats_restrict_manage_posts_print_terms($taxonomy, $term->term_id, $level+1);
292
  }
293
  }
wpsc-admin/display-update.page.php CHANGED
@@ -29,8 +29,9 @@ $wpsc_version = get_option( 'wpsc_version', '0' );
29
  if ( ! get_option( 'wpsc_needs_update', false ) ) {
30
  $show_update_page = 0;
31
  } else {
32
-
33
- $product_count = $wpdb->get_var( "SELECT COUNT(*) FROM " . WPSC_TABLE_PRODUCT_LIST );
 
34
 
35
  if ( $product_count > 0 ) {
36
 
29
  if ( ! get_option( 'wpsc_needs_update', false ) ) {
30
  $show_update_page = 0;
31
  } else {
32
+
33
+ $table_exists = $wpdb->get_var( "SHOW TABLES LIKE '" . WPSC_TABLE_PRODUCT_LIST . "'" );
34
+ $product_count = empty( $table_exists ) ? 0 : $wpdb->get_var( "SELECT COUNT(*) FROM " . WPSC_TABLE_PRODUCT_LIST );
35
 
36
  if ( $product_count > 0 ) {
37
 
wpsc-admin/display-upgrades.page.php CHANGED
@@ -12,7 +12,7 @@ function wpsc_display_upgrades_page() {
12
  <br />
13
  <div class='wpsc_gold_module'>
14
  <br />
15
- <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/" target="_blank"><strong><?php _e( 'Pure Gold', 'wpsc' ); ?></strong></a>
16
  <p class='wpsc_gold_text'>Add product search, multiple image upload, gallery view, Grid View and multiple payment gateway options to your shop</p>
17
  <span class='wpsc_gold_info'>$40</span>
18
  </div>
@@ -21,28 +21,21 @@ function wpsc_display_upgrades_page() {
21
  <br />
22
  <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/dropshop-2010/" target="_blank"><strong><?php _e( 'DropShop', 'wpsc' ); ?></strong></a>
23
  <p class='wpsc_gold_text'>Impress your customers with our AJAX powered DropShop that lets your customers drag and drop products into their shopping cart</p>
24
- <span class='wpsc_gold_info'>$75</span>
25
  </div>
26
 
27
  <div class='wpsc_gold_module'>
28
  <br />
29
- <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/mp3-audio-player/" target="_blank"><strong><?php _e( 'MP3 Player', 'wpsc' ); ?></strong></a>
30
- <p class='wpsc_gold_text'>Adding this module lets you upload and manage MP3 preview files that can be associated with your digital downloads.</p>
31
- <span class='wpsc_gold_info'>$10</span>
32
- </div>
33
-
34
- <div class='wpsc_gold_module'>
35
- <br />
36
- <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/members-only-module/" target="_blank"><strong><?php _e( 'Members Only Module', 'wpsc' ); ?></strong></a>
37
- <p class='wpsc_gold_text'>The Members modules lets you set private pages and posts that are only available to paying customers. Activating this module also adds a new option under "WordPress Users" menu that shop owners can use to manage their subscribers.</p>
38
- <span class='wpsc_gold_info'>$25</span>
39
  </div>
40
 
41
  <div class='wpsc_gold_module'>
42
  <br />
43
  <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/product-slider-2010/" target="_blank"><strong><?php _e( 'Product Slider', 'wpsc' ); ?> </strong></a>
44
  <p class='wpsc_gold_text'>Display your products in a new and fancy way using the "Product Slider" module.</p>
45
- <span class='wpsc_gold_info'>$25</span>
46
  </div>
47
 
48
  <div class='wpsc_gold_module'>
@@ -51,6 +44,26 @@ function wpsc_display_upgrades_page() {
51
  <p class='wpsc_gold_text'>Make your Online photo gallery into an e-Commerce solution.</p>
52
  <span class='wpsc_gold_info'>$10</span>
53
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  </div>
55
 
56
  <h2><?php _e( 'Upgrades', 'wpsc' ); ?></h2>
12
  <br />
13
  <div class='wpsc_gold_module'>
14
  <br />
15
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/" target="_blank"><strong><?php _e( 'Gold Cart', 'wpsc' ); ?></strong></a>
16
  <p class='wpsc_gold_text'>Add product search, multiple image upload, gallery view, Grid View and multiple payment gateway options to your shop</p>
17
  <span class='wpsc_gold_info'>$40</span>
18
  </div>
21
  <br />
22
  <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/dropshop-2010/" target="_blank"><strong><?php _e( 'DropShop', 'wpsc' ); ?></strong></a>
23
  <p class='wpsc_gold_text'>Impress your customers with our AJAX powered DropShop that lets your customers drag and drop products into their shopping cart</p>
24
+ <span class='wpsc_gold_info'>$100</span>
25
  </div>
26
 
27
  <div class='wpsc_gold_module'>
28
  <br />
29
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/" target="_blank"><strong><?php _e( 'Members Access Plugin', 'wpsc' ); ?></strong></a>
30
+ <p class='wpsc_gold_text'>Create product memberships and sell them in your store. Use these memberships to restrict premium content on your posts and pages creating a "members only" area perfect for: Forums, Images and Movies and Podcasts</p>
31
+ <span class='wpsc_gold_info'>$49</span>
 
 
 
 
 
 
 
32
  </div>
33
 
34
  <div class='wpsc_gold_module'>
35
  <br />
36
  <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/product-slider-2010/" target="_blank"><strong><?php _e( 'Product Slider', 'wpsc' ); ?> </strong></a>
37
  <p class='wpsc_gold_text'>Display your products in a new and fancy way using the "Product Slider" module.</p>
38
+ <span class='wpsc_gold_info'>$45</span>
39
  </div>
40
 
41
  <div class='wpsc_gold_module'>
44
  <p class='wpsc_gold_text'>Make your Online photo gallery into an e-Commerce solution.</p>
45
  <span class='wpsc_gold_info'>$10</span>
46
  </div>
47
+
48
+ <div class='wpsc_gold_module'>
49
+ <br />
50
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/jplayer-mp3-player/" target="_blank"><strong><?php _e( 'JPlayer - MP3 Plugin', 'wpsc' ); ?> </strong></a>
51
+ <p class='wpsc_gold_text'>JPlayer is a Plugin that provides a Javascript powered MP3 player to each product. This is very similar to our alternative MP3 Player except that it uses CSS and Javascript to customize the look and feel of the player making it much easier for you to style it also comes with a range of skins.</p>
52
+ <span class='wpsc_gold_info'>$40</span>
53
+ </div>
54
+ <div class='wpsc_gold_module'>
55
+ <br />
56
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/fedex-shipping-module/" target="_blank"><strong><?php _e( 'FedEx Plugin', 'wpsc' ); ?> </strong></a>
57
+ <p class='wpsc_gold_text'>This plugin offers shop owners the ability to provide Fedex Shipping Quotes for products with weights..</p>
58
+ <span class='wpsc_gold_info'>$40</span>
59
+ </div>
60
+ <div class='wpsc_gold_module'>
61
+ <br />
62
+ <a href="http://www.bravenewcode.com/store/plugins/piggy/?utm_source=affiliate-6331&utm_medium=affiliates&utm_campaign=wpec" target="_blank"><strong><?php _e( 'Piggy', 'wpsc' ); ?> </strong></a>
63
+ <p class='wpsc_gold_text'>Your WP E-Commerce sales, in your pocket. Piggy is a web-app that provides mobile access to view sales data for your WP E-Commerce powered WordPress website. Works on iOS and Android.</p>
64
+ <span class='wpsc_gold_info'>$39</span>
65
+ </div>
66
+
67
  </div>
68
 
69
  <h2><?php _e( 'Upgrades', 'wpsc' ); ?></h2>
wpsc-admin/includes/display-items-functions.php CHANGED
@@ -70,7 +70,7 @@ add_filter( 'redirect_post_location', 'wpsc_redirect_variation_update', 10, 2 );
70
  function wpsc_css_header() {
71
  global $post_type;
72
  ?>
73
- <style>
74
  <?php if ( isset( $_GET['post_type'] ) && ( 'wpsc-product' == $_GET['post_type'] ) || ( !empty( $post_type ) && 'wpsc-product' == $post_type ) ) : ?>
75
  #icon-edit { background:transparent url('<?php echo WPSC_CORE_IMAGES_URL.'/icon32.png';?>') no-repeat; }
76
  <?php endif; ?>
@@ -1011,8 +1011,16 @@ function wpsc_attachment_fields( $form_fields, $post ) {
1011
 
1012
  $check = get_post_meta( $post->ID, '_wpsc_selected_image_size', true );
1013
  if ( !$check )
1014
- $check = 'small-product-thumbnail';
1015
-
 
 
 
 
 
 
 
 
1016
  //This loop attaches the custom thumbnail/single image sizes to this page
1017
  foreach ( $size_names as $size => $name ) {
1018
  $downsize = image_downsize( $post->ID, $size );
@@ -1180,7 +1188,7 @@ function edit_multiple_image_gallery( $post ) {
1180
 
1181
  function wpsc_save_quickedit_box( $post_id ) {
1182
  global $current_screen;
1183
- if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || $current_screen->id != 'edit-wpsc-product' || ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
1184
  return;
1185
 
1186
  $is_parent = ( bool )wpsc_product_has_children( $post_id );
@@ -1236,7 +1244,7 @@ function wpsc_quick_edit_boxes( $col_name, $_screen_post_type = null ) {
1236
  ?>
1237
  <label class="alignleft">
1238
  <span class="checkbox-title wpsc-quick-edit"><?php _e( 'SKU:', 'wpsc' ); ?> </span>
1239
- <input type="text" name="sku" class="wpsc_ie_sku">
1240
  </label>
1241
  <?php
1242
  break;
@@ -1244,7 +1252,7 @@ case 'weight' :
1244
  ?>
1245
  <label class="alignleft">
1246
  <span class="checkbox-title wpsc-quick-edit"><?php _e( 'Weight:', 'wpsc' ); ?> </span>
1247
- <input type="text" name="weight" class="wpsc_ie_weight">
1248
  </label>
1249
  <?php
1250
  break;
@@ -1252,7 +1260,7 @@ case 'stock' :
1252
  ?>
1253
  <label class="alignleft">
1254
  <span class="checkbox-title wpsc-quick-edit"><?php _e( 'Stock:', 'wpsc' ); ?> </span>
1255
- <input type="text" name="stock" class="wpsc_ie_stock">
1256
  </label>
1257
  <?php
1258
  break;
@@ -1260,7 +1268,7 @@ case 'price' :
1260
  ?>
1261
  <label class="alignleft">
1262
  <span class="checkbox-title wpsc-quick-edit"><?php _e( 'Price:', 'wpsc' ); ?> </span>
1263
- <input type="text" name="price" class="wpsc_ie_price">
1264
  </label>
1265
  <?php
1266
  break;
@@ -1268,7 +1276,7 @@ case 'sale_price' :
1268
  ?>
1269
  <label class="alignleft">
1270
  <span class="checkbox-title wpsc-quick-edit"><?php _e( 'Sale Price:', 'wpsc' ); ?> </span>
1271
- <input type="text" name="sale_price" class="wpsc_ie_sale_price">
1272
  </label>
1273
  <?php
1274
  break;
70
  function wpsc_css_header() {
71
  global $post_type;
72
  ?>
73
+ <style type="text/css">
74
  <?php if ( isset( $_GET['post_type'] ) && ( 'wpsc-product' == $_GET['post_type'] ) || ( !empty( $post_type ) && 'wpsc-product' == $post_type ) ) : ?>
75
  #icon-edit { background:transparent url('<?php echo WPSC_CORE_IMAGES_URL.'/icon32.png';?>') no-repeat; }
76
  <?php endif; ?>
1011
 
1012
  $check = get_post_meta( $post->ID, '_wpsc_selected_image_size', true );
1013
  if ( !$check )
1014
+ $check = 'medium-single-product';
1015
+
1016
+ // regenerate size metadata in case it's missing
1017
+ if ( ! image_get_intermediate_size( $post->ID, $check ) ) {
1018
+ $metadata = wp_get_attachment_metadata( $post->ID );
1019
+ $file = get_attached_file( $post->ID );
1020
+ $metadata = array_merge( wp_generate_attachment_metadata( $post->ID, $file ), $metadata );
1021
+ wp_update_attachment_metadata( $post->ID, $metadata );
1022
+ }
1023
+
1024
  //This loop attaches the custom thumbnail/single image sizes to this page
1025
  foreach ( $size_names as $size => $name ) {
1026
  $downsize = image_downsize( $post->ID, $size );
1188
 
1189
  function wpsc_save_quickedit_box( $post_id ) {
1190
  global $current_screen;
1191
+ if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || empty( $current_screen ) || $current_screen->id != 'edit-wpsc-product' || ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
1192
  return;
1193
 
1194
  $is_parent = ( bool )wpsc_product_has_children( $post_id );
1244
  ?>
1245
  <label class="alignleft">
1246
  <span class="checkbox-title wpsc-quick-edit"><?php _e( 'SKU:', 'wpsc' ); ?> </span>
1247
+ <input type="text" name="sku" class="wpsc_ie_sku" />
1248
  </label>
1249
  <?php
1250
  break;
1252
  ?>
1253
  <label class="alignleft">
1254
  <span class="checkbox-title wpsc-quick-edit"><?php _e( 'Weight:', 'wpsc' ); ?> </span>
1255
+ <input type="text" name="weight" class="wpsc_ie_weight" />
1256
  </label>
1257
  <?php
1258
  break;
1260
  ?>
1261
  <label class="alignleft">
1262
  <span class="checkbox-title wpsc-quick-edit"><?php _e( 'Stock:', 'wpsc' ); ?> </span>
1263
+ <input type="text" name="stock" class="wpsc_ie_stock" />
1264
  </label>
1265
  <?php
1266
  break;
1268
  ?>
1269
  <label class="alignleft">
1270
  <span class="checkbox-title wpsc-quick-edit"><?php _e( 'Price:', 'wpsc' ); ?> </span>
1271
+ <input type="text" name="price" class="wpsc_ie_price" />
1272
  </label>
1273
  <?php
1274
  break;
1276
  ?>
1277
  <label class="alignleft">
1278
  <span class="checkbox-title wpsc-quick-edit"><?php _e( 'Sale Price:', 'wpsc' ); ?> </span>
1279
+ <input type="text" name="sale_price" class="wpsc_ie_sale_price" />
1280
  </label>
1281
  <?php
1282
  break;
wpsc-admin/includes/product-functions.php CHANGED
@@ -43,7 +43,7 @@ function wpsc_product_has_children($id){
43
  function wpsc_admin_submit_product( $post_ID, $post ) {
44
  global $current_screen, $wpdb;
45
 
46
- if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || $current_screen->id != 'wpsc-product' || $post->post_type != 'wpsc-product' || empty( $_POST['meta'] ) )
47
  return $post_ID;
48
 
49
  //Type-casting ( not so much sanitization, which would be good to do )
@@ -51,19 +51,22 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
51
  $product_id = $post_ID;
52
  $post_data['additional_description'] = isset($post_data['additional_description']) ? $post_data['additional_description'] : '';
53
  $post_meta['meta'] = (array)$_POST['meta'];
54
- $post_data['meta']['_wpsc_price'] = abs((float)str_replace( ',','',$post_data['meta']['_wpsc_price'] ));
55
- $post_data['meta']['_wpsc_special_price'] = abs((float)str_replace( ',','',$post_data['meta']['_wpsc_special_price'] ));
 
 
56
  if($post_data['meta']['_wpsc_sku'] == __('N/A', 'wpsc'))
57
  $post_data['meta']['_wpsc_sku'] = '';
58
- if(isset($post_data['meta']['_wpsc_is_donation']))
59
  $post_data['meta']['_wpsc_is_donation'] = 1;
60
  else
61
  $post_data['meta']['_wpsc_is_donation'] = 0;
62
- if (!isset($post_data['meta']['_wpsc_limited_stock'])){
63
  $post_data['meta']['_wpsc_stock'] = false;
64
- }else {
65
- $post_data['meta']['_wpsc_stock'] = (int)$post_data['meta']['_wpsc_stock'];
66
  }
 
67
  unset($post_data['meta']['_wpsc_limited_stock']);
68
  if(!isset($post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'])) $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = '';
69
  if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
@@ -84,19 +87,21 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
84
  $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = $post_data['meta']['_wpsc_product_metadata']['weight_unit'];
85
 
86
  // table rate price
87
- $post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = $post_data['table_rate_price'];
 
88
  // if table_rate_price is unticked, wipe the table rate prices
89
- if(!isset($post_data['table_rate_price']['state'])) $post_data['table_rate_price']['state'] = '';
90
- if($post_data['table_rate_price']['state'] != 1) {$post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = null;
91
- $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] = null;
92
- $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = null;
93
- $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] = null;
94
  }
95
- foreach((array)$post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] as $key => $value){
96
- if(empty($value)){
97
- unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][$key]);
98
- unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][$key]);
99
- }
 
 
 
100
  }
101
 
102
 
@@ -172,8 +177,10 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
172
  wpsc_edit_product_variations( $product_id, $post_data );
173
 
174
  //and the alt currency
175
- foreach((array)$post_data['newCurrency'] as $key =>$value){
176
- wpsc_update_alt_product_currency($product_id, $value, $post_data['newCurrPrice'][$key]);
 
 
177
  }
178
 
179
  if($post_data['files']['file']['tmp_name'] != '') {
@@ -593,6 +600,7 @@ function wpsc_edit_product_variations($product_id, $post_data) {
593
  $product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
594
 
595
  $variation_sets_and_values = array_merge($variation_sets, $variation_values);
 
596
  wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
597
 
598
  $child_product_template = array(
@@ -737,6 +745,7 @@ function wpsc_edit_product_variations($product_id, $post_data) {
737
  }
738
  if(!empty($childs)){
739
  $old_ids_to_delete = array_diff($childs, $product_children);
 
740
  if(is_array($old_ids_to_delete) && !empty($old_ids_to_delete)) {
741
  foreach($old_ids_to_delete as $object_ids) {
742
  wp_delete_post($object_ids);
@@ -1030,7 +1039,7 @@ function wpsc_item_add_preview_file($product_id, $preview_file) {
1030
 
1031
  // Save the data
1032
  $id = wp_insert_post($attachment, $file, $product_id);
1033
- remove_filter('upload_dir', 'wpsc_modify_upload_directory');
1034
  return $id;
1035
 
1036
 
43
  function wpsc_admin_submit_product( $post_ID, $post ) {
44
  global $current_screen, $wpdb;
45
 
46
+ if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || empty( $current_screen ) || $current_screen->id != 'wpsc-product' || $post->post_type != 'wpsc-product' || empty( $_POST['meta'] ) )
47
  return $post_ID;
48
 
49
  //Type-casting ( not so much sanitization, which would be good to do )
51
  $product_id = $post_ID;
52
  $post_data['additional_description'] = isset($post_data['additional_description']) ? $post_data['additional_description'] : '';
53
  $post_meta['meta'] = (array)$_POST['meta'];
54
+ if ( isset( $post_data['meta']['_wpsc_price'] ) )
55
+ $post_data['meta']['_wpsc_price'] = abs( (float) str_replace( ',', '', $post_data['meta']['_wpsc_price'] ) );
56
+ if ( isset( $post_data['meta']['_wpsc_special_price'] ) )
57
+ $post_data['meta']['_wpsc_special_price'] = abs((float)str_replace( ',','',$post_data['meta']['_wpsc_special_price'] ));
58
  if($post_data['meta']['_wpsc_sku'] == __('N/A', 'wpsc'))
59
  $post_data['meta']['_wpsc_sku'] = '';
60
+ if( isset( $post_data['meta']['_wpsc_is_donation'] ) )
61
  $post_data['meta']['_wpsc_is_donation'] = 1;
62
  else
63
  $post_data['meta']['_wpsc_is_donation'] = 0;
64
+ if ( ! isset( $post_data['meta']['_wpsc_limited_stock'] ) ){
65
  $post_data['meta']['_wpsc_stock'] = false;
66
+ } else {
67
+ $post_data['meta']['_wpsc_stock'] = isset( $post_data['meta']['_wpsc_stock'] ) ? (int) $post_data['meta']['_wpsc_stock'] : 0;
68
  }
69
+
70
  unset($post_data['meta']['_wpsc_limited_stock']);
71
  if(!isset($post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'])) $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = '';
72
  if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
87
  $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = $post_data['meta']['_wpsc_product_metadata']['weight_unit'];
88
 
89
  // table rate price
90
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = isset( $post_data['table_rate_price'] ) ? $post_data['table_rate_price'] : array();
91
+
92
  // if table_rate_price is unticked, wipe the table rate prices
93
+ if ( empty( $post_data['table_rate_price']['state'] ) ) {
94
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] = array();
95
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = array();
 
 
96
  }
97
+
98
+ if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] ) ) {
99
+ foreach ( (array) $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] as $key => $value ){
100
+ if(empty($value)){
101
+ unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][$key]);
102
+ unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][$key]);
103
+ }
104
+ }
105
  }
106
 
107
 
177
  wpsc_edit_product_variations( $product_id, $post_data );
178
 
179
  //and the alt currency
180
+ if ( ! empty( $post_data['newCurrency'] ) ) {
181
+ foreach( (array) $post_data['newCurrency'] as $key =>$value ){
182
+ wpsc_update_alt_product_currency( $product_id, $value, $post_data['newCurrPrice'][$key] );
183
+ }
184
  }
185
 
186
  if($post_data['files']['file']['tmp_name'] != '') {
600
  $product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
601
 
602
  $variation_sets_and_values = array_merge($variation_sets, $variation_values);
603
+ $variation_sets_and_values = apply_filters('wpsc_edit_product_variation_sets_and_values', $variation_sets_and_values, $product_id);
604
  wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
605
 
606
  $child_product_template = array(
745
  }
746
  if(!empty($childs)){
747
  $old_ids_to_delete = array_diff($childs, $product_children);
748
+ $old_ids_to_delete = apply_filters('wpsc_edit_product_variations_deletion', $old_ids_to_delete);
749
  if(is_array($old_ids_to_delete) && !empty($old_ids_to_delete)) {
750
  foreach($old_ids_to_delete as $object_ids) {
751
  wp_delete_post($object_ids);
1039
 
1040
  // Save the data
1041
  $id = wp_insert_post($attachment, $file, $product_id);
1042
+ remove_filter('upload_dir', 'wpsc_modify_preview_directory');
1043
  return $id;
1044
 
1045
 
wpsc-admin/includes/save-data.functions.php CHANGED
@@ -67,7 +67,7 @@ function wpsc_custom_category_columns( $columns ) {
67
  unset( $columns["cb"] );
68
 
69
  $custom_array = array(
70
- 'cb' => '<input type="checkbox">',
71
  'image' => __( 'Image', 'wpsc' )
72
  );
73
 
@@ -599,18 +599,23 @@ function wpsc_save_category_set($category_id, $tt_id) {
599
  wpsc_update_categorymeta($category_id, 'active', '1');
600
  wpsc_update_categorymeta($category_id, 'order', '0');
601
 
602
- wpsc_update_categorymeta($category_id, 'display_type',$wpdb->escape(stripslashes($_POST['display_type'])));
603
- wpsc_update_categorymeta($category_id, 'image_height', $wpdb->escape(stripslashes($_POST['image_height'])));
604
- wpsc_update_categorymeta($category_id, 'image_width', $wpdb->escape(stripslashes($_POST['image_width'])));
 
 
 
 
 
605
 
606
 
607
- if($_POST['use_additonal_form_set'] != '') {
608
  wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $_POST['use_additonal_form_set']);
609
  } else {
610
  wpsc_delete_categorymeta($category_id, 'use_additonal_form_set');
611
  }
612
 
613
- if((bool)(int)$_POST['uses_billing_address'] == true) {
614
  wpsc_update_categorymeta($category_id, 'uses_billing_address', 1);
615
  $uses_additional_forms = true;
616
  } else {
@@ -618,7 +623,7 @@ function wpsc_save_category_set($category_id, $tt_id) {
618
  $uses_additional_forms = false;
619
  }
620
 
621
- if(isset( $_POST['countrylist2'] ) && !empty( $_POST['countrylist2'] ) && ($category_id > 0)){
622
  $AllSelected = false;
623
  $countryList = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_CURRENCY_LIST."`");
624
 
@@ -629,7 +634,7 @@ function wpsc_save_category_set($category_id, $tt_id) {
629
  wpsc_update_categorymeta( $category_id, 'target_market', $selectedCountries);
630
  }
631
 
632
- }elseif(!isset($_POST['countrylist2'])){
633
  wpsc_update_categorymeta( $category_id, 'target_market','');
634
  $AllSelected = true;
635
  }
67
  unset( $columns["cb"] );
68
 
69
  $custom_array = array(
70
+ 'cb' => '<input type="checkbox" />',
71
  'image' => __( 'Image', 'wpsc' )
72
  );
73
 
599
  wpsc_update_categorymeta($category_id, 'active', '1');
600
  wpsc_update_categorymeta($category_id, 'order', '0');
601
 
602
+ if ( isset( $_POST['display_type'] ) )
603
+ wpsc_update_categorymeta($category_id, 'display_type',$wpdb->escape(stripslashes($_POST['display_type'])));
604
+
605
+ if ( isset( $_POST['image_height'] ) )
606
+ wpsc_update_categorymeta($category_id, 'image_height', $wpdb->escape(stripslashes($_POST['image_height'])));
607
+
608
+ if ( isset( $_POST['image_width'] ) )
609
+ wpsc_update_categorymeta($category_id, 'image_width', $wpdb->escape(stripslashes($_POST['image_width'])));
610
 
611
 
612
+ if ( ! empty( $_POST['use_additional_form_set'] ) ) {
613
  wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $_POST['use_additonal_form_set']);
614
  } else {
615
  wpsc_delete_categorymeta($category_id, 'use_additonal_form_set');
616
  }
617
 
618
+ if ( ! empty( $_POST['uses_billing_address'] ) ) {
619
  wpsc_update_categorymeta($category_id, 'uses_billing_address', 1);
620
  $uses_additional_forms = true;
621
  } else {
623
  $uses_additional_forms = false;
624
  }
625
 
626
+ if( ! empty( $_POST['countrylist2'] ) && ($category_id > 0)){
627
  $AllSelected = false;
628
  $countryList = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_CURRENCY_LIST."`");
629
 
634
  wpsc_update_categorymeta( $category_id, 'target_market', $selectedCountries);
635
  }
636
 
637
+ } elseif ( ! isset($_POST['countrylist2'] ) ){
638
  wpsc_update_categorymeta( $category_id, 'target_market','');
639
  $AllSelected = true;
640
  }
wpsc-admin/includes/settings-pages/presentation.php CHANGED
@@ -468,7 +468,7 @@ function wpsc_options_presentation() {
468
  $display_moredetails = '';
469
  }
470
  ?>
471
- <select name='wpsc_options[product_view]' onchange="toggle_display_options(this.options[this.selectedIndex].value)">
472
  <option value='default' <?php echo $product_view1; ?>><?php _e( 'Default View', 'wpsc' ); ?></option>
473
  <?php
474
  if ( function_exists( 'product_display_list' ) ) {
@@ -497,37 +497,39 @@ function wpsc_options_presentation() {
497
  ?><a href='http://getshopped.org/extend/premium-upgrades'><?php _e( 'Purchase unavailable options', 'wpsc' ); ?></a> <?php
498
  }
499
  ?>
500
-
501
- <div id='grid_view_options' <?php if ( isset( $list_view_quantity_style ) )
502
- echo $list_view_quantity_style; ?> <?php if ( is_null( $product_view3 ) ) {
503
- echo "style='display:none;'";
504
- } ?>>
505
-
506
- <input type='text' name='wpsc_options[grid_number_per_row]' id='grid_number_per_row' size='1' value='<?php esc_attr_e( get_option( 'grid_number_per_row' ) ); ?>' />
507
- <label for='grid_number_per_row'><?php _e( 'Products Per Row', 'wpsc' ); ?></label><br />
508
-
509
- <input type='hidden' value='0' name='wpsc_options[show_images_only]' />
510
- <input type='checkbox' value='1' name='wpsc_options[show_images_only]' id='show_images_only' <?php echo $show_images_only_value; ?> />
511
- <label for='show_images_only'><?php _e( 'Show images only', 'wpsc' ); ?></label><br />
512
-
513
- <input type='hidden' value='0' name='wpsc_options[display_variations]' />
514
- <input type='checkbox' value='1' name='wpsc_options[display_variations]' id='display_variations' <?php echo $display_variations; ?> />
515
- <label for='display_variations'><?php _e( 'Display Variations', 'wpsc' ); ?></label><br />
516
-
517
- <input type='hidden' value='0' name='wpsc_options[display_description]' />
518
- <input type='checkbox' value='1' name='wpsc_options[display_description]' id='display_description' <?php echo $display_description; ?> />
519
- <label for='display_description'><?php _e( 'Display Description', 'wpsc' ); ?></label><br />
520
-
521
- <input type='hidden' value='0' name='wpsc_options[display_addtocart]' />
522
- <input type='checkbox' value='1' name='wpsc_options[display_addtocart]' id='display_addtocart' <?php echo $display_addtocart; ?> />
523
- <label for='display_addtocart'><?php _e( 'Display "Add To Cart" Button', 'wpsc' ); ?></label><br />
524
-
525
- <input type='hidden' value='0' name='wpsc_options[display_moredetails]' />
526
- <input type='checkbox' value='1' name='wpsc_options[display_moredetails]' id='display_moredetails' <?php echo $display_moredetails; ?> />
527
- <label for='display_moredetails'><?php _e( 'Display "More Details" Button', 'wpsc' ); ?></label>
528
- </div>
529
- </td>
530
- </tr>
 
 
531
  <?php
532
  $selected1 = $selected2 = '';
533
  if(get_option('wpsc_display_categories'))
@@ -535,6 +537,7 @@ function wpsc_options_presentation() {
535
  else
536
  $selected2 = 'checked="checked"';
537
  ?>
 
538
  <tr>
539
  <th scope="row"><?php _e('Show list of categories','wpsc'); ?></th>
540
  <td>
468
  $display_moredetails = '';
469
  }
470
  ?>
471
+ <select name='wpsc_options[product_view]'>
472
  <option value='default' <?php echo $product_view1; ?>><?php _e( 'Default View', 'wpsc' ); ?></option>
473
  <?php
474
  if ( function_exists( 'product_display_list' ) ) {
497
  ?><a href='http://getshopped.org/extend/premium-upgrades'><?php _e( 'Purchase unavailable options', 'wpsc' ); ?></a> <?php
498
  }
499
  ?>
500
+ </td>
501
+ </tr>
502
+
503
+
504
+ <tr id="wpsc-grid-settings">
505
+ <th scope="row"><?php _e( 'Grid view settings:', 'wpsc' ) ?></th>
506
+ <td>
507
+ <input type='text' name='wpsc_options[grid_number_per_row]' id='grid_number_per_row' size='1' value='<?php esc_attr_e( get_option( 'grid_number_per_row' ) ); ?>' />
508
+ <label for='grid_number_per_row'><?php _e( 'Products Per Row', 'wpsc' ); ?></label><br />
509
+
510
+ <input type='hidden' value='0' name='wpsc_options[show_images_only]' />
511
+ <input type='checkbox' value='1' name='wpsc_options[show_images_only]' id='show_images_only' <?php echo $show_images_only_value; ?> />
512
+ <label for='show_images_only'><?php _e( 'Show images only', 'wpsc' ); ?></label><br />
513
+
514
+ <input type='hidden' value='0' name='wpsc_options[display_variations]' />
515
+ <input type='checkbox' value='1' name='wpsc_options[display_variations]' id='display_variations' <?php echo $display_variations; ?> />
516
+ <label for='display_variations'><?php _e( 'Display Variations', 'wpsc' ); ?></label><br />
517
+
518
+ <input type='hidden' value='0' name='wpsc_options[display_description]' />
519
+ <input type='checkbox' value='1' name='wpsc_options[display_description]' id='display_description' <?php echo $display_description; ?> />
520
+ <label for='display_description'><?php _e( 'Display Description', 'wpsc' ); ?></label><br />
521
+
522
+ <input type='hidden' value='0' name='wpsc_options[display_addtocart]' />
523
+ <input type='checkbox' value='1' name='wpsc_options[display_addtocart]' id='display_addtocart' <?php echo $display_addtocart; ?> />
524
+ <label for='display_addtocart'><?php _e( 'Display "Add To Cart" Button', 'wpsc' ); ?></label><br />
525
+
526
+ <input type='hidden' value='0' name='wpsc_options[display_moredetails]' />
527
+ <input type='checkbox' value='1' name='wpsc_options[display_moredetails]' id='display_moredetails' <?php echo $display_moredetails; ?> />
528
+ <label for='display_moredetails'><?php _e( 'Display "More Details" Button', 'wpsc' ); ?></label>
529
+ </td>
530
+ </tr>
531
+
532
+
533
  <?php
534
  $selected1 = $selected2 = '';
535
  if(get_option('wpsc_display_categories'))
537
  else
538
  $selected2 = 'checked="checked"';
539
  ?>
540
+
541
  <tr>
542
  <th scope="row"><?php _e('Show list of categories','wpsc'); ?></th>
543
  <td>
wpsc-admin/includes/updating-functions.php CHANGED
@@ -303,17 +303,9 @@ GROUP BY ".WPSC_TABLE_PRODUCT_LIST.".id", ARRAY_A);
303
  );
304
  $attachment_id = wp_insert_post($image_post_values);
305
  }
306
- $image_size_data = @getimagesize($full_image_path);
307
- $image_metadata = array(
308
- 'width' => $image_size_data[0],
309
- 'height' => $image_size_data[1],
310
- 'file' => $subdir
311
- );
312
 
313
-
314
- update_post_meta( $attachment_id, '_wp_attached_file', $subdir );
315
- update_post_meta( $attachment_id, '_wp_attachment_metadata', $image_metadata);
316
-
317
  }
318
 
319
  }
303
  );
304
  $attachment_id = wp_insert_post($image_post_values);
305
  }
 
 
 
 
 
 
306
 
307
+ update_attached_file( $attachment_id, $new_path );
308
+ wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $new_path ) );
 
 
309
  }
310
 
311
  }
wpsc-admin/js/admin.js CHANGED
@@ -145,7 +145,7 @@ jQuery(document).ready(function(){
145
  jQuery('#checkout_'+id).after(returned_data);
146
  }else{
147
  output = "<tr class='wpsc_grey'><td></td><td colspan='5'>Please Save your changes before trying to Order your Checkout Forms again.</td></tr>\r\n<tr class='wpsc_grey'><td></td><th>Label</th><th >Value</th><td colspan='3'><a href='' class='wpsc_add_new_checkout_option' title='form_options["+id+"]'>+ New Option</a></td></tr>";
148
- output += "<tr class='wpsc_grey'><td></td><td><input type='text' value='' name='wpsc_checkout_option_label["+id+"][]' /></td><td colspan='4'><input type='text' value='' name='wpsc_checkout_option_value["+id+"][]' /><a class='wpsc_delete_option' href='' ><img src='" + WPSC_CORE_IMAGES_URL + "trash.gif' alt='Delete' title='delete' /></a></td></tr>";
149
  jQuery('#checkout_'+id).after(output);
150
 
151
  }
@@ -216,11 +216,14 @@ jQuery(document).ready(function(){
216
  var product_id = jQuery(this).parent("form.product_upload").find('input#hidden_id').val();
217
  post_values = products + '&product_id=' + product_id;
218
  jQuery.post('admin.php?wpsc_admin_action=product_files_upload',post_values, function(returned_data){
219
- jQuery("#TB_closeWindowButton").click(TB_remove);
220
-
 
 
 
 
 
221
  });
222
- // alert(products);
223
-
224
  event.preventDefault();
225
  });
226
  });
@@ -385,7 +388,7 @@ jQuery(document).ready(function(){
385
  axis: 'y',
386
  containment: 'table#wpsc_checkout_list',
387
  placeholder: 'checkout-placeholder',
388
- handle: '.drag',
389
 
390
  });
391
  jQuery(this).bind('sortupdate', function(event, ui) {
@@ -891,7 +894,6 @@ function hideOptionElement(id, option) {
891
  prevOption = option;
892
  }
893
 
894
-
895
  function hideelement(id) {
896
  state = document.getElementById(id).style.display;
897
  //alert(document.getElementById(id).style.display);
@@ -960,25 +962,20 @@ function showaddform() {
960
  return false;
961
  }
962
  //used to add new form fields in the checkout setting page
963
- function add_form_field() {
964
- time = new Date();
965
- new_element_number = time.getTime();
966
- new_element_id = "form_id_"+new_element_number;
967
-
968
- new_element_contents = "";
969
- //new_element_contents += "<tr class='checkout_form_field' >\n\r";
970
  new_element_contents += "<td class='drag'></td>";
971
  new_element_contents += "<td class='namecol'><input type='text' name='new_form_name["+new_element_number+"]' value='' /></td>\n\r";
972
  new_element_contents += "<td class='typecol'><select class='wpsc_checkout_selectboxes' name='new_form_type["+new_element_number+"]'>"+HTML_FORM_FIELD_TYPES+"</select></td>\n\r";
973
  new_element_contents += "<td class='typecol'><select name='new_form_unique_name["+new_element_number+"]'>"+HTML_FORM_FIELD_UNIQUE_NAMES+"</select></td>\n\r";
974
  new_element_contents += "<td class='mandatorycol' style='text-align: center;'><input type='checkbox' name='new_form_mandatory["+new_element_number+"]' value='1' /></td>\n\r";
975
  new_element_contents += "<td><a class='image_link' href='#' onclick='return remove_new_form_field(\""+new_element_id+"\");'><img src='" + WPSC_CORE_IMAGES_URL + "/trash.gif' alt='"+TXT_WPSC_DELETE+"' title='"+TXT_WPSC_DELETE+"' /></a></td>\n\r";
976
- // new_element_contents += "</tr>";
977
-
978
- var new_element = jQuery('<tr id="'+new_element_id+'" />');
979
- jQuery(new_element).html(new_element_contents);
980
- jQuery("tbody#wpsc_checkout_list_body").append(new_element);
981
- jQuery(new_element).addClass('checkout_form_field');
982
  return false;
983
  }
984
 
@@ -1044,18 +1041,6 @@ function hideelement1(id, item_value) {
1044
  }
1045
  }
1046
 
1047
- function toggle_display_options(state) {
1048
- switch(state) {
1049
- case 'grid':
1050
- document.getElementById('grid_view_options').style.display = 'block';
1051
- break;
1052
-
1053
- default:
1054
- document.getElementById('grid_view_options').style.display = 'none';
1055
- break;
1056
- }
1057
- }
1058
-
1059
  function show_status_box(id,image_id) {
1060
  state = document.getElementById(id).style.display;
1061
  if(state != 'block') {
145
  jQuery('#checkout_'+id).after(returned_data);
146
  }else{
147
  output = "<tr class='wpsc_grey'><td></td><td colspan='5'>Please Save your changes before trying to Order your Checkout Forms again.</td></tr>\r\n<tr class='wpsc_grey'><td></td><th>Label</th><th >Value</th><td colspan='3'><a href='' class='wpsc_add_new_checkout_option' title='form_options["+id+"]'>+ New Option</a></td></tr>";
148
+ output += "<tr class='wpsc_grey'><td></td><td><input type='text' value='' name='wpsc_checkout_option_label["+id+"][]' /></td><td colspan='4'><input type='text' value='' name='wpsc_checkout_option_value["+id+"][]' /><a class='wpsc_delete_option' href='' ><img src='" + WPSC_CORE_IMAGES_URL + "/trash.gif' alt='Delete' title='delete' /></a></td></tr>";
149
  jQuery('#checkout_'+id).after(output);
150
 
151
  }
216
  var product_id = jQuery(this).parent("form.product_upload").find('input#hidden_id').val();
217
  post_values = products + '&product_id=' + product_id;
218
  jQuery.post('admin.php?wpsc_admin_action=product_files_upload',post_values, function(returned_data){
219
+ tb_remove();
220
+ if (returned_data.length > 0) {
221
+ jQuery('#wpsc_product_download_forms .select_product_file').append(returned_data).
222
+ find('p.no-item').hide().end().
223
+ find('p:even').removeClass('alt').end().
224
+ find('p:odd').addClass('alt');
225
+ }
226
  });
 
 
227
  event.preventDefault();
228
  });
229
  });
388
  axis: 'y',
389
  containment: 'table#wpsc_checkout_list',
390
  placeholder: 'checkout-placeholder',
391
+ handle: '.drag'
392
 
393
  });
394
  jQuery(this).bind('sortupdate', function(event, ui) {
894
  prevOption = option;
895
  }
896
 
 
897
  function hideelement(id) {
898
  state = document.getElementById(id).style.display;
899
  //alert(document.getElementById(id).style.display);
962
  return false;
963
  }
964
  //used to add new form fields in the checkout setting page
965
+ function add_form_field(e) {
966
+ var time = new Date(),
967
+ new_element_number = time.getTime(),
968
+ new_element_id = "form_id_"+new_element_number,
969
+ new_element_contents = '<tr class="checkout_form_field" id="'+new_element_id+'">';
970
+
 
971
  new_element_contents += "<td class='drag'></td>";
972
  new_element_contents += "<td class='namecol'><input type='text' name='new_form_name["+new_element_number+"]' value='' /></td>\n\r";
973
  new_element_contents += "<td class='typecol'><select class='wpsc_checkout_selectboxes' name='new_form_type["+new_element_number+"]'>"+HTML_FORM_FIELD_TYPES+"</select></td>\n\r";
974
  new_element_contents += "<td class='typecol'><select name='new_form_unique_name["+new_element_number+"]'>"+HTML_FORM_FIELD_UNIQUE_NAMES+"</select></td>\n\r";
975
  new_element_contents += "<td class='mandatorycol' style='text-align: center;'><input type='checkbox' name='new_form_mandatory["+new_element_number+"]' value='1' /></td>\n\r";
976
  new_element_contents += "<td><a class='image_link' href='#' onclick='return remove_new_form_field(\""+new_element_id+"\");'><img src='" + WPSC_CORE_IMAGES_URL + "/trash.gif' alt='"+TXT_WPSC_DELETE+"' title='"+TXT_WPSC_DELETE+"' /></a></td>\n\r";
977
+ new_element_contents += '</tr>';
978
+ jQuery("#wpsc_checkout_list_body").append(new_element_contents);
 
 
 
 
979
  return false;
980
  }
981
 
1041
  }
1042
  }
1043
 
 
 
 
 
 
 
 
 
 
 
 
 
1044
  function show_status_box(id,image_id) {
1045
  state = document.getElementById(id).style.display;
1046
  if(state != 'block') {
wpsc-core/js/wp-e-commerce.js CHANGED
@@ -202,6 +202,8 @@ jQuery(document).ready(function () {
202
  jQuery('#wpsc_checkout_gravatar').attr('src', 'https://secure.gravatar.com/avatar/'+MD5(jQuery(this).val().split(' ').join(''))+'?s=60&d=mm');
203
  });
204
 
 
 
205
  //this bit of code runs on the checkout page. If the checkbox is selected it copies the valus in the billing country and puts it in the shipping country form fields. 23.07.09
206
  if(jQuery("#shippingSameBilling").is(":checked"))
207
  wpsc_shipping_same_as_billing();
@@ -285,7 +287,7 @@ jQuery(document).ready(function () {
285
  });
286
 
287
  // update the price when the variations are altered.
288
- jQuery(".wpsc_select_variation").change(function() {
289
  jQuery('option[value="0"]', this).attr('disabled', 'disabled');
290
  parent_form = jQuery(this).parents("form.product_form");
291
  form_values =jQuery("input[name=product_id], .wpsc_select_variation",parent_form).serialize( );
@@ -308,6 +310,7 @@ jQuery(document).ready(function () {
308
  }
309
  if( typeof(price) !== 'undefined' && typeof(old_price) !== 'undefined' && typeof(you_save) !== 'undefined' && typeof(numeric_price) !== 'undefined' ) {
310
  target_id = "product_price_"+product_id;
 
311
  second_target_id = "donation_price_"+product_id;
312
  third_target_id = "old_product_price_"+product_id;
313
  yousave_target_id = "yousave_"+product_id;
@@ -315,7 +318,7 @@ jQuery(document).ready(function () {
315
  if(jQuery("input#"+target_id).attr('type') == 'text') {
316
  jQuery("input#"+target_id).val(numeric_price);
317
  } else {
318
- jQuery("#"+target_id+".pricedisplay").html(price);
319
  jQuery("#"+third_target_id).html(old_price);
320
  jQuery("#"+yousave_target_id).html(you_save);
321
  }
@@ -409,22 +412,11 @@ function wpsc_fancy_notification(parent_form){
409
  };
410
 
411
  form_button_id = jQuery(parent_form).attr('id') + "_submit_button";
412
- var container_offset = {};
413
- new_container_offset = jQuery('#default_products_page_container, #products_page_container, #list_view_products_page_container, #grid_view_products_page_container, #single_product_page_container').offset();
414
-
415
- if(container_offset['left'] == null) {
416
- container_offset['left'] = new_container_offset.left;
417
- container_offset['top'] = new_container_offset.top;
418
- }
419
-
420
- var button_offset = {};
421
- new_button_offset = jQuery('#'+form_button_id).offset()
422
 
423
- button_offset['left'] = new_button_offset.left;
424
- button_offset['top'] = new_button_offset.top;
425
 
426
- jQuery('#fancy_notification').css("left", (button_offset['left'] - container_offset['left'] - 140) + 'px');
427
- jQuery('#fancy_notification').css("top", ((button_offset['top'] - container_offset['top']) + 40) + 'px');
428
 
429
 
430
  jQuery('#fancy_notification').css("display", 'block');
202
  jQuery('#wpsc_checkout_gravatar').attr('src', 'https://secure.gravatar.com/avatar/'+MD5(jQuery(this).val().split(' ').join(''))+'?s=60&d=mm');
203
  });
204
 
205
+ jQuery('#fancy_notification').appendTo('body');
206
+
207
  //this bit of code runs on the checkout page. If the checkbox is selected it copies the valus in the billing country and puts it in the shipping country form fields. 23.07.09
208
  if(jQuery("#shippingSameBilling").is(":checked"))
209
  wpsc_shipping_same_as_billing();
287
  });
288
 
289
  // update the price when the variations are altered.
290
+ jQuery(".wpsc_select_variation").live('change', function() {
291
  jQuery('option[value="0"]', this).attr('disabled', 'disabled');
292
  parent_form = jQuery(this).parents("form.product_form");
293
  form_values =jQuery("input[name=product_id], .wpsc_select_variation",parent_form).serialize( );
310
  }
311
  if( typeof(price) !== 'undefined' && typeof(old_price) !== 'undefined' && typeof(you_save) !== 'undefined' && typeof(numeric_price) !== 'undefined' ) {
312
  target_id = "product_price_"+product_id;
313
+ price_target_selector = "#" + target_id + ".pricedisplay, ." + product_id + " .currentprice";
314
  second_target_id = "donation_price_"+product_id;
315
  third_target_id = "old_product_price_"+product_id;
316
  yousave_target_id = "yousave_"+product_id;
318
  if(jQuery("input#"+target_id).attr('type') == 'text') {
319
  jQuery("input#"+target_id).val(numeric_price);
320
  } else {
321
+ jQuery(price_target_selector).html(price);
322
  jQuery("#"+third_target_id).html(old_price);
323
  jQuery("#"+yousave_target_id).html(you_save);
324
  }
412
  };
413
 
414
  form_button_id = jQuery(parent_form).attr('id') + "_submit_button";
 
 
 
 
 
 
 
 
 
 
415
 
416
+ var button_offset = jQuery('#'+form_button_id).offset()
 
417
 
418
+ jQuery('#fancy_notification').css("left", (button_offset.left - 130) + 'px');
419
+ jQuery('#fancy_notification').css("top", (button_offset.top + 40) + 'px');
420
 
421
 
422
  jQuery('#fancy_notification').css("display", 'block');
wpsc-core/js/wpsc_colorbox.js CHANGED
@@ -1,5 +1,21 @@
1
  jQuery(document).ready(function(){
2
  jQuery('.imagecol').each(function(){
3
- jQuery('.thickbox', this).colorbox({maxWidth:'90%', maxHeight:'90%'});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  });
5
  });
1
  jQuery(document).ready(function(){
2
  jQuery('.imagecol').each(function(){
3
+ var t = jQuery(this).find('.wpcart_gallery .thickbox');
4
+ t.colorbox({
5
+ maxWidth :'90%',
6
+ maxHeight :'90%',
7
+ returnFocus : false
8
+ });
9
+
10
+ jQuery(this).children('.thickbox').click(function(e){
11
+ var that = jQuery(this);
12
+ e.preventDefault();
13
+ t.each(function(){
14
+ if (jQuery(this).attr('href') == that.attr('href')) {
15
+ jQuery(this).click();
16
+ return;
17
+ }
18
+ });
19
+ });
20
  });
21
  });
wpsc-core/wpsc-constants.php CHANGED
@@ -26,9 +26,9 @@ function wpsc_core_constants() {
26
  if(!defined('WPSC_URL'))
27
  define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
28
  // Define Plugin version
29
- define( 'WPSC_VERSION', '3.8.1' );
30
- define( 'WPSC_MINOR_VERSION', '372308' );
31
- define( 'WPSC_PRESENTABLE_VERSION', '3.8.1' );
32
 
33
  // Define Debug Variables for developers
34
  define( 'WPSC_DEBUG', false );
@@ -270,11 +270,7 @@ function wpsc_core_setup_cart() {
270
 
271
  // Cart exists in Session, so attempt to unserialize it
272
  if ( isset( $_SESSION['wpsc_cart'] ) ) {
273
- if ( is_object( $_SESSION['wpsc_cart'] ) )
274
- $wpsc_cart = $_SESSION['wpsc_cart'];
275
- else
276
- $wpsc_cart = unserialize( $_SESSION['wpsc_cart'] );
277
-
278
  if ( !is_object( $wpsc_cart ) || ( 'wpsc_cart' != get_class( $wpsc_cart ) ) )
279
  $wpsc_cart = new wpsc_cart;
280
 
@@ -293,7 +289,7 @@ function wpsc_core_setup_cart() {
293
  * Starting it in wp_query results in intractable infinite loops in 3.0
294
  */
295
  function wpsc_core_setup_globals() {
296
- global $wpsc_query_vars, $wpsc_cart;
297
 
298
  // Setup some globals
299
  $wpsc_query_vars = array();
@@ -307,6 +303,7 @@ function wpsc_core_setup_globals() {
307
 
308
  // Include a file named after the current theme, if one exists
309
  if ( !empty( $selected_theme ) && file_exists( WPSC_THEMES_PATH . $selected_theme . '/' . $selected_theme . '.php' ) )
310
- include_once( WPSC_THEMES_PATH . $selected_theme . '/' . $selected_theme . '.php' );
311
-
 
312
  }
26
  if(!defined('WPSC_URL'))
27
  define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
28
  // Define Plugin version
29
+ define( 'WPSC_VERSION', '3.8.2' );
30
+ define( 'WPSC_MINOR_VERSION', '377719' );
31
+ define( 'WPSC_PRESENTABLE_VERSION', '3.8.2' );
32
 
33
  // Define Debug Variables for developers
34
  define( 'WPSC_DEBUG', false );
270
 
271
  // Cart exists in Session, so attempt to unserialize it
272
  if ( isset( $_SESSION['wpsc_cart'] ) ) {
273
+ $wpsc_cart = maybe_unserialize( $_SESSION['wpsc_cart'] );
 
 
 
 
274
  if ( !is_object( $wpsc_cart ) || ( 'wpsc_cart' != get_class( $wpsc_cart ) ) )
275
  $wpsc_cart = new wpsc_cart;
276
 
289
  * Starting it in wp_query results in intractable infinite loops in 3.0
290
  */
291
  function wpsc_core_setup_globals() {
292
+ global $wpsc_query_vars, $wpsc_cart, $wpec_ash;
293
 
294
  // Setup some globals
295
  $wpsc_query_vars = array();
303
 
304
  // Include a file named after the current theme, if one exists
305
  if ( !empty( $selected_theme ) && file_exists( WPSC_THEMES_PATH . $selected_theme . '/' . $selected_theme . '.php' ) )
306
+ include_once( WPSC_THEMES_PATH . $selected_theme . '/' . $selected_theme . '.php' );
307
+ require_once( WPSC_FILE_PATH . '/wpsc-includes/shipping.helper.php');
308
+ $wpec_ash = new ASH();
309
  }
wpsc-core/wpsc-deprecated.php CHANGED
@@ -469,7 +469,7 @@ function wpsc_total_product_count() {
469
  */
470
  class WPSC_Query extends WP_Query
471
  {
472
- function WPSC_Query( $query ) {
473
  $query = wp_parse_args( $query );
474
  $query['post_type'] = 'wpsc-product';
475
  _deprecated_function( __FUNCTION__, '3.8', 'WP_Query class' );
469
  */
470
  class WPSC_Query extends WP_Query
471
  {
472
+ function WPSC_Query( $query = '' ) {
473
  $query = wp_parse_args( $query );
474
  $query['post_type'] = 'wpsc-product';
475
  _deprecated_function( __FUNCTION__, '3.8', 'WP_Query class' );
wpsc-core/wpsc-functions.php CHANGED
@@ -405,7 +405,9 @@ function wpsc_start_the_query() {
405
  $is_404 = false;
406
  if(isset($wp_query->query_vars['term']) && in_array($wp_query->query_vars['term'], $wpsc_page_titles)){
407
  $wp_query = new WP_Query( 'pagename='.$wpsc_page_titles['products'].'/'.$wp_query->query_vars['term'] );
408
-
 
 
409
  }elseif ( null == $wpsc_query ) {
410
  if( ( $wp_query->is_404 && !empty($wp_query->query_vars['paged']) ) || (isset( $wp_query->query['pagename']) && strpos( $wp_query->query['pagename'] , $wpsc_page_titles['products'] ) !== false ) && !isset($wp_query->post)){
411
  //what was this for?
@@ -765,8 +767,12 @@ function wpsc_generate_product_query( $query ) {
765
  }
766
  if(1 == get_option('use_pagination')){
767
  $query->query_vars['posts_per_page'] = get_option('wpsc_products_per_page');
768
- if( isset( $_GET['items_per_page'] ) )
769
- $query->query_vars['posts_per_page'] = (int)$_GET['items_per_page'];
 
 
 
 
770
  } else {
771
  $query->query_vars['posts_per_page'] = '-1';
772
  }
@@ -971,7 +977,7 @@ function wpsc_product_link( $permalink, $post, $leavename ) {
971
  $term_url = '';
972
  $rewritecode = array(
973
  '%wpsc_product_category%',
974
- '%postname%'
975
  );
976
  if ( is_object( $post ) ) {
977
  // In wordpress 2.9 we got a post object
405
  $is_404 = false;
406
  if(isset($wp_query->query_vars['term']) && in_array($wp_query->query_vars['term'], $wpsc_page_titles)){
407
  $wp_query = new WP_Query( 'pagename='.$wpsc_page_titles['products'].'/'.$wp_query->query_vars['term'] );
408
+ global $post;
409
+ $post = $wp_query->post;
410
+ setup_postdata( $post );
411
  }elseif ( null == $wpsc_query ) {
412
  if( ( $wp_query->is_404 && !empty($wp_query->query_vars['paged']) ) || (isset( $wp_query->query['pagename']) && strpos( $wp_query->query['pagename'] , $wpsc_page_titles['products'] ) !== false ) && !isset($wp_query->post)){
413
  //what was this for?
767
  }
768
  if(1 == get_option('use_pagination')){
769
  $query->query_vars['posts_per_page'] = get_option('wpsc_products_per_page');
770
+ if( isset( $_GET['items_per_page'] ) ) {
771
+ if ( is_numeric( $_GET['items_per_page'] ) )
772
+ $query->query_vars['posts_per_page'] = (int) $_GET['items_per_page'];
773
+ elseif ( $_GET['items_per_page'] == 'all' )
774
+ $query->query_vars['posts_per_page'] = -1;
775
+ }
776
  } else {
777
  $query->query_vars['posts_per_page'] = '-1';
778
  }
977
  $term_url = '';
978
  $rewritecode = array(
979
  '%wpsc_product_category%',
980
+ $leavename ? '' : '%postname%',
981
  );
982
  if ( is_object( $post ) ) {
983
  // In wordpress 2.9 we got a post object
wpsc-core/wpsc-installer.php CHANGED
@@ -15,17 +15,18 @@ function wpsc_auto_update() {
15
 
16
  if ( $wpsc_version === false )
17
  add_option( 'wpsc_version', WPSC_VERSION, '', 'yes' );
 
 
18
 
19
  if ( $wpsc_minor_version === false )
20
  add_option( 'wpsc_minor_version', WPSC_MINOR_VERSION, '', 'yes' );
 
 
21
 
22
- if ( version_compare( $wpsc_version, WPSC_VERSION, '<' ) || version_compare( $wpsc_minor_vesion, WPSC_MINOR_VERSION, '<' ) ) {
23
- if ( version_compare( WPSC_VERSION, '3.8', '=' ) )
24
- add_option( 'wpsc_needs_update', true, '', 'no' );
25
  update_option( 'wpsc_needs_update', true );
26
- update_option( 'wpsc_version', WPSC_VERSION );
27
- update_option( 'wpsc_minor_version', WPSC_MINOR_VERSION );
28
- }
29
  }
30
 
31
  function wpsc_install() {
@@ -58,22 +59,23 @@ function wpsc_install() {
58
  wp_schedule_event( time(), 'daily', 'wpsc_daily_cron_tasks' );
59
 
60
  // All code to add new database tables and columns must be above here
61
- $wpsc_version = get_option( 'wpsc_version' );
62
- $wpsc_minor_version = get_option( 'wspc_minor_version' );
63
 
64
  if ( $wpsc_version === false )
65
  add_option( 'wpsc_version', WPSC_VERSION, '', 'yes' );
 
 
66
 
67
  if ( $wpsc_minor_version === false )
68
  add_option( 'wpsc_minor_version', WPSC_MINOR_VERSION, '', 'yes' );
69
-
70
- if ( version_compare( $wpsc_version, WPSC_VERSION, '<' ) || version_compare( $wpsc_minor_vesion, WPSC_MINOR_VERSION, '<' ) ) {
71
- if ( version_compare( WPSC_VERSION, '3.8', '=' ) )
72
- add_option( 'wpsc_needs_update', true, '', 'no' );
73
- update_option( 'wpsc_needs_update', true );
74
- update_option( 'wpsc_version', WPSC_VERSION );
75
  update_option( 'wpsc_minor_version', WPSC_MINOR_VERSION );
76
- }
 
 
 
 
77
 
78
  if('' == get_option('show_subcatsprods_in_cat'))
79
  update_option('show_subcatsprods_in_cat',0);
15
 
16
  if ( $wpsc_version === false )
17
  add_option( 'wpsc_version', WPSC_VERSION, '', 'yes' );
18
+ else
19
+ update_option( 'wpsc_version', WPSC_VERSION );
20
 
21
  if ( $wpsc_minor_version === false )
22
  add_option( 'wpsc_minor_version', WPSC_MINOR_VERSION, '', 'yes' );
23
+ else
24
+ update_option( 'wpsc_minor_version', WPSC_MINOR_VERSION );
25
 
26
+ if ( version_compare( $wpsc_version, '3.8', '<' ) )
 
 
27
  update_option( 'wpsc_needs_update', true );
28
+ else
29
+ update_option( 'wpsc_needs_update', false );
 
30
  }
31
 
32
  function wpsc_install() {
59
  wp_schedule_event( time(), 'daily', 'wpsc_daily_cron_tasks' );
60
 
61
  // All code to add new database tables and columns must be above here
62
+ $wpsc_version = get_option( 'wpsc_version', 0 );
63
+ $wpsc_minor_version = get_option( 'wspc_minor_version', 0 );
64
 
65
  if ( $wpsc_version === false )
66
  add_option( 'wpsc_version', WPSC_VERSION, '', 'yes' );
67
+ else
68
+ update_option( 'wpsc_version', WPSC_VERSION );
69
 
70
  if ( $wpsc_minor_version === false )
71
  add_option( 'wpsc_minor_version', WPSC_MINOR_VERSION, '', 'yes' );
72
+ else
 
 
 
 
 
73
  update_option( 'wpsc_minor_version', WPSC_MINOR_VERSION );
74
+
75
+ if ( version_compare( $wpsc_version, '3.8', '<' ) )
76
+ update_option( 'wpsc_needs_update', true );
77
+ else
78
+ update_option( 'wpsc_needs_update', false );
79
 
80
  if('' == get_option('show_subcatsprods_in_cat'))
81
  update_option('show_subcatsprods_in_cat',0);
wpsc-includes/ajax.functions.php CHANGED
@@ -40,7 +40,7 @@ function wpsc_add_to_cart() {
40
  $product_id = (int)$_POST['product_id'];
41
 
42
  // compatibility with older themes
43
- if ( is_array( $_POST['wpsc_quantity_update'] ) ) {
44
  $_POST['wpsc_quantity_update'] = $_POST['wpsc_quantity_update'][$product_id];
45
  }
46
 
@@ -413,7 +413,6 @@ function wpsc_update_product_price() {
413
  }
414
 
415
  do_action( 'wpsc_update_variation_product', (int)$_POST['product_id'], $variations );
416
- $pm = $_POST['pm'];
417
 
418
  $stock = wpsc_check_variation_stock_availability( (int)$_POST['product_id'], $variations );
419
  if ( is_numeric( $stock ) && $stock == 0 ) {
@@ -452,7 +451,7 @@ function wpsc_update_location() {
452
  if ( $_SESSION['wpsc_selected_country'] == null ) {
453
  $_SESSION['wpsc_selected_country'] = $_POST['country'];
454
  }
455
- if ( $_POST['region'] != null ) {
456
  $_SESSION['wpsc_delivery_region'] = $_POST['region'];
457
  if ( $_SESSION['wpsc_selected_region'] == null ) {
458
  $_SESSION['wpsc_selected_region'] = $_POST['region'];
@@ -467,7 +466,7 @@ function wpsc_update_location() {
467
  }
468
  }
469
 
470
- if ( $_POST['zipcode'] != '' ) {
471
  $_SESSION['wpsc_zipcode'] = $_POST['zipcode'];
472
  }
473
 
40
  $product_id = (int)$_POST['product_id'];
41
 
42
  // compatibility with older themes
43
+ if ( isset( $_POST['wpsc_quantity_update'] ) && is_array( $_POST['wpsc_quantity_update'] ) ) {
44
  $_POST['wpsc_quantity_update'] = $_POST['wpsc_quantity_update'][$product_id];
45
  }
46
 
413
  }
414
 
415
  do_action( 'wpsc_update_variation_product', (int)$_POST['product_id'], $variations );
 
416
 
417
  $stock = wpsc_check_variation_stock_availability( (int)$_POST['product_id'], $variations );
418
  if ( is_numeric( $stock ) && $stock == 0 ) {
451
  if ( $_SESSION['wpsc_selected_country'] == null ) {
452
  $_SESSION['wpsc_selected_country'] = $_POST['country'];
453
  }
454
+ if ( ! empty( $_POST['region'] ) ) {
455
  $_SESSION['wpsc_delivery_region'] = $_POST['region'];
456
  if ( $_SESSION['wpsc_selected_region'] == null ) {
457
  $_SESSION['wpsc_selected_region'] = $_POST['region'];
466
  }
467
  }
468
 
469
+ if ( ! empty( $_POST['zipcode'] ) ) {
470
  $_SESSION['wpsc_zipcode'] = $_POST['zipcode'];
471
  }
472
 
wpsc-includes/cart.class.php CHANGED
@@ -347,7 +347,8 @@ function wpsc_cart_item_image( $width = 31, $height = 31 ) {
347
 
348
  $cart_image = wpsc_the_product_thumbnail( $width, $height, $wpsc_cart->cart_item->product_id, "shopping_cart");
349
 
350
- if( is_ssl() && !strstr( $cart_image, 'https' ) ) str_replace( 'http', 'https', $cart_image );
 
351
 
352
  return $cart_image;
353
  }
@@ -1385,17 +1386,20 @@ class wpsc_cart {
1385
  if($this->shipping_method == null){
1386
  $this->get_shipping_method();
1387
  }
1388
- if(is_callable(array($wpsc_shipping_modules[$this->shipping_method], "getQuote" ))) {
1389
  $unprocessed_shipping_quotes = $wpsc_shipping_modules[$this->shipping_method]->getQuote();
1390
 
1391
  }
1392
  $num = 0;
1393
- foreach((array)$unprocessed_shipping_quotes as $shipping_key => $shipping_value) {
1394
- $per_item_shipping = $this->calculate_per_item_shipping($this->shipping_method);
1395
- $this->shipping_quotes[$num]['name'] = $shipping_key;
1396
- $this->shipping_quotes[$num]['value'] = (float)$shipping_value+(float)$per_item_shipping;
1397
- $num++;
1398
- }
 
 
 
1399
  $this->shipping_quote_count = count($this->shipping_quotes);
1400
  }
1401
 
@@ -1600,17 +1604,20 @@ class wpsc_cart_item {
1600
 
1601
  $this->weight = $product_meta[0]["weight"];
1602
  // if we are using table rate price
1603
- $levels = $product_meta[0]['table_rate_price'];
1604
- if (isset($levels["quantity"]) && $levels["quantity"] != '') {
1605
- foreach((array)$levels['quantity'] as $key => $qty) {
1606
- if ($this->quantity >= $qty) {
1607
- $unit_price = $levels['table_price'][$key];
1608
- if ($unit_price != '')
1609
- $price = $unit_price;
1610
-
1611
- }
1612
- }
1613
- }
 
 
 
1614
  $price = apply_filters('wpsc_price', $price, $product_id);
1615
  // create the string containing the product name.
1616
  $product_name = $product->post_title;
347
 
348
  $cart_image = wpsc_the_product_thumbnail( $width, $height, $wpsc_cart->cart_item->product_id, "shopping_cart");
349
 
350
+ if( is_ssl() )
351
+ $cart_image = str_replace( 'http://', 'https://', $cart_image );
352
 
353
  return $cart_image;
354
  }
1386
  if($this->shipping_method == null){
1387
  $this->get_shipping_method();
1388
  }
1389
+ if( isset( $wpsc_shipping_modules[$this->shipping_method] ) && is_callable( array( $wpsc_shipping_modules[$this->shipping_method], "getQuote" ) ) ) {
1390
  $unprocessed_shipping_quotes = $wpsc_shipping_modules[$this->shipping_method]->getQuote();
1391
 
1392
  }
1393
  $num = 0;
1394
+ if ( ! empty( $unprocessed_shipping_quotes ) ) {
1395
+ foreach((array)$unprocessed_shipping_quotes as $shipping_key => $shipping_value) {
1396
+ $per_item_shipping = $this->calculate_per_item_shipping($this->shipping_method);
1397
+ $this->shipping_quotes[$num]['name'] = $shipping_key;
1398
+ $this->shipping_quotes[$num]['value'] = (float)$shipping_value+(float)$per_item_shipping;
1399
+ $num++;
1400
+ }
1401
+ }
1402
+
1403
  $this->shipping_quote_count = count($this->shipping_quotes);
1404
  }
1405
 
1604
 
1605
  $this->weight = $product_meta[0]["weight"];
1606
  // if we are using table rate price
1607
+ if ( isset( $product_meta[0]['table_rate_price'] ) ) {
1608
+ $levels = $product_meta[0]['table_rate_price'];
1609
+ if ( ! empty( $levels['quantity'] ) ) {
1610
+ foreach((array)$levels['quantity'] as $key => $qty) {
1611
+ if ($this->quantity >= $qty) {
1612
+ $unit_price = $levels['table_price'][$key];
1613
+ if ($unit_price != '')
1614
+ $price = $unit_price;
1615
+
1616
+ }
1617
+ }
1618
+ }
1619
+ }
1620
+
1621
  $price = apply_filters('wpsc_price', $price, $product_id);
1622
  // create the string containing the product name.
1623
  $product_name = $product->post_title;
wpsc-includes/category.functions.php CHANGED
@@ -237,14 +237,14 @@ function wpsc_end_category_query() {
237
  */
238
  function wpsc_display_category_loop($query, $category_html, &$category_branch = null){
239
  static $category_count_data = array(); // the array tree is stored in this
240
-
241
  if( isset($query['parent_category_id']) )
242
  $category_id = absint($query['parent_category_id']);
243
  else
244
  $category_id = 0;
245
  $category_data = get_terms('wpsc_product_category','hide_empty=0&parent='.$category_id, OBJECT, 'display');
246
  $output ='';
247
-
248
  // if the category branch is identical to null, make it a reference to $category_count_data
249
  if($category_branch === null) {
250
  $category_branch =& $category_count_data;
@@ -336,7 +336,7 @@ function wpsc_display_category_loop($query, $category_html, &$category_branch =
336
 
337
  }
338
 
339
-
340
  // get the list of products associated with this category.
341
  $tags_to_replace = array('[wpsc_category_name]',
342
  '[wpsc_category_description]',
@@ -346,9 +346,9 @@ function wpsc_display_category_loop($query, $category_html, &$category_branch =
346
  '[wpsc_category_image]',
347
  '[wpsc_subcategory]',
348
  '[wpsc_category_products_count]');
349
-
350
  $content_to_place = array(
351
- htmlentities($category_row->name,ENT_QUOTES, 'UTF-8'),
352
  $category_description,
353
  get_term_link($category_row->slug, 'wpsc_product_category'),
354
  $category_row->term_id,
@@ -417,12 +417,10 @@ function wpsc_is_in_category() {
417
  * @author John Beales ( johnbeales.com )
418
  */
419
  function wpsc_category_id($category_slug = '') {
420
- if(empty($category_slug)) {
421
- $query_vars = get_query_var('query_vars');
422
- $category_slug = $query_vars['wpsc_product_category'];
423
- } elseif(array_key_exists('wpsc_product_category', $_GET)) {
424
  $category_slug = $_GET['wpsc_product_category'];
425
- }
426
 
427
  if(!empty($category_slug)) {
428
  $category = get_term_by('slug', $category_slug, 'wpsc_product_category');
237
  */
238
  function wpsc_display_category_loop($query, $category_html, &$category_branch = null){
239
  static $category_count_data = array(); // the array tree is stored in this
240
+
241
  if( isset($query['parent_category_id']) )
242
  $category_id = absint($query['parent_category_id']);
243
  else
244
  $category_id = 0;
245
  $category_data = get_terms('wpsc_product_category','hide_empty=0&parent='.$category_id, OBJECT, 'display');
246
  $output ='';
247
+
248
  // if the category branch is identical to null, make it a reference to $category_count_data
249
  if($category_branch === null) {
250
  $category_branch =& $category_count_data;
336
 
337
  }
338
 
339
+
340
  // get the list of products associated with this category.
341
  $tags_to_replace = array('[wpsc_category_name]',
342
  '[wpsc_category_description]',
346
  '[wpsc_category_image]',
347
  '[wpsc_subcategory]',
348
  '[wpsc_category_products_count]');
349
+
350
  $content_to_place = array(
351
+ esc_html($category_row->name),
352
  $category_description,
353
  get_term_link($category_row->slug, 'wpsc_product_category'),
354
  $category_row->term_id,
417
  * @author John Beales ( johnbeales.com )
418
  */
419
  function wpsc_category_id($category_slug = '') {
420
+ if(empty($category_slug))
421
+ $category_slug = get_query_var( 'wpsc_product_category' );
422
+ elseif(array_key_exists('wpsc_product_category', $_GET))
 
423
  $category_slug = $_GET['wpsc_product_category'];
 
424
 
425
  if(!empty($category_slug)) {
426
  $category = get_term_by('slug', $category_slug, 'wpsc_product_category');
wpsc-includes/checkout.class.php CHANGED
@@ -630,20 +630,22 @@ class wpsc_checkout {
630
 
631
  $delivery_country_id = wpsc_get_country_form_id_by_type('delivery_country');
632
  $billing_country_id = wpsc_get_country_form_id_by_type('country');
633
-
634
  }
635
- $saved_form_data = @htmlentities( stripslashes( (string)$_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id] ), ENT_QUOTES, 'UTF-8' );
 
 
636
  $an_array = '';
637
  if ( function_exists( 'wpsc_get_ticket_checkout_set' ) ) {
638
  if ( $this->checkout_item->checkout_set == wpsc_get_ticket_checkout_set() )
639
  $an_array = '[]';
640
  }
 
641
  switch ( $this->checkout_item->type ) {
642
  case "address":
643
  case "delivery_address":
644
  case "textarea":
645
 
646
- $output = "<textarea title='" . $this->checkout_item->unique_name . "' class='text' id='" . $this->form_element_id() . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' rows='3' cols='40' >" . $saved_form_data . "</textarea>";
647
  break;
648
 
649
  case "checkbox":
@@ -651,8 +653,12 @@ class wpsc_checkout {
651
  if ( $options != '' ) {
652
  $i = mt_rand();
653
  foreach ( $options as $label => $value ) {
654
- $output .= "<input type='hidden' title='" . $this->checkout_item->unique_name . "' id='" . $this->form_element_id() . "' value='-1' name='collected_data[{$this->checkout_item->id}][" . $i . "]'/><input type='checkbox' title='" . $this->checkout_item->unique_name . "' id='" . $this->form_element_id() . "' value='" . esc_attr( $value ) . "' name='collected_data[{$this->checkout_item->id}][" . $i . "]'/> ";
655
- $output .= "<label for='" . $this->form_element_id() . "'>" . $label . "</label>";
 
 
 
 
656
  }
657
  }
658
  break;
@@ -674,10 +680,10 @@ class wpsc_checkout {
674
  $options = $this->get_checkout_options( $this->checkout_item->id );
675
  if ( $options != '' ) {
676
  $output = "<select name='collected_data[{$this->checkout_item->id}]" . $an_array . "'>";
677
- $output .= "<option value='-1'>Select an Option</option>";
678
  foreach ( (array)$options as $label => $value ) {
679
  $value = esc_attr(str_replace( ' ', '', $value ) );
680
- $output .="<option value='" . esc_attr( $value ) . "'>" . esc_html( $label ) . "</option>\n\r";
681
  }
682
  $output .="</select>";
683
  }
@@ -685,10 +691,13 @@ class wpsc_checkout {
685
  case "radio":
686
  $options = $this->get_checkout_options( $this->checkout_item->id );
687
  if ( $options != '' ) {
688
- $i = mt_rand();
689
  foreach ( (array)$options as $label => $value ) {
690
- $output .= "<input type='radio' title='" . $this->checkout_item->unique_name . "' id='" . $this->form_element_id() . "'value='" . esc_attr( $value ) . "' name='collected_data[{$this->checkout_item->id}][" . $i . "]'/> ";
691
- $output .= "<label for='" . $this->form_element_id() . "'>" . $label . "</label>";
 
 
 
 
692
  }
693
  }
694
  break;
@@ -706,7 +715,7 @@ class wpsc_checkout {
706
  $disabled = '';
707
  if(wpsc_disregard_shipping_state_fields())
708
  $disabled = 'disabled = "disabled"';
709
- $output = "<input class='shipping_region text' title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' value='" . $saved_form_data . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' ".$disabled." />";
710
  }
711
  } elseif ( $this->checkout_item->unique_name == 'billingstate' ) {
712
  if ( wpsc_uses_shipping() && wpsc_has_regions($_SESSION['wpsc_selected_country']) ) {
@@ -715,10 +724,10 @@ class wpsc_checkout {
715
  $disabled = '';
716
  if(wpsc_disregard_billing_state_fields())
717
  $disabled = 'disabled = "disabled"';
718
- $output = "<input class='billing_region text' title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' value='" . $saved_form_data . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' ".$disabled." />";
719
  }
720
  } else {
721
- $output = "<input title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' class='text' value='" . $saved_form_data . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' />";
722
  }
723
 
724
  break;
@@ -861,9 +870,7 @@ class wpsc_checkout {
861
  */
862
  function save_forms_to_db( $purchase_id ) {
863
  global $wpdb;
864
-
865
- $count = $this->get_count_checkout_fields() + 1;
866
- $i = 0;
867
  foreach ( $this->checkout_items as $form_data ) {
868
  $value = '';
869
  if( isset( $_POST['collected_data'][$form_data->id] ) )
@@ -873,24 +880,21 @@ class wpsc_checkout {
873
 
874
 
875
  if ( $form_data->type != 'heading' ) {
876
- if ( is_array( $value ) && ($form_data->unique_name == 'billingcountry' || $form_data->unique_name == 'shippingcountry') ) {
 
877
  $value = $value[0];
878
-
879
- $prepared_query = $wpdb->query( $wpdb->prepare( "INSERT INTO `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` ( `log_id` , `form_id` , `value` ) VALUES ( %d, %d, %s)", $purchase_id, $form_data->id, $value ) );
880
- } elseif ( is_array( $value ) ) {
881
-
882
- foreach ( (array)$value as $v ) {
883
- $prepared_query = $wpdb->query( $wpdb->prepare( "INSERT INTO `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` ( `log_id` , `form_id` , `value` ) VALUES ( %d, %d, %s)", $purchase_id, $form_data->id, $v ) );
884
  }
885
  } else {
886
- $prepared_query = $wpdb->query( $wpdb->prepare( "INSERT INTO `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` ( `log_id` , `form_id` , `value` ) VALUES ( %d, %d, %s)", $purchase_id, $form_data->id, $value ) );
887
  }
 
 
888
  }
889
- if ( $i > $count ) {
890
- break;
891
- }
892
-
893
- $i++;
894
  }
895
  }
896
 
@@ -901,7 +905,7 @@ class wpsc_checkout {
901
  global $wpdb;
902
  $sql = "SELECT COUNT(*) FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` !='heading' AND `active`='1'";
903
  $count = $wpdb->get_var( $sql );
904
- return $count;
905
  }
906
 
907
  /**
630
 
631
  $delivery_country_id = wpsc_get_country_form_id_by_type('delivery_country');
632
  $billing_country_id = wpsc_get_country_form_id_by_type('country');
 
633
  }
634
+
635
+ $saved_form_data = isset( $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id] ) ? $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id] : null;
636
+
637
  $an_array = '';
638
  if ( function_exists( 'wpsc_get_ticket_checkout_set' ) ) {
639
  if ( $this->checkout_item->checkout_set == wpsc_get_ticket_checkout_set() )
640
  $an_array = '[]';
641
  }
642
+ $output = '';
643
  switch ( $this->checkout_item->type ) {
644
  case "address":
645
  case "delivery_address":
646
  case "textarea":
647
 
648
+ $output .= "<textarea title='" . $this->checkout_item->unique_name . "' class='text' id='" . $this->form_element_id() . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' rows='3' cols='40' >" . esc_html( (string) $saved_form_data ) . "</textarea>";
649
  break;
650
 
651
  case "checkbox":
653
  if ( $options != '' ) {
654
  $i = mt_rand();
655
  foreach ( $options as $label => $value ) {
656
+ ?>
657
+ <label>
658
+ <input <?php checked( in_array( $value, (array) $saved_form_data ) ); ?> type="checkbox" name="collected_data[<?php echo esc_attr( $this->checkout_item->id ); ?>]<?php echo $an_array; ?>[] ?>" value="<?php echo esc_attr( $value ); ?>" />
659
+ <?php echo esc_html( $label ); ?>
660
+ </label>
661
+ <?php
662
  }
663
  }
664
  break;
680
  $options = $this->get_checkout_options( $this->checkout_item->id );
681
  if ( $options != '' ) {
682
  $output = "<select name='collected_data[{$this->checkout_item->id}]" . $an_array . "'>";
683
+ $output .= "<option value='-1'>" . __( 'Select an Option', 'wpsc' ) . "</option>";
684
  foreach ( (array)$options as $label => $value ) {
685
  $value = esc_attr(str_replace( ' ', '', $value ) );
686
+ $output .="<option " . selected( $value, $saved_form_data, false ) . " value='" . esc_attr( $value ) . "'>" . esc_html( $label ) . "</option>\n\r";
687
  }
688
  $output .="</select>";
689
  }
691
  case "radio":
692
  $options = $this->get_checkout_options( $this->checkout_item->id );
693
  if ( $options != '' ) {
 
694
  foreach ( (array)$options as $label => $value ) {
695
+ ?>
696
+ <label>
697
+ <input type="radio" <?php checked( $value, $saved_form_data ); ?> name="collected_data[<?php echo esc_attr( $this->checkout_item->id ); ?>]<?php echo $an_array; ?>" value="<?php echo esc_attr( $value ); ?>" />
698
+ <?php echo esc_html( $label ); ?>
699
+ </label>
700
+ <?php
701
  }
702
  }
703
  break;
715
  $disabled = '';
716
  if(wpsc_disregard_shipping_state_fields())
717
  $disabled = 'disabled = "disabled"';
718
+ $output = "<input class='shipping_region text' title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' value='" . esc_attr( $saved_form_data ) . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' ".$disabled." />";
719
  }
720
  } elseif ( $this->checkout_item->unique_name == 'billingstate' ) {
721
  if ( wpsc_uses_shipping() && wpsc_has_regions($_SESSION['wpsc_selected_country']) ) {
724
  $disabled = '';
725
  if(wpsc_disregard_billing_state_fields())
726
  $disabled = 'disabled = "disabled"';
727
+ $output = "<input class='billing_region text' title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' value='" . esc_attr( $saved_form_data ) . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' ".$disabled." />";
728
  }
729
  } else {
730
+ $output = "<input title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' class='text' value='" . esc_attr( $saved_form_data ) . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' />";
731
  }
732
 
733
  break;
870
  */
871
  function save_forms_to_db( $purchase_id ) {
872
  global $wpdb;
873
+
 
 
874
  foreach ( $this->checkout_items as $form_data ) {
875
  $value = '';
876
  if( isset( $_POST['collected_data'][$form_data->id] ) )
880
 
881
 
882
  if ( $form_data->type != 'heading' ) {
883
+ if ( is_array( $value ) ) {
884
+ if ( in_array( $form_data->unique_name, array( 'billingcountry', 'shippingcountry' ) ) ) {
885
  $value = $value[0];
886
+ $prepared_query = $wpdb->prepare( "INSERT INTO `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` ( `log_id` , `form_id` , `value` ) VALUES ( %d, %d, %s)", $purchase_id, $form_data->id, $value );
887
+ } else {
888
+ foreach ( (array)$value as $v ) {
889
+ $prepared_query = $wpdb->prepare( "INSERT INTO `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` ( `log_id` , `form_id` , `value` ) VALUES ( %d, %d, %s)", $purchase_id, $form_data->id, $v );
890
+ }
 
891
  }
892
  } else {
893
+ $prepared_query = $wpdb->prepare( "INSERT INTO `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` ( `log_id` , `form_id` , `value` ) VALUES ( %d, %d, %s)", $purchase_id, $form_data->id, $value );
894
  }
895
+
896
+ $wpdb->query( $prepared_query );
897
  }
 
 
 
 
 
898
  }
899
  }
900
 
905
  global $wpdb;
906
  $sql = "SELECT COUNT(*) FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` !='heading' AND `active`='1'";
907
  $count = $wpdb->get_var( $sql );
908
+ return (int) $count;
909
  }
910
 
911
  /**
wpsc-includes/coupons.class.php CHANGED
@@ -207,42 +207,42 @@ class wpsc_coupons {
207
 
208
  switch($c['logic']) {
209
  case 'equal': //Checks if the product name is exactly the same as the condition value
210
- if ($product_data->name == $c['value']) {
211
 
212
  return true;
213
  }
214
  break;
215
 
216
  case 'greater'://Checks if the product name is not the same as the condition value
217
- if ($product_data->name > $c['value'])
218
  return true;
219
  break;
220
 
221
  case 'less'://Checks if the product name is not the same as the condition value
222
- if ($product_data->name < $c['value'])
223
  return true;
224
  break;
225
 
226
  case 'contains'://Checks if the product name contains the condition value
227
- preg_match("/(.*)".$c['value']."(.*)/", $product_data->name, $match);
228
  if (!empty($match))
229
  return true;
230
  break;
231
 
232
  case 'not_contain'://Checks if the product name contains the condition value
233
- preg_match("/(.*)".$c['value']."(.*)/", $product_data->name, $match);
234
  if (empty($match))
235
  return true;
236
  break;
237
 
238
  case 'begins'://Checks if the product name begins with condition value
239
- preg_match("/^".$c['value']."/", $product_data->name, $match);
240
  if (!empty($match))
241
  return true;
242
  break;
243
 
244
  case 'ends'://Checks if the product name ends with condition value
245
- preg_match("/".$c['value']."$/", $product_data->name, $match);
246
  if (!empty($match))
247
  return true;
248
  break;
207
 
208
  switch($c['logic']) {
209
  case 'equal': //Checks if the product name is exactly the same as the condition value
210
+ if ($product_data->post_title == $c['value']) {
211
 
212
  return true;
213
  }
214
  break;
215
 
216
  case 'greater'://Checks if the product name is not the same as the condition value
217
+ if ($product_data->post_title > $c['value'])
218
  return true;
219
  break;
220
 
221
  case 'less'://Checks if the product name is not the same as the condition value
222
+ if ($product_data->post_title < $c['value'])
223
  return true;
224
  break;
225
 
226
  case 'contains'://Checks if the product name contains the condition value
227
+ preg_match("/(.*)".$c['value']."(.*)/", $product_data->post_title, $match);
228
  if (!empty($match))
229
  return true;
230
  break;
231
 
232
  case 'not_contain'://Checks if the product name contains the condition value
233
+ preg_match("/(.*)".$c['value']."(.*)/", $product_data->post_title, $match);
234
  if (empty($match))
235
  return true;
236
  break;
237
 
238
  case 'begins'://Checks if the product name begins with condition value
239
+ preg_match("/^".$c['value']."/", $product_data->post_title, $match);
240
  if (!empty($match))
241
  return true;
242
  break;
243
 
244
  case 'ends'://Checks if the product name ends with condition value
245
+ preg_match("/".$c['value']."$/", $product_data->post_title, $match);
246
  if (!empty($match))
247
  return true;
248
  break;
wpsc-includes/form-display.functions.php CHANGED
@@ -185,10 +185,9 @@ function wpsc_select_product_file( $product_id = null ) {
185
  $output .= " <label for='select_product_file_$num'>" . $file->post_title . "</label>\n";
186
  $output .= "</p>\n";
187
  }
188
-
189
- if ( !$attached_files ) {
190
- $output .= "<p>" . __( 'There are no files attached to this product. Upload a new file or select from other product files.', 'wpsc' ) . "</p>";
191
- }
192
 
193
  $output .= "</div>";
194
  $output .= "<div class='" . ((is_numeric( $product_id )) ? "edit_" : "") . "select_product_handle'><div></div></div>";
185
  $output .= " <label for='select_product_file_$num'>" . $file->post_title . "</label>\n";
186
  $output .= "</p>\n";
187
  }
188
+
189
+ $no_file_style = empty( $attached_files ) ? '' : ' style="display:none;"';
190
+ $output .= "<p class='no-item' {$no_file_style}>" . __( 'There are no files attached to this product. Upload a new file or select from other product files.', 'wpsc' ) . "</p>";
 
191
 
192
  $output .= "</div>";
193
  $output .= "<div class='" . ((is_numeric( $product_id )) ? "edit_" : "") . "select_product_handle'><div></div></div>";
wpsc-includes/merchant.class.php CHANGED
@@ -61,6 +61,28 @@ class wpsc_merchant {
61
  * collate_data method, collate purchase data, like addresses, like country
62
  * @access public
63
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  function __construct( $purchase_id = null, $is_receiving = false ) {
65
  global $wpdb;
66
  if ( ($purchase_id == null) && ($is_receiving == true) ) {
@@ -101,27 +123,6 @@ class wpsc_merchant {
101
  $currency_code = $wpdb->get_var( "SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . get_option( 'currency_type' ) . "' LIMIT 1" );
102
  $collected_form_data = $wpdb->get_results( "SELECT `data_names`.`id`, `data_names`.`unique_name`, `collected_data`.`value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` AS `collected_data` JOIN `" . WPSC_TABLE_CHECKOUT_FORMS . "` AS `data_names` ON `collected_data`.`form_id` = `data_names`.`id` WHERE `log_id` = '" . $purchase_id . "'", ARRAY_A );
103
 
104
- $address_keys = array (
105
- 'billing' => array (
106
- 'first_name' => 'billingfirstname',
107
- 'last_name' => 'billinglastname',
108
- 'address' => 'billingaddress',
109
- 'city' => 'billingcity',
110
- 'state' => 'billingstate',
111
- 'country' => 'billingcountry',
112
- 'post_code' => 'billingpostcode',
113
- ),
114
- 'shipping' => array (
115
- 'first_name' => 'shippingfirstname',
116
- 'last_name' => 'shippinglastname',
117
- 'address' => 'shippingaddress',
118
- 'city' => 'shippingcity',
119
- 'state' => 'shippingstate',
120
- 'country' => 'shippingcountry',
121
- 'post_code' => 'shippingpostcode',
122
- )
123
- );
124
-
125
  $address_data = array(
126
  'billing' => array(),
127
  'shipping' => array()
@@ -129,11 +130,11 @@ class wpsc_merchant {
129
 
130
  foreach ( $collected_form_data as $collected_form_row ) {
131
  $address_data_set = 'billing';
132
- $address_key = array_search( $collected_form_row['unique_name'], $address_keys['billing'] );
133
 
134
  if ( $address_key == null ) {
135
  $address_data_set = 'shipping';
136
- $address_key = array_search( $collected_form_row['unique_name'], $address_keys['shipping'] );
137
  }
138
 
139
  if ( $address_key == null )
@@ -321,7 +322,7 @@ class wpsc_merchant {
321
  if($append === false){
322
  return $wpdb->update(WPSC_TABLE_PURCHASE_LOGS,array('authcode'=>$authcode), array('id'=>absint($this->purchase_id)),array('%s'), array('%d'));
323
  }else{
324
- $current_authcode = $wpdb->get_var( "SELECT authcode FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `sessionid` = " . absint( $this->session_id ) . " LIMIT 1" );
325
  //this is overwrite
326
  $new_authcode = isset($current_authcode) ? $current_authcode.'|' :'';
327
  $new_authcode .= $authcode;
61
  * collate_data method, collate purchase data, like addresses, like country
62
  * @access public
63
  */
64
+
65
+ protected $address_keys = array (
66
+ 'billing' => array (
67
+ 'first_name' => 'billingfirstname',
68
+ 'last_name' => 'billinglastname',
69
+ 'address' => 'billingaddress',
70
+ 'city' => 'billingcity',
71
+ 'state' => 'billingstate',
72
+ 'country' => 'billingcountry',
73
+ 'post_code' => 'billingpostcode',
74
+ ),
75
+ 'shipping' => array (
76
+ 'first_name' => 'shippingfirstname',
77
+ 'last_name' => 'shippinglastname',
78
+ 'address' => 'shippingaddress',
79
+ 'city' => 'shippingcity',
80
+ 'state' => 'shippingstate',
81
+ 'country' => 'shippingcountry',
82
+ 'post_code' => 'shippingpostcode',
83
+ )
84
+ );
85
+
86
  function __construct( $purchase_id = null, $is_receiving = false ) {
87
  global $wpdb;
88
  if ( ($purchase_id == null) && ($is_receiving == true) ) {
123
  $currency_code = $wpdb->get_var( "SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . get_option( 'currency_type' ) . "' LIMIT 1" );
124
  $collected_form_data = $wpdb->get_results( "SELECT `data_names`.`id`, `data_names`.`unique_name`, `collected_data`.`value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` AS `collected_data` JOIN `" . WPSC_TABLE_CHECKOUT_FORMS . "` AS `data_names` ON `collected_data`.`form_id` = `data_names`.`id` WHERE `log_id` = '" . $purchase_id . "'", ARRAY_A );
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  $address_data = array(
127
  'billing' => array(),
128
  'shipping' => array()
130
 
131
  foreach ( $collected_form_data as $collected_form_row ) {
132
  $address_data_set = 'billing';
133
+ $address_key = array_search( $collected_form_row['unique_name'], $this->address_keys['billing'] );
134
 
135
  if ( $address_key == null ) {
136
  $address_data_set = 'shipping';
137
+ $address_key = array_search( $collected_form_row['unique_name'], $this->address_keys['shipping'] );
138
  }
139
 
140
  if ( $address_key == null )
322
  if($append === false){
323
  return $wpdb->update(WPSC_TABLE_PURCHASE_LOGS,array('authcode'=>$authcode), array('id'=>absint($this->purchase_id)),array('%s'), array('%d'));
324
  }else{
325
+ $current_authcode = $wpdb->get_var( "SELECT authcode FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` = " . absint( $this->session_id ) . " LIMIT 1" );
326
  //this is overwrite
327
  $new_authcode = isset($current_authcode) ? $current_authcode.'|' :'';
328
  $new_authcode .= $authcode;
wpsc-includes/processing.functions.php CHANGED
@@ -344,7 +344,7 @@ function wpsc_check_weight($state, $product) {
344
  if( array_search( 'usps', $custom_shipping ) !== false )
345
  $shipping_modules[] = 'Weight Rate';
346
 
347
- if( $product_meta['no_shipping'] != 1 && !empty( $shipping_modules ) ) {
348
  if( $product_meta['weight'] == 0 ) // otherwise, use the weight from the products list table
349
  $has_no_weight = true;
350
 
344
  if( array_search( 'usps', $custom_shipping ) !== false )
345
  $shipping_modules[] = 'Weight Rate';
346
 
347
+ if( empty( $product_meta['no_shipping'] ) && !empty( $shipping_modules ) ) {
348
  if( $product_meta['weight'] == 0 ) // otherwise, use the weight from the products list table
349
  $has_no_weight = true;
350
 
wpsc-includes/product-template.php CHANGED
@@ -306,10 +306,11 @@ function wpsc_product_image( $attachment_id = 0, $width = null, $height = null )
306
  }
307
  if(empty($image_url) && !empty($file_path)){
308
  $image_meta = get_post_meta( $attachment_id, '_wp_attached_file' );
309
- $image_url = $uploads['baseurl'].'/'.$image_meta[0];
 
310
  }
311
- if( is_ssl() && !strstr( $image_url, 'https' ) ) str_replace('http', 'https', $image_url);
312
- // @todo - put fallback 'No image' catcher here
313
  return apply_filters( 'wpsc_product_image', $image_url );
314
  }
315
 
@@ -340,30 +341,41 @@ function wpsc_show_pnp(){
340
  */
341
  function wpsc_product_variation_price_available($product_id){
342
  global $wpdb;
343
- $price = $wpdb->get_var('
344
- SELECT
345
- `pm`.`meta_value`
346
- FROM
347
- `' . $wpdb->postmeta . '` `pm`
348
- JOIN
349
- `' . $wpdb->posts . '` `p`
350
- ON
351
- `pm`.`post_id` = `p`.`id`
352
- WHERE
353
- `p`.`post_type`= "wpsc-product"
354
  AND
355
- `p`.`post_parent` = ' . $product_id . '
356
- AND
357
- `pm`.`meta_key` = "_wpsc_price"
358
- AND
359
- `p`.`ID` IN (
360
- SELECT `' . $wpdb->postmeta . '`.`post_id` FROM `' . $wpdb->postmeta . '` WHERE `meta_key` = "_wpsc_stock" AND `meta_value` != "0"
361
- )
362
- ORDER BY
363
- `meta_value` ASC
364
- LIMIT 1'
365
- );
366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  $price = wpsc_currency_display($price, array('display_as_html' => false));
368
  return $price;
369
  }
@@ -447,7 +459,7 @@ function wpsc_calculate_price( $product_id, $variations = null, $special = true
447
  function wpsc_display_categories() {
448
  global $wp_query;
449
  $output = false;
450
- if ( !is_numeric( get_option( 'wpsc_default_category' ) ) ) {
451
 
452
  if ( isset( $wp_query->query_vars['products'] ) )
453
  $category_id = $wp_query->query_vars['products'];
@@ -678,7 +690,7 @@ function wpsc_the_product_title() {
678
  */
679
  function wpsc_the_product_description() {
680
  $content = get_the_content( __( 'Read the rest of this entry &raquo;', 'wpsc' ) );
681
- return wpautop($content,1);
682
  }
683
 
684
  /**
@@ -815,13 +827,13 @@ global $wpdb;
815
 
816
  if ( wpsc_product_has_stock( $the_selected_product ) ) {
817
  $stock = get_product_meta( $the_selected_product, "stock", true );
818
- $stock = apply_filters( 'wpsc_product_variation_stock', $stock, $id );
819
  if ( 0 < $stock )
820
  return $stock;
821
  }else{
822
 
823
  $stock = get_product_meta( $the_selected_product, "stock", true );
824
- $stock = apply_filters( 'wpsc_product_variation_stock', $stock, $id );
825
 
826
  if ( is_numeric($stock) ){
827
  $claimed_stock = $wpdb->get_var("SELECT SUM(`stock_claimed`) FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `product_id` IN('$the_selected_product')");
@@ -940,10 +952,29 @@ function wpsc_product_is_donation( $id = null ) {
940
  * @return boolean - true if the product is on special, otherwise false
941
  */
942
  function wpsc_product_on_special() {
943
- global $wpsc_query;
944
-
945
  $price = get_product_meta( get_the_ID(), 'price', true );
946
- $special_price = get_product_meta( get_the_ID(), 'special_price', true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
947
  if ( ($special_price > 0) && (($price - $special_price) > 0) )
948
  return true;
949
  else
@@ -1075,14 +1106,21 @@ function wpsc_the_product_image( $width='', $height='', $product_id='' ) {
1075
  $post_thumbnail_id = get_post_thumbnail_id( $product_id );
1076
 
1077
  $src = wp_get_attachment_image_src( $post_thumbnail_id, 'large' );
1078
- if ( !empty( $src ) && is_string( $src[0] ) ) {
1079
- return $src[0];
1080
- } elseif ( !empty( $attached_images ) ) {
 
1081
  $attached_image = wp_get_attachment_image_src( $attached_images[0]->ID, 'large' );
1082
- return $attached_image[0];
1083
  } else {
1084
- return apply_filters( 'wpsc_product_image', false);
1085
  }
 
 
 
 
 
 
1086
  }
1087
 
1088
  /**
@@ -1108,11 +1146,13 @@ function wpsc_check_display_type(){
1108
  * @return string - the URL to the thumbnail image
1109
  */
1110
  function wpsc_the_product_thumbnail( $width = null, $height = null, $product_id = 0, $page = 'products-page' ) {
 
 
1111
  $display = wpsc_check_display_type();
1112
  // Get the product ID if none was passed
1113
  if ( empty( $product_id ) )
1114
  $product_id = get_the_ID();
1115
-
1116
  // Load the product
1117
  $product = get_post( $product_id );
1118
 
@@ -1127,7 +1167,7 @@ function wpsc_the_product_thumbnail( $width = null, $height = null, $product_id
1127
  }
1128
 
1129
  // Use product thumbnail
1130
- if ( has_post_thumbnail( $product_id ) && 'single' != $page) {
1131
  $thumbnail_id = get_post_thumbnail_id( $product_id );
1132
  // Use first product image
1133
  } else {
@@ -1145,7 +1185,7 @@ function wpsc_the_product_thumbnail( $width = null, $height = null, $product_id
1145
  if ( !empty( $attached_images ) )
1146
  $thumbnail_id = $attached_images[0]->ID;
1147
  }
1148
-
1149
  //Overwrite height & width if custom dimensions exist for thumbnail_id
1150
  if ( 'grid' != $display && 'products-page' == $page && isset($thumbnail_id)) {
1151
  $custom_width = get_post_meta( $thumbnail_id, '_wpsc_custom_thumb_w', true );
@@ -1159,23 +1199,33 @@ function wpsc_the_product_thumbnail( $width = null, $height = null, $product_id
1159
  }
1160
  } elseif( $page == 'single' && isset($thumbnail_id)) {
1161
  $custom_thumbnail = get_post_meta( $thumbnail_id, '_wpsc_selected_image_size', true );
1162
- if(!$custom_thumbnail)
1163
- $custom_thumbnail = array($width, $height);
1164
-
 
 
 
 
 
 
 
 
 
 
1165
  $src = wp_get_attachment_image_src( $thumbnail_id, $custom_thumbnail );
1166
 
1167
  if ( !empty( $src ) && is_string( $src[0] ) ) {
1168
- return $src[0];
1169
  }
1170
  }
1171
-
1172
- // Return image link...
1173
- if ( isset($thumbnail_id) &&( $image_link = wpsc_product_image( $thumbnail_id, $width, $height ) ))
1174
- return $image_link;
1175
 
1176
- // ... or false as if no image was found.
1177
- else
1178
- return false;
 
 
 
 
1179
  }
1180
 
1181
  /**
@@ -1411,8 +1461,9 @@ function wpsc_the_variation_out_of_stock() {
1411
  // If there is more than one variation group we cannot determine a stock status for individual variations
1412
  // Also, if the item is not stock limited, there is no need to check variation stock status
1413
  $product_id = get_the_ID();
1414
- $stock = get_product_meta( $product_id, 'stock' );
1415
- if ( ($wpsc_variations->variation_group_count == 1) && (is_numeric( $stock[0] )) ) {
 
1416
 
1417
  $product_id = get_the_ID();
1418
  $variation_group_id = $wpsc_variations->variation_group->term_id;
@@ -1767,4 +1818,4 @@ function wpsc_get_downloadable_file($file_id){
1767
  return get_post( $file_id );
1768
  }
1769
 
1770
- ?>
306
  }
307
  if(empty($image_url) && !empty($file_path)){
308
  $image_meta = get_post_meta( $attachment_id, '_wp_attached_file' );
309
+ if ( ! empty( $image_meta ) )
310
+ $image_url = $uploads['baseurl'].'/'.$image_meta[0];
311
  }
312
+ if( is_ssl() ) str_replace('http://', 'https://', $image_url);
313
+
314
  return apply_filters( 'wpsc_product_image', $image_url );
315
  }
316
 
341
  */
342
  function wpsc_product_variation_price_available($product_id){
343
  global $wpdb;
344
+
345
+ $sql = $wpdb->prepare( "
346
+ SELECT pm.meta_value
347
+ FROM {$wpdb->posts} AS p
348
+ INNER JOIN {$wpdb->postmeta} AS pm ON pm.post_id = p.id AND pm.meta_key = '_wpsc_price'
349
+ INNER JOIN {$wpdb->postmeta} AS pm2 ON pm2.post_id = p.id AND pm2.meta_key = '_wpsc_stock' AND pm2.meta_value != '0'
350
+ WHERE
351
+ p.post_type = 'wpsc-product'
 
 
 
352
  AND
353
+ p.post_parent = %d
354
+ ORDER BY CAST(pm.meta_value AS DECIMAL(10, 2)) ASC
355
+ LIMIT 1
356
+ ", $product_id );
 
 
 
 
 
 
 
357
 
358
+ $price = (float) $wpdb->get_var( $sql );
359
+
360
+ $sql = $wpdb->prepare("
361
+ SELECT pm.meta_value
362
+ FROM {$wpdb->posts} AS p
363
+ INNER JOIN {$wpdb->postmeta} AS pm ON pm.post_id = p.id AND pm.meta_key = '_wpsc_special_price' AND pm.meta_value != '0' AND pm.meta_value != ''
364
+ INNER JOIN {$wpdb->postmeta} AS pm2 ON pm2.post_id = p.id AND pm2.meta_key = '_wpsc_stock' AND pm2.meta_value != '0'
365
+ WHERE
366
+ p.post_type = 'wpsc-product'
367
+ AND
368
+ p.post_parent = %d
369
+ ORDER BY CAST(pm.meta_value AS DECIMAL(10, 2)) ASC
370
+ LIMIT 1
371
+ ", $product_id);
372
+
373
+ $special_price = (float) $wpdb->get_var( $sql );
374
+
375
+ if ( ! empty( $special_price ) && $special_price < $price ) {
376
+ $price = $special_price;
377
+ }
378
+
379
  $price = wpsc_currency_display($price, array('display_as_html' => false));
380
  return $price;
381
  }
459
  function wpsc_display_categories() {
460
  global $wp_query;
461
  $output = false;
462
+ if ( !is_numeric( get_option( 'wpsc_default_category' ) ) && ! get_query_var( 'product_tag' ) ) {
463
 
464
  if ( isset( $wp_query->query_vars['products'] ) )
465
  $category_id = $wp_query->query_vars['products'];
690
  */
691
  function wpsc_the_product_description() {
692
  $content = get_the_content( __( 'Read the rest of this entry &raquo;', 'wpsc' ) );
693
+ return do_shortcode( wpautop( $content,1 ) );
694
  }
695
 
696
  /**
827
 
828
  if ( wpsc_product_has_stock( $the_selected_product ) ) {
829
  $stock = get_product_meta( $the_selected_product, "stock", true );
830
+ $stock = apply_filters( 'wpsc_product_variation_stock', $stock, $product_id );
831
  if ( 0 < $stock )
832
  return $stock;
833
  }else{
834
 
835
  $stock = get_product_meta( $the_selected_product, "stock", true );
836
+ $stock = apply_filters( 'wpsc_product_variation_stock', $stock, $product_id );
837
 
838
  if ( is_numeric($stock) ){
839
  $claimed_stock = $wpdb->get_var("SELECT SUM(`stock_claimed`) FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `product_id` IN('$the_selected_product')");
952
  * @return boolean - true if the product is on special, otherwise false
953
  */
954
  function wpsc_product_on_special() {
955
+ global $wpsc_query, $wpdb;
956
+
957
  $price = get_product_meta( get_the_ID(), 'price', true );
958
+
959
+ // don't rely on product sales price if it has variations
960
+ if ( wpsc_have_variations() ) {
961
+ $sql = $wpdb->prepare("
962
+ SELECT MIN(pm.meta_value)
963
+ FROM {$wpdb->posts} AS p
964
+ INNER JOIN {$wpdb->postmeta} AS pm ON pm.post_id = p.id AND pm.meta_key = '_wpsc_special_price' AND pm.meta_value != '0' AND pm.meta_value != ''
965
+ INNER JOIN {$wpdb->postmeta} AS pm2 ON pm2.post_id = p.id AND pm2.meta_key = '_wpsc_stock' AND pm2.meta_value != '0'
966
+ WHERE
967
+ p.post_type = 'wpsc-product'
968
+ AND
969
+ p.post_parent = %d
970
+ ORDER BY CAST(pm.meta_value AS DECIMAL(10, 2)) ASC
971
+ LIMIT 1
972
+ ", get_the_id() );
973
+ $special_price = (int) $wpdb->get_var( $sql );
974
+ } else {
975
+ $special_price = get_product_meta( get_the_ID(), 'special_price', true );
976
+ }
977
+
978
  if ( ($special_price > 0) && (($price - $special_price) > 0) )
979
  return true;
980
  else
1106
  $post_thumbnail_id = get_post_thumbnail_id( $product_id );
1107
 
1108
  $src = wp_get_attachment_image_src( $post_thumbnail_id, 'large' );
1109
+
1110
+ if ( ! empty( $src ) && is_string( $src[0] ) ) {
1111
+ $src = $src[0];
1112
+ } elseif ( ! empty( $attached_images ) ) {
1113
  $attached_image = wp_get_attachment_image_src( $attached_images[0]->ID, 'large' );
1114
+ $src = $attached_image[0];
1115
  } else {
1116
+ $src = false;
1117
  }
1118
+
1119
+ if ( is_ssl() && ! empty( $src ) )
1120
+ $src = str_replace( 'http://', 'https://', $src );
1121
+ $src = apply_filters( 'wpsc_product_image', $src );
1122
+
1123
+ return $src;
1124
  }
1125
 
1126
  /**
1146
  * @return string - the URL to the thumbnail image
1147
  */
1148
  function wpsc_the_product_thumbnail( $width = null, $height = null, $product_id = 0, $page = 'products-page' ) {
1149
+ $thumbnail = false;
1150
+
1151
  $display = wpsc_check_display_type();
1152
  // Get the product ID if none was passed
1153
  if ( empty( $product_id ) )
1154
  $product_id = get_the_ID();
1155
+
1156
  // Load the product
1157
  $product = get_post( $product_id );
1158
 
1167
  }
1168
 
1169
  // Use product thumbnail
1170
+ if ( has_post_thumbnail( $product_id ) ) {
1171
  $thumbnail_id = get_post_thumbnail_id( $product_id );
1172
  // Use first product image
1173
  } else {
1185
  if ( !empty( $attached_images ) )
1186
  $thumbnail_id = $attached_images[0]->ID;
1187
  }
1188
+
1189
  //Overwrite height & width if custom dimensions exist for thumbnail_id
1190
  if ( 'grid' != $display && 'products-page' == $page && isset($thumbnail_id)) {
1191
  $custom_width = get_post_meta( $thumbnail_id, '_wpsc_custom_thumb_w', true );
1199
  }
1200
  } elseif( $page == 'single' && isset($thumbnail_id)) {
1201
  $custom_thumbnail = get_post_meta( $thumbnail_id, '_wpsc_selected_image_size', true );
1202
+ if ( !$custom_thumbnail ) {
1203
+ $custom_thumbnail = 'medium-single-product';
1204
+
1205
+ // regenerate size metadata in case it's missing
1206
+ if ( ! image_get_intermediate_size( $thumbnail_id, $custom_thumbnail ) ) {
1207
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
1208
+ $metadata = wp_get_attachment_metadata( $thumbnail_id );
1209
+ $file = get_attached_file( $thumbnail_id );
1210
+ $metadata = array_merge( wp_generate_attachment_metadata( $thumbnail_id, $file ), $metadata );
1211
+ wp_update_attachment_metadata( $thumbnail_id, $metadata );
1212
+ }
1213
+ }
1214
+
1215
  $src = wp_get_attachment_image_src( $thumbnail_id, $custom_thumbnail );
1216
 
1217
  if ( !empty( $src ) && is_string( $src[0] ) ) {
1218
+ $thumbnail = $src[0];
1219
  }
1220
  }
 
 
 
 
1221
 
1222
+ if ( ! $thumbnail && isset( $thumbnail_id ) )
1223
+ $thumbnail = wpsc_product_image( $thumbnail_id, $width, $height );
1224
+
1225
+ if ( ! empty( $thumbnail ) && is_ssl() )
1226
+ $thumbnail = str_replace( 'http://', 'https://', $thumbnail );
1227
+
1228
+ return $thumbnail;
1229
  }
1230
 
1231
  /**
1461
  // If there is more than one variation group we cannot determine a stock status for individual variations
1462
  // Also, if the item is not stock limited, there is no need to check variation stock status
1463
  $product_id = get_the_ID();
1464
+
1465
+ $stock = get_product_meta( $product_id, 'stock', true );
1466
+ if ( ($wpsc_variations->variation_group_count == 1) && is_numeric( $stock ) && isset( $wpsc_variations->variation->slug ) ) {
1467
 
1468
  $product_id = get_the_ID();
1469
  $variation_group_id = $wpsc_variations->variation_group->term_id;
1818
  return get_post( $file_id );
1819
  }
1820
 
1821
+ ?>
wpsc-includes/productfeed.php CHANGED
@@ -95,15 +95,7 @@ function wpsc_generate_product_feed() {
95
  $output .= " <pubDate>".$post->post_modified_gmt."</pubDate>\n\r";
96
  $output .= " <guid>$purchase_link</guid>\n\r";
97
 
98
- $image_link = FALSE;
99
-
100
- if ( has_post_thumbnail( $post->ID ) ) {
101
-
102
- $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
103
- $src = wp_get_attachment_image_src( $post_thumbnail_id, 'large' );
104
- $image_link = $src[0];
105
-
106
- }
107
 
108
  if ($image_link !== FALSE) {
109
 
@@ -116,9 +108,15 @@ function wpsc_generate_product_feed() {
116
  }
117
 
118
  $price = wpsc_calculate_price($post->ID);
 
 
 
 
 
 
 
119
  $children = get_children(array('post_parent'=> $post->ID,
120
  'post_type'=>'wpsc-product'));
121
-
122
  foreach ($children as $child) {
123
  $child_price = wpsc_calculate_price($child->ID);
124
 
@@ -133,26 +131,39 @@ function wpsc_generate_product_feed() {
133
 
134
  $output .= " <g:price>".$price."</g:price>\n\r";
135
 
136
- $product_meta = get_post_meta( $post->ID, '_wpsc_product_metadata', true );
137
- foreach (array_keys($product_meta) as $meta_key) {
138
- if (stripos($meta_key,'g:') === 0)
139
- $google_elements[$meta_key] = $product_meta[$meta_key];
 
 
 
140
  }
141
- $google_elements = apply_filters('wpsc_google_elements', array('product_id'=>$product['id'],'elements'=>$google_elements));
 
142
  $google_elements = $google_elements['elements'];
143
 
144
  $done_condition = FALSE;
145
- if (count($google_elements)) {
146
- foreach ($google_elements as $gelement) {
147
-
148
- $output .= " <".$gelement['meta_key'].">";
149
- $output .= "<![CDATA[".$gelement['meta_value']."]]>";
150
- $output .= "</".$gelement['meta_key'].">\n\r";
 
 
 
 
 
 
151
 
152
- if ($gelement['meta_key'] == 'g:condition')
153
  $done_condition = TRUE;
 
154
  }
 
155
  }
 
156
  if (!$done_condition)
157
  $output .= " <g:condition>new</g:condition>\n\r";
158
 
@@ -171,4 +182,4 @@ function wpsc_generate_product_feed() {
171
  echo $output;
172
  exit();
173
  }
174
- ?>
95
  $output .= " <pubDate>".$post->post_modified_gmt."</pubDate>\n\r";
96
  $output .= " <guid>$purchase_link</guid>\n\r";
97
 
98
+ $image_link = wpsc_the_product_thumbnail() ;
 
 
 
 
 
 
 
 
99
 
100
  if ($image_link !== FALSE) {
101
 
108
  }
109
 
110
  $price = wpsc_calculate_price($post->ID);
111
+ $args = array(
112
+ 'display_currency_symbol' => false,
113
+ 'display_decimal_point' => true,
114
+ 'display_currency_code' => false,
115
+ 'display_as_html' => false
116
+ );
117
+ $price = wpsc_currency_display($price, $args);
118
  $children = get_children(array('post_parent'=> $post->ID,
119
  'post_type'=>'wpsc-product'));
 
120
  foreach ($children as $child) {
121
  $child_price = wpsc_calculate_price($child->ID);
122
 
131
 
132
  $output .= " <g:price>".$price."</g:price>\n\r";
133
 
134
+ $google_elements = Array ();
135
+
136
+ $product_meta = get_post_custom ( $post->ID );
137
+
138
+ foreach ( $product_meta as $meta_key => $meta_value ) {
139
+ if ( stripos($meta_key,'g:') === 0 )
140
+ $google_elements[$meta_key] = $meta_value;
141
  }
142
+
143
+ $google_elements = apply_filters( 'wpsc_google_elements', array ( 'product_id' => $post->ID, 'elements' => $google_elements ) );
144
  $google_elements = $google_elements['elements'];
145
 
146
  $done_condition = FALSE;
147
+
148
+ if ( count ( $google_elements ) ) {
149
+
150
+ foreach ( $google_elements as $element_name => $element_values ) {
151
+
152
+ foreach ( $element_values as $element_value ) {
153
+
154
+ $output .= " <".$element_name.">";
155
+ $output .= "<![CDATA[".$element_value."]]>";
156
+ $output .= "</".$element_name.">\n\r";
157
+
158
+ }
159
 
160
+ if ($element_name == 'g:condition')
161
  $done_condition = TRUE;
162
+
163
  }
164
+
165
  }
166
+
167
  if (!$done_condition)
168
  $output .= " <g:condition>new</g:condition>\n\r";
169
 
182
  echo $output;
183
  exit();
184
  }
185
+ ?>
wpsc-includes/shipping.helper.php CHANGED
@@ -538,6 +538,12 @@ class ASH{
538
  * @param ASHShipment $shipment
539
  */
540
  function cache_results($internal_name, $rate_table, $shipment){
 
 
 
 
 
 
541
  $_SESSION["wpec_ash"][$internal_name]["rate_table"] = $rate_table;
542
  $shipment_vals = array("package_count"=>$shipment->package_count,
543
  "destination" =>$shipment->destination,
@@ -559,7 +565,16 @@ class ASH{
559
  if (!array_key_exists($internal_name,$_SESSION["wpec_ash"])){
560
  return FALSE;
561
  }
562
- $cached_shipment = $_SESSION["wpec_ash"][$internal_name]["shipment"];
 
 
 
 
 
 
 
 
 
563
  $shipment_vals = array("package_count"=>$shipment->package_count,
564
  "destination" =>$shipment->destination,
565
  "total_weight" =>$shipment->total_weight
@@ -582,4 +597,4 @@ $wpec_ash = new ASH();
582
  global $wpec_ash_xml;
583
  $wpec_ash_xml = new ASHXML();
584
  global $wpec_ash_tools;
585
- $wpec_ash_tools = new ASHTools();
538
  * @param ASHShipment $shipment
539
  */
540
  function cache_results($internal_name, $rate_table, $shipment){
541
+ if (!is_array($_SESSION["wpec_ash"])){
542
+ $_SESSION["wpec_ash"] = array();
543
+ }
544
+ if (!is_array($_SESSION["wpec_ash"][$internal_name])){
545
+ $_SESSION["wpec_ash"][$internal_name] = array();
546
+ }
547
  $_SESSION["wpec_ash"][$internal_name]["rate_table"] = $rate_table;
548
  $shipment_vals = array("package_count"=>$shipment->package_count,
549
  "destination" =>$shipment->destination,
565
  if (!array_key_exists($internal_name,$_SESSION["wpec_ash"])){
566
  return FALSE;
567
  }
568
+ if (is_object($_SESSION["wpec_ash"][$internal_name]["shipment"])){
569
+ $cached_shipment = $_SESSION["wpec_ash"][$internal_name]["shipment"];
570
+ }else{
571
+ if (!empty($_SESSION["wpec_ash"][$internal_name]["shipment"])){
572
+ if (is_array($_SESSION["wpec_ash"][$internal_name]["shipment"])){
573
+ $cached_shipment = $_SESSION["wpec_ash"][$internal_name]["shipment"];
574
+ }
575
+ }
576
+ }
577
+
578
  $shipment_vals = array("package_count"=>$shipment->package_count,
579
  "destination" =>$shipment->destination,
580
  "total_weight" =>$shipment->total_weight
597
  global $wpec_ash_xml;
598
  $wpec_ash_xml = new ASHXML();
599
  global $wpec_ash_tools;
600
+ $wpec_ash_tools = new ASHTools();
wpsc-includes/theme.functions.php CHANGED
@@ -364,7 +364,7 @@ function wpsc_get_the_category_id($slug, $type = 'name'){
364
  $taxonomy = 'wpsc_product_category';
365
 
366
  $category = get_term_by($type,$slug,$taxonomy);
367
- return $category->term_id;
368
  }
369
 
370
  /**
@@ -897,11 +897,7 @@ function wpsc_get_the_new_id($prod_id){
897
  */
898
  function wpsc_display_products_page( $query ) {
899
  global $wpdb, $wpsc_query,$wp_query;
900
- static $count = 0;
901
- $count++;
902
  remove_filter('the_title','wpsc_the_category_title');
903
- if ( $count > 10 )
904
- exit( 'fail' );
905
 
906
  // If the data is coming from a shortcode parse the values into the args variable,
907
  // I did it this was to preserve backwards compatibility
@@ -1058,10 +1054,8 @@ function wpsc_products_page( $content = '' ) {
1058
 
1059
  // get the display type for the productspage
1060
  $display_type = get_option('product_view');
1061
- if ( isset( $_SESSION['wpsc_display_type'] ) ) {
1062
  $display_type = $_SESSION['wpsc_display_type'];
1063
- unset($_SESSION['wpsc_display_type']);
1064
- }
1065
 
1066
  ob_start();
1067
  wpsc_include_products_page_template($display_type);
364
  $taxonomy = 'wpsc_product_category';
365
 
366
  $category = get_term_by($type,$slug,$taxonomy);
367
+ return empty( $category ) ? false : $category->term_id;
368
  }
369
 
370
  /**
897
  */
898
  function wpsc_display_products_page( $query ) {
899
  global $wpdb, $wpsc_query,$wp_query;
 
 
900
  remove_filter('the_title','wpsc_the_category_title');
 
 
901
 
902
  // If the data is coming from a shortcode parse the values into the args variable,
903
  // I did it this was to preserve backwards compatibility
1054
 
1055
  // get the display type for the productspage
1056
  $display_type = get_option('product_view');
1057
+ if ( isset( $_SESSION['wpsc_display_type'] ) )
1058
  $display_type = $_SESSION['wpsc_display_type'];
 
 
1059
 
1060
  ob_start();
1061
  wpsc_include_products_page_template($display_type);
wpsc-includes/variations.class.php CHANGED
@@ -18,7 +18,7 @@ class wpsc_variations {
18
 
19
  //variations inside variation groups: i.e. (red, green, blue) or (S, M, L, XL)
20
  var $variations;
21
- var $variations_count = 0;
22
  var $current_variation = -1;
23
  var $variation;
24
 
18
 
19
  //variations inside variation groups: i.e. (red, green, blue) or (S, M, L, XL)
20
  var $variations;
21
+ var $variation_count = 0;
22
  var $current_variation = -1;
23
  var $variation;
24
 
wpsc-merchants/paypal-standard.merchant.php CHANGED
@@ -158,7 +158,7 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
158
  $reprocessed_cart_data['subscription']['unit'] = strtoupper($cart_row['recurring_data']['rebill_interval']['unit']);
159
  $reprocessed_cart_data['subscription']['times_to_rebill'] = $cart_row['recurring_data']['times_to_rebill'];
160
  } else {
161
- $item_cost = ($cart_row['price'] + $cart_row['shipping'] + $cart_row['tax']) + $cart_row['quantity'];
162
 
163
  if ($item_cost > 0) {
164
  $reprocessed_cart_data['shopping_cart']['price'] += $item_cost;
158
  $reprocessed_cart_data['subscription']['unit'] = strtoupper($cart_row['recurring_data']['rebill_interval']['unit']);
159
  $reprocessed_cart_data['subscription']['times_to_rebill'] = $cart_row['recurring_data']['times_to_rebill'];
160
  } else {
161
+ $item_cost = ($cart_row['price'] + $cart_row['shipping'] + $cart_row['tax']) * $cart_row['quantity'];
162
 
163
  if ($item_cost > 0) {
164
  $reprocessed_cart_data['shopping_cart']['price'] += $item_cost;
wpsc-shipping/ups_20.php CHANGED
@@ -24,6 +24,10 @@ class ash_ups {
24
  return true;
25
  }
26
 
 
 
 
 
27
  function getId() {
28
  // return $this->usps_id;
29
  }
@@ -746,13 +750,16 @@ class ash_ups {
746
 
747
  function getQuote(){
748
  global $wpdb, $wpec_ash;
 
 
 
749
 
750
  // Arguments array for various functions to use
751
  $args = array();
752
  // Final rate table
753
  $rate_table = array();
754
  // Get the ups settings from the ups account info page (Shipping tab)
755
- $wpsc_ups_settings = get_option("wpsc_ups_settings");
756
  // Get the wordpress shopping cart options
757
  $wpsc_options = get_option("wpsc_options");
758
 
24
  return true;
25
  }
26
 
27
+ function __autoload($name){
28
+ include("../wpsc-includes/shipping.helper.php");
29
+ }
30
+
31
  function getId() {
32
  // return $this->usps_id;
33
  }
750
 
751
  function getQuote(){
752
  global $wpdb, $wpec_ash;
753
+ if (!is_object($wpec_ash)){
754
+ $wpec_ash = new ASH();
755
+ }
756
 
757
  // Arguments array for various functions to use
758
  $args = array();
759
  // Final rate table
760
  $rate_table = array();
761
  // Get the ups settings from the ups account info page (Shipping tab)
762
+ $wpsc_ups_settings = get_option("wpsc_ups_settings", array());
763
  // Get the wordpress shopping cart options
764
  $wpsc_options = get_option("wpsc_options");
765
 
wpsc-shipping/usps_20.php CHANGED
@@ -21,7 +21,7 @@ class ash_usps{
21
  * default "usps" Don't change unless you know what you are doing!
22
  * @var string
23
  */
24
- var $internal_name = "ash_usps";
25
  /**
26
  *
27
  * The external name that the USPS class identifies itself.
@@ -426,7 +426,7 @@ class ash_usps{
426
  * @param ASHPackage $package
427
  * @return array
428
  */
429
- function _build_intl_shipment(&$request,$data,$package){
430
  $shipment = array();
431
 
432
  $data["pounds"] = floor($package->weight);
@@ -453,9 +453,8 @@ class ash_usps{
453
  "CommercialFlag"=>"Y"
454
  );
455
 
456
- $temp = $base;
457
- $temp["@attr"]["ID"] = 0;
458
- array_push($shipment, $temp);
459
  $request[$data["req"]]["Package"] = $shipment;
460
  }
461
 
@@ -468,6 +467,9 @@ class ash_usps{
468
  */
469
  function _build_request(&$data){
470
  global $wpec_ash_xml;
 
 
 
471
  $req = "RateV4Request";
472
  if ($data["dest_country"] != "USA"){
473
  $req = "IntlRateV2Request";
@@ -531,10 +533,10 @@ class ash_usps{
531
  * @param string $package
532
  * @return string
533
  */
534
- function _get_service($ServiceTag,$package){
535
  global $wpec_ash_xml;
536
  $service = "";
537
- $temp_service = $wpec_ash_xml->get($ServiceTag,$package);
538
 
539
  if ($temp_service){
540
  $service = $temp_service[0];
@@ -557,6 +559,10 @@ class ash_usps{
557
  */
558
  function _merge_arrays(array $arrays){
559
  $final_array = array();
 
 
 
 
560
  foreach($arrays as $arr){
561
  foreach($arr as $key=>$value){
562
  if (!array_key_exists($key, $final_array)){
@@ -582,8 +588,11 @@ class ash_usps{
582
  global $wpec_ash_xml;
583
  $package_services = array();
584
  $this->_clean_response($response);
585
-
586
  $packages = $wpec_ash_xml->get("Package", $response);
 
 
 
587
 
588
  foreach($packages as $package){
589
  $temp = array();
@@ -618,8 +627,8 @@ class ash_usps{
618
  $this->_clean_response($response);
619
 
620
  $services = $wpec_ash_xml->get("Service", $response);
621
- if (!$services){
622
-
623
  }
624
  foreach($services as $service){
625
  $service_name = $this->_get_service("SvcDescription",$service);
@@ -706,10 +715,16 @@ class ash_usps{
706
  global $wpec_ash_xml;
707
  //*** Build Request **\\
708
  $request = $this->_build_request($data);
 
 
 
709
  $this->_build_domestic_shipment($request, $data, FALSE);
710
  $request_xml = $wpec_ash_xml->build_message($request);
711
  //*** Make the Request ***\\
712
  $response = $this->_make_request($request_xml,FALSE);
 
 
 
713
  //*** Parse the response from USPS ***\
714
  $package_rate_table = $this->_parse_domestic_response($response);
715
  $rate_table = $this->_merge_arrays($package_rate_table);
@@ -729,10 +744,16 @@ class ash_usps{
729
  foreach($this->shipment->packages as $package){
730
  $temp_data = $data;
731
  $request = $this->_build_request($temp_data);
 
 
 
732
  $this->_build_domestic_shipment($request, $temp_data, $package);
733
  $request_xml = $wpec_ash_xml->build_message($request);
734
  //*** Make the Request ***\\
735
  $response = $this->_make_request($request_xml,FALSE);
 
 
 
736
  //*** Parse the Response ***\\
737
  $package_rate_table = $this->_parse_domestic_response($response);
738
  //*** Reformat the array structure ***\\
@@ -758,10 +779,16 @@ class ash_usps{
758
  foreach($this->shipment->packages as $package){
759
  $temp_data = $data;
760
  $request = $this->_build_request($temp_data);
 
 
 
761
  $this->_build_intl_shipment($request, $temp_data, $package);
762
  $request_xml = $wpec_ash_xml->build_message($request);
763
  //*** Make the Request ***\\
764
  $response = $this->_make_request($request_xml,TRUE);
 
 
 
765
  $rate_table = $this->_parse_intl_response($response);
766
  array_push($rate_tables, $rate_table);
767
  }
@@ -880,13 +907,21 @@ class ash_usps{
880
  */
881
  function getQuote(){
882
  global $wpdb, $wpec_ash, $wpec_ash_tools;
 
 
 
 
 
 
 
883
  $this->shipment = $wpec_ash->get_shipment();
884
  $this->shipment->set_destination($this->internal_name);
885
  // Check to see if the cached shipment is still accurate, if not we need new rate
886
  $cache = $wpec_ash->check_cache($this->internal_name, $this->shipment);
887
- //if ($cache){
888
- // return $cache["rate_table"];
889
- //}
 
890
 
891
  $data = array();
892
  //*** WPEC Configuration values ***\\
@@ -905,9 +940,7 @@ class ash_usps{
905
  //************ GET THE RATE ************\\
906
  $rate_table = $this->_run_quote($data);
907
  //************ CACHE the Results ************\\
908
-
909
  $wpec_ash->cache_results($this->internal_name, $rate_table, $this->shipment);
910
-
911
  return $rate_table;
912
  }
913
 
21
  * default "usps" Don't change unless you know what you are doing!
22
  * @var string
23
  */
24
+ var $internal_name = "usps";
25
  /**
26
  *
27
  * The external name that the USPS class identifies itself.
426
  * @param ASHPackage $package
427
  * @return array
428
  */
429
+ function _build_intl_shipment(&$request,array $data, $package){
430
  $shipment = array();
431
 
432
  $data["pounds"] = floor($package->weight);
453
  "CommercialFlag"=>"Y"
454
  );
455
 
456
+ $base["@attr"]["ID"] = 0;
457
+ array_push($shipment, $base);
 
458
  $request[$data["req"]]["Package"] = $shipment;
459
  }
460
 
467
  */
468
  function _build_request(&$data){
469
  global $wpec_ash_xml;
470
+ if (!is_array($data)){
471
+ return array();
472
+ }
473
  $req = "RateV4Request";
474
  if ($data["dest_country"] != "USA"){
475
  $req = "IntlRateV2Request";
533
  * @param string $package
534
  * @return string
535
  */
536
+ function _get_service($ServiceTag, $package){
537
  global $wpec_ash_xml;
538
  $service = "";
539
+ $temp_service = $wpec_ash_xml->get($ServiceTag, $package);
540
 
541
  if ($temp_service){
542
  $service = $temp_service[0];
559
  */
560
  function _merge_arrays(array $arrays){
561
  $final_array = array();
562
+ if (!is_array($arrays)){
563
+ // How did that happen, I mean really, I am specifying array as the base type
564
+ return $final_array;
565
+ }
566
  foreach($arrays as $arr){
567
  foreach($arr as $key=>$value){
568
  if (!array_key_exists($key, $final_array)){
588
  global $wpec_ash_xml;
589
  $package_services = array();
590
  $this->_clean_response($response);
591
+
592
  $packages = $wpec_ash_xml->get("Package", $response);
593
+ if (!is_array($packages)){
594
+ return array();
595
+ }
596
 
597
  foreach($packages as $package){
598
  $temp = array();
627
  $this->_clean_response($response);
628
 
629
  $services = $wpec_ash_xml->get("Service", $response);
630
+ if (empty($services)){
631
+ return array();
632
  }
633
  foreach($services as $service){
634
  $service_name = $this->_get_service("SvcDescription",$service);
715
  global $wpec_ash_xml;
716
  //*** Build Request **\\
717
  $request = $this->_build_request($data);
718
+ if (empty($request)){
719
+ return array();
720
+ }
721
  $this->_build_domestic_shipment($request, $data, FALSE);
722
  $request_xml = $wpec_ash_xml->build_message($request);
723
  //*** Make the Request ***\\
724
  $response = $this->_make_request($request_xml,FALSE);
725
+ if (empty($response) || $response === FALSE){
726
+ return array();
727
+ }
728
  //*** Parse the response from USPS ***\
729
  $package_rate_table = $this->_parse_domestic_response($response);
730
  $rate_table = $this->_merge_arrays($package_rate_table);
744
  foreach($this->shipment->packages as $package){
745
  $temp_data = $data;
746
  $request = $this->_build_request($temp_data);
747
+ if (empty($request)){
748
+ continue;
749
+ }
750
  $this->_build_domestic_shipment($request, $temp_data, $package);
751
  $request_xml = $wpec_ash_xml->build_message($request);
752
  //*** Make the Request ***\\
753
  $response = $this->_make_request($request_xml,FALSE);
754
+ if (empty($response)){
755
+ continue;
756
+ }
757
  //*** Parse the Response ***\\
758
  $package_rate_table = $this->_parse_domestic_response($response);
759
  //*** Reformat the array structure ***\\
779
  foreach($this->shipment->packages as $package){
780
  $temp_data = $data;
781
  $request = $this->_build_request($temp_data);
782
+ if (empty($request)){
783
+ continue;
784
+ }
785
  $this->_build_intl_shipment($request, $temp_data, $package);
786
  $request_xml = $wpec_ash_xml->build_message($request);
787
  //*** Make the Request ***\\
788
  $response = $this->_make_request($request_xml,TRUE);
789
+ if (empty($response) || $response === FALSE){
790
+ continue;
791
+ }
792
  $rate_table = $this->_parse_intl_response($response);
793
  array_push($rate_tables, $rate_table);
794
  }
907
  */
908
  function getQuote(){
909
  global $wpdb, $wpec_ash, $wpec_ash_tools;
910
+ if (!is_object($wpec_ash)){
911
+ $wpec_ash = new ASH();
912
+ }
913
+ if (!is_object($wpec_ash_tools)){
914
+ $wpec_ash = new ASHTools();
915
+ }
916
+
917
  $this->shipment = $wpec_ash->get_shipment();
918
  $this->shipment->set_destination($this->internal_name);
919
  // Check to see if the cached shipment is still accurate, if not we need new rate
920
  $cache = $wpec_ash->check_cache($this->internal_name, $this->shipment);
921
+
922
+ if ($cache){
923
+ return $cache["rate_table"];
924
+ }
925
 
926
  $data = array();
927
  //*** WPEC Configuration values ***\\
940
  //************ GET THE RATE ************\\
941
  $rate_table = $this->_run_quote($data);
942
  //************ CACHE the Results ************\\
 
943
  $wpec_ash->cache_results($this->internal_name, $rate_table, $this->shipment);
 
944
  return $rate_table;
945
  }
946
 
wpsc-taxes/models/taxes.class.php CHANGED
@@ -85,7 +85,11 @@ class wpec_taxes {
85
  * */
86
  function wpec_taxes_get_rate( $country_code, $region_code='' ) {
87
  //initialize return variable
88
- $returnable = false;
 
 
 
 
89
 
90
  //first check if the region given is part of the country
91
  if ( !empty( $region_code ) ) {
85
  * */
86
  function wpec_taxes_get_rate( $country_code, $region_code='' ) {
87
  //initialize return variable
88
+ // use wpsc_tax_rate hook to provide your own tax solution
89
+ $returnable = apply_filters( 'wpsc_tax_rate', false, $this, $country_code, $region_code );
90
+
91
+ if ( $returnable !== false )
92
+ return $returnable;
93
 
94
  //first check if the region given is part of the country
95
  if ( !empty( $region_code ) ) {
wpsc-theme/functions/wpsc-transaction_results_functions.php CHANGED
@@ -232,8 +232,9 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
232
  $total_tax = '';
233
  $total_shipping_html = '';
234
  $total_shipping_email = '';
235
- $total_shipping_email.= sprintf(__( 'Total Shipping: %s
236
- ', 'wpsc' ), wpsc_currency_display( $total_shipping, array( 'display_as_html' => false ) ) );
 
237
  $total_price_email.= sprintf(__( 'Total: %s
238
  ', 'wpsc' ), wpsc_currency_display( $total, array( 'display_as_html' => false ) ));
239
  if ( $purchase_log['discount_value'] > 0 ) {
@@ -250,8 +251,9 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
250
  $total_tax_html .= __('Total Tax', 'wpsc').': '. wpsc_currency_display( $purchase_log['wpec_taxes_total'] )."\n\r";
251
  $total_tax .= __('Total Tax', 'wpsc').': '. wpsc_currency_display( $purchase_log['wpec_taxes_total'] , array( 'display_as_html' => false ) )."\n\r";
252
  }
253
- $total_shipping_html.= sprintf(__( '<hr>Total Shipping: %s
254
- ', 'wpsc' ), wpsc_currency_display( $total_shipping ));
 
255
  $total_price_html.= sprintf(__( 'Total: %s
256
  ', 'wpsc' ), wpsc_currency_display( $total ) );
257
  $report_id = sprintf(__("Purchase # %s
@@ -299,9 +301,14 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
299
  $message = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . $message;
300
  $message_html = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . $message_html;
301
 
302
- wp_mail( $email, __( 'Order Pending: Payment Required', 'wpsc' ), $message );
303
- } else {
 
 
 
 
304
  wp_mail( $email, __( 'Purchase Receipt', 'wpsc' ), $message );
 
305
  }
306
  }
307
 
@@ -346,9 +353,9 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
346
 
347
  //echo '======REPORT======<br />'.$report.'<br />';
348
  //echo '======EMAIL======<br />'.$message.'<br />';
349
- if ( (get_option( 'purch_log_email' ) != null) && ($purchase_log['email_sent'] != 1) ){
350
  wp_mail( get_option( 'purch_log_email' ), __( 'Purchase Report', 'wpsc' ), $report );
351
- $wpdb->update(WPSC_TABLE_PURCHASE_LOGS, array('email_sent' => '1'), array('id' => $purchase_log['id']) );
352
  }
353
 
354
  /// Adjust stock and empty the cart
232
  $total_tax = '';
233
  $total_shipping_html = '';
234
  $total_shipping_email = '';
235
+ if ( wpsc_uses_shipping() )
236
+ $total_shipping_email.= sprintf(__( 'Total Shipping: %s
237
+ ', 'wpsc' ), wpsc_currency_display( $total_shipping, array( 'display_as_html' => false ) ) );
238
  $total_price_email.= sprintf(__( 'Total: %s
239
  ', 'wpsc' ), wpsc_currency_display( $total, array( 'display_as_html' => false ) ));
240
  if ( $purchase_log['discount_value'] > 0 ) {
251
  $total_tax_html .= __('Total Tax', 'wpsc').': '. wpsc_currency_display( $purchase_log['wpec_taxes_total'] )."\n\r";
252
  $total_tax .= __('Total Tax', 'wpsc').': '. wpsc_currency_display( $purchase_log['wpec_taxes_total'] , array( 'display_as_html' => false ) )."\n\r";
253
  }
254
+ if ( wpsc_uses_shipping() )
255
+ $total_shipping_html.= sprintf(__( '<hr>Total Shipping: %s
256
+ ', 'wpsc' ), wpsc_currency_display( $total_shipping ));
257
  $total_price_html.= sprintf(__( 'Total: %s
258
  ', 'wpsc' ), wpsc_currency_display( $total ) );
259
  $report_id = sprintf(__("Purchase # %s
301
  $message = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . $message;
302
  $message_html = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . $message_html;
303
 
304
+ // prevent email duplicates
305
+ if ( ! get_transient( "{$sessionid}_pending_email_sent" ) ) {
306
+ wp_mail( $email, __( 'Order Pending: Payment Required', 'wpsc' ), $message );
307
+ set_transient( "{$sessionid}_pending_email_sent", true, 60 * 60 * 12 );
308
+ }
309
+ } elseif ( ! get_transient( "{$sessionid}_receipt_email_sent" ) ) {
310
  wp_mail( $email, __( 'Purchase Receipt', 'wpsc' ), $message );
311
+ set_transient( "{$sessionid}_receipt_email_sent", true, 60 * 60 * 12 );
312
  }
313
  }
314
 
353
 
354
  //echo '======REPORT======<br />'.$report.'<br />';
355
  //echo '======EMAIL======<br />'.$message.'<br />';
356
+ if ( (get_option( 'purch_log_email' ) != null) && ( $purchase_log['email_sent'] != 1 ) ){
357
  wp_mail( get_option( 'purch_log_email' ), __( 'Purchase Report', 'wpsc' ), $report );
358
+ $wpdb->update(WPSC_TABLE_PURCHASE_LOGS, array('email_sent' => '1'), array( 'sessionid' => $sessionid ) );
359
  }
360
 
361
  /// Adjust stock and empty the cart
wpsc-theme/functions/wpsc-user_log_functions.php CHANGED
@@ -38,8 +38,7 @@ function validate_form_data() {
38
 
39
  foreach ( (array)$_POST['collected_data'] as $value_id => $value ) {
40
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `id` = '$value_id' LIMIT 1";
41
- $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
42
- $form_data = $form_data[0];
43
  $bad_input = false;
44
  if ( $form_data['mandatory'] == 1 ) {
45
  switch ( $form_data['type'] ) {
@@ -128,8 +127,11 @@ function validate_form_data() {
128
  function wpsc_display_form_fields() {
129
  // Field display and Data saving function
130
 
131
- global $wpdb, $user_ID, $wpsc_purchlog_statuses, $gateway_checkout_form_fields;
132
-
 
 
 
133
  $meta_data = null;
134
  $saved_data_sql = "SELECT * FROM `" . $wpdb->usermeta . "` WHERE `user_id` = '" . $user_ID . "' AND `meta_key` = 'wpshpcrt_usr_profile';";
135
  $saved_data = $wpdb->get_row( $saved_data_sql, ARRAY_A );
@@ -202,10 +204,11 @@ function wpsc_display_form_fields() {
202
  break;
203
 
204
  case "text":
 
205
  if($continue){
206
- echo "<input type='text' value='" . $meta_data[$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
207
 
208
- }elseif('shippingstate' == $form_field['unique_name'] && is_numeric( $meta_data[$form_field['id']] )){
209
 
210
  }
211
 
@@ -244,8 +247,40 @@ function wpsc_display_form_fields() {
244
  echo "<input type='text' value='" . $meta_data[$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
245
  break;
246
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  default:
248
- echo "<input type='text' value='" . $meta_data[$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
 
249
  break;
250
  }
251
  echo "
38
 
39
  foreach ( (array)$_POST['collected_data'] as $value_id => $value ) {
40
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `id` = '$value_id' LIMIT 1";
41
+ $form_data = $wpdb->get_row( $form_sql, ARRAY_A );
 
42
  $bad_input = false;
43
  if ( $form_data['mandatory'] == 1 ) {
44
  switch ( $form_data['type'] ) {
127
  function wpsc_display_form_fields() {
128
  // Field display and Data saving function
129
 
130
+ global $wpdb, $user_ID, $wpsc_purchlog_statuses, $gateway_checkout_form_fields, $wpsc_checkout;
131
+
132
+ if ( empty( $wpsc_checkout ) )
133
+ $wpsc_checkout = new WPSC_Checkout();
134
+
135
  $meta_data = null;
136
  $saved_data_sql = "SELECT * FROM `" . $wpdb->usermeta . "` WHERE `user_id` = '" . $user_ID . "' AND `meta_key` = 'wpshpcrt_usr_profile';";
137
  $saved_data = $wpdb->get_row( $saved_data_sql, ARRAY_A );
204
  break;
205
 
206
  case "text":
207
+ $value = isset( $meta_data[$form_field['id']] ) ? $meta_data[$form_field['id']] : '';
208
  if($continue){
209
+ echo "<input type='text' value='" . $value . "' name='collected_data[" . $form_field['id'] . "]' />";
210
 
211
+ }elseif('shippingstate' == $form_field['unique_name'] && is_numeric( $value )){
212
 
213
  }
214
 
247
  echo "<input type='text' value='" . $meta_data[$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
248
  break;
249
 
250
+ case "select":
251
+ $options = $wpsc_checkout->get_checkout_options( $form_field['id'] );
252
+ $selected = isset( $meta_data[$form_field['id']] ) ? $meta_data[$form_field['id']] : null;
253
+
254
+ ?>
255
+ <select name='collected_data["<?php echo esc_attr( $form_field['id'] ); ?>"]'>
256
+ <option value="-1"><?php _e( 'Select an Option', 'wpsc' ); ?></option>
257
+ <?php foreach ( $options as $label => $value ): ?>
258
+ <option <?php selected( $value, $selected ); ?> value="<?php echo esc_attr( $value ); ?>"><?php echo esc_html( $label ); ?></option>
259
+ <?php endforeach ?>
260
+ </select>
261
+ <?php
262
+ break;
263
+
264
+ case 'checkbox':
265
+ case 'radio':
266
+ $checked_values = isset( $meta_data[$form_field['id']] ) ? (array) $meta_data[$form_field['id']] : array();
267
+ $options = $wpsc_checkout->get_checkout_options( $form_field['id'] );
268
+ $field_name = "collected_data[{$form_field['id']}]";
269
+ if ( $form_field['type'] == 'checkbox' )
270
+ $field_name .= '[]';
271
+ foreach ( $options as $label => $value ) {
272
+ ?>
273
+ <label>
274
+ <input <?php checked( in_array( $value, $checked_values ) ); ?> type="<?php echo $form_field['type']; ?>" id="" name="collected_data[<?php echo esc_attr( $form_field['id'] ); ?>][]" value="<?php echo esc_attr( $value ); ?>" />
275
+ <?php echo esc_html( $label ); ?>
276
+ </label><br />
277
+ <?php
278
+ }
279
+ break;
280
+
281
  default:
282
+ $value = isset( $meta_data[$form_field['id']] ) ? $meta_data[$form_field['id']] : '';
283
+ echo "<input type='text' value='" . $value . "' name='collected_data[" . $form_field['id'] . "]' />";
284
  break;
285
  }
286
  echo "
wpsc-theme/wpsc-category_widget.php CHANGED
@@ -31,7 +31,7 @@
31
  wpsc_parent_category_image( $show_thumbnails, $category_image , $width, $height, false, $show_name ); ?></a>
32
  <?php } ?>
33
 
34
- <a href="<?php echo $link; ?>"><?php echo $curr_cat['name']; ?></a>
35
 
36
  <ul class="wpsc_categories wpsc_second_level_categories">
37
 
31
  wpsc_parent_category_image( $show_thumbnails, $category_image , $width, $height, false, $show_name ); ?></a>
32
  <?php } ?>
33
 
34
+ <a href="<?php echo $link; ?>"><?php echo esc_html( $curr_cat['name'] ); ?></a>
35
 
36
  <ul class="wpsc_categories wpsc_second_level_categories">
37
 
wpsc-theme/wpsc-grid_view.php CHANGED
@@ -88,7 +88,7 @@ $image_height = get_option('product_image_height');
88
  <?php if(wpsc_product_on_special()) : ?>
89
  <p class="pricedisplay <?php echo wpsc_the_product_id(); ?>"><?php _e('Old Price', 'wpsc'); ?>:<span class="oldprice"><?php echo wpsc_product_normal_price(); ?></span></p>
90
  <?php endif; ?>
91
- <p class="pricedisplay <?php echo wpsc_the_product_id(); ?>"><?php _e('Price', 'wpsc'); ?>:<span class="currentprice"><?php echo wpsc_the_product_price(); ?></span></p>
92
  <?php if(wpsc_show_pnp()) : ?>
93
  <p class="pricedisplay"><?php _e('Shipping', 'wpsc'); ?>:<span class="pp_price"><?php echo wpsc_product_postage_and_packaging(); ?></span></p>
94
  <?php endif; ?>
88
  <?php if(wpsc_product_on_special()) : ?>
89
  <p class="pricedisplay <?php echo wpsc_the_product_id(); ?>"><?php _e('Old Price', 'wpsc'); ?>:<span class="oldprice"><?php echo wpsc_product_normal_price(); ?></span></p>
90
  <?php endif; ?>
91
+ <p class="pricedisplay <?php echo wpsc_the_product_id(); ?>"><?php _e('Price', 'wpsc'); ?>:<span id='product_price_<?php echo wpsc_the_product_id(); ?>' class="currentprice pricedisplay"><?php echo wpsc_the_product_price(); ?></span></p>
92
  <?php if(wpsc_show_pnp()) : ?>
93
  <p class="pricedisplay"><?php _e('Shipping', 'wpsc'); ?>:<span class="pp_price"><?php echo wpsc_product_postage_and_packaging(); ?></span></p>
94
  <?php endif; ?>
wpsc-widgets/category_widget.php CHANGED
@@ -112,7 +112,10 @@ class WP_Widget_Product_Categories extends WP_Widget {
112
  $instance = wp_parse_args((array) $instance, array(
113
  'title' => '',
114
  'width' => 45,
115
- 'height' => 45
 
 
 
116
  ));
117
 
118
  // Values
112
  $instance = wp_parse_args((array) $instance, array(
113
  'title' => '',
114
  'width' => 45,
115
+ 'height' => 45,
116
+ 'image' => false,
117
+ 'grid' => false,
118
+ 'show_name' => false,
119
  ));
120
 
121
  // Values
wpsc-widgets/latest_product_widget.php CHANGED
@@ -156,7 +156,7 @@ function wpsc_latest_product( $args = null, $instance ) {
156
  if ( $attached_image->ID > 0 )
157
  $output .= '<img src="' . wpsc_product_image( $attached_image->ID, $width, $height ) . '" title="' . $latest_product->post_title . '" alt="' . $latest_product->post_title . '" />';
158
  else
159
- $output .='<img class="no-image" id="product_image_'.wpsc_the_product_id().'" alt="No Image" title="'.wpsc_the_product_title().'" src="'.WPSC_URL.'/wpsc-theme/images/noimage.png" width="' . $width . '" height="' . $height . '" />';
160
 
161
  $output .= '</a>';
162
  $output .= '</div>';
156
  if ( $attached_image->ID > 0 )
157
  $output .= '<img src="' . wpsc_product_image( $attached_image->ID, $width, $height ) . '" title="' . $latest_product->post_title . '" alt="' . $latest_product->post_title . '" />';
158
  else
159
+ $output .='<img class="no-image" id="product_image_'.wpsc_the_product_id().'" alt="No Image" title="'.wpsc_the_product_title().'" src="'.WPSC_URL.'/wpsc-theme/wpsc-images/noimage.png" width="' . $width . '" height="' . $height . '" />';
160
 
161
  $output .= '</a>';
162
  $output .= '</div>';