WP eCommerce - Version 3.8.Dev.Beta2

Version Description

Download this release

Release Info

Developer jghazally
Plugin Icon 128x128 WP eCommerce
Version 3.8.Dev.Beta2
Comparing to
See all releases

Code changes from version 3.8.Dev.Beta to 3.8.Dev.Beta2

Files changed (78) hide show
  1. wpsc-admin/admin-form-functions.php +5 -18
  2. wpsc-admin/admin.php +9 -6
  3. wpsc-admin/ajax-and-init.php +62 -177
  4. wpsc-admin/css/admin.css +15 -1
  5. wpsc-admin/display-debug.page.php +2 -16
  6. wpsc-admin/display-groups.page.php +11 -8
  7. wpsc-admin/display-items.page.php +80 -20
  8. wpsc-admin/display-options-settings.page.php +4 -2
  9. wpsc-admin/includes/display-items-functions.php +78 -147
  10. wpsc-admin/includes/product-functions.php +114 -193
  11. wpsc-admin/includes/products.php +1 -0
  12. wpsc-admin/includes/save-data.functions.php +5 -6
  13. wpsc-admin/includes/settings-pages/gateway.php +2 -1
  14. wpsc-admin/includes/settings-pages/presentation.php +40 -40
  15. wpsc-admin/includes/settings-pages/shipping.php +17 -70
  16. wpsc-admin/includes/settings-pages/taxes.php +3 -3
  17. wpsc-admin/includes/updating-functions.php +1 -1
  18. wpsc-admin/js/admin-legacy.js +0 -54
  19. wpsc-admin/js/admin.js +0 -50
  20. wpsc-core/images/credit_cards.png +0 -0
  21. wpsc-core/js/jquery.colorbox-min.js +4 -0
  22. wpsc-core/js/tinymce3/cart.png +0 -0
  23. wpsc-core/js/tinymce3/credit_cards.png +0 -0
  24. wpsc-core/js/tinymce3/editor_plugin.js +2 -2
  25. wpsc-core/js/tinymce3/mce.css +0 -9
  26. wpsc-core/js/tinymce3/productspage.gif +0 -0
  27. wpsc-core/js/tinymce3/productspage.jpg +0 -0
  28. wpsc-core/js/tinymce3/tinymce.js +8 -2
  29. wpsc-core/js/tinymce3/window.php +2 -1
  30. wpsc-core/js/user.js +6 -27
  31. wpsc-core/js/wp-e-commerce.js +20 -14
  32. wpsc-core/js/wpsc_colorbox.css +40 -0
  33. wpsc-core/js/wpsc_colorbox.js +5 -0
  34. wpsc-core/wpsc-deprecated.php +5 -3
  35. wpsc-core/wpsc-functions.php +44 -22
  36. wpsc-core/wpsc-includes.php +0 -1
  37. wpsc-includes/ajax.functions.php +59 -79
  38. wpsc-includes/breadcrumbs.class.php +25 -12
  39. wpsc-includes/cart.class.php +6 -12
  40. wpsc-includes/category.functions.php +3 -79
  41. wpsc-includes/checkout.class.php +64 -10
  42. wpsc-includes/coupons.class.php +2 -2
  43. wpsc-includes/display.functions.php +23 -82
  44. wpsc-includes/form-display.functions.php +9 -10
  45. wpsc-includes/homepage_products_functions.php +0 -244
  46. wpsc-includes/merchant.class.php +5 -1
  47. wpsc-includes/misc.functions.php +28 -18
  48. wpsc-includes/processing.functions.php +7 -268
  49. wpsc-includes/product-template.php +118 -27
  50. wpsc-includes/purchaselogs.class.php +3 -3
  51. wpsc-includes/theme.functions.php +47 -29
  52. wpsc-includes/theming.class.php +1 -1
  53. wpsc-includes/variations.class.php +14 -1
  54. wpsc-includes/wpsc_query.php +0 -1086
  55. wpsc-languages/EN_en.php +10 -36
  56. wpsc-merchants/GoogleCheckout-XML.php +1 -1
  57. wpsc-merchants/chronopay.php +3 -4
  58. wpsc-merchants/paypal-standard.merchant.php +54 -24
  59. wpsc-merchants/paypal_multiple.php +0 -646
  60. wpsc-shipping/ups.php +635 -329
  61. wpsc-shipping/ups_data.php +0 -110
  62. wpsc-taxes/controllers/taxes_controller.class.php +24 -29
  63. wpsc-theme/functions/wpsc-transaction_results_functions.php +98 -103
  64. wpsc-theme/functions/wpsc-user_log_functions.php +68 -24
  65. wpsc-theme/wpsc-category_widget.php +0 -1
  66. wpsc-theme/wpsc-default.css +169 -70
  67. wpsc-theme/wpsc-list_view.php +17 -13
  68. wpsc-theme/wpsc-products_page.php +36 -52
  69. wpsc-theme/wpsc-shopping_cart_page.php +38 -22
  70. wpsc-theme/wpsc-single_product.php +9 -5
  71. wpsc-theme/wpsc-transaction_results.php +12 -16
  72. wpsc-theme/wpsc-user-log.php +1 -0
  73. wpsc-updates/database_template.php +0 -119
  74. wpsc-updates/update.php +0 -130
  75. wpsc-updates/updating_tasks.php +0 -24
  76. wpsc-widgets/donations_widget.php +2 -1
  77. wpsc-widgets/specials_widget.php +1 -0
  78. wpsc-widgets/tagging_functions.php +0 -1
wpsc-admin/admin-form-functions.php CHANGED
@@ -302,8 +302,7 @@ function wpsc_packing_slip($purchase_id) {
302
  $purch_sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`='".$purchase_id."'";
303
  $purch_data = $wpdb->get_row($purch_sql,ARRAY_A) ;
304
 
305
-
306
- //echo "<p style='padding-left: 5px;'><strong>".__('Date', 'wpsc')."</strong>:".date("jS M Y", $purch_data['date'])."</p>";
307
 
308
  $cartsql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=".$purchase_id."";
309
  $cart_log = $wpdb->get_results($cartsql,ARRAY_A) ;
@@ -326,7 +325,7 @@ function wpsc_packing_slip($purchase_id) {
326
 
327
  if($input_data != null) {
328
  $form_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1'",ARRAY_A);
329
-
330
  foreach($form_data as $form_field) {
331
  switch($form_field['type']) {
332
  case 'country':
@@ -374,17 +373,6 @@ function wpsc_packing_slip($purchase_id) {
374
  }
375
  }
376
 
377
- // echo " <tr><td colspan='2'></td></tr>\n\r";
378
- // echo " <tr><td>".__('Payment Method', 'wpsc').":</td><td>".$gateway_name."</td></tr>\n\r";
379
- // //echo " <tr><td>".__('Purchase No.', 'wpsc').":</td><td>".$purch_data['id']."</td></tr>\n\r";
380
- // echo " <tr><td>".__('How The Customer Found Us', 'wpsc').":</td><td>".$purch_data['find_us']."</td></tr>\n\r";
381
- // $engrave_line = explode(",",$purch_data['engravetext']);
382
- // echo " <tr><td>".__('Engrave text', 'wpsc')."</td><td></td></tr>\n\r";
383
- // echo " <tr><td>".__('Line 1', 'wpsc').":</td><td>".$engrave_line[0]."</td></tr>\n\r";
384
- // echo " <tr><td>".__('Line 2', 'wpsc').":</td><td>".$engrave_line[1]."</td></tr>\n\r";
385
- // if($purch_data['transactid'] != '') {
386
- // echo " <tr><td>".__('Transaction Id', 'wpsc').":</td><td>".$purch_data['transactid']."</td></tr>\n\r";
387
- // }
388
  echo "</table>\n\r";
389
 
390
 
@@ -414,8 +402,7 @@ function wpsc_packing_slip($purchase_id) {
414
  if(($j % 2) != 0) {
415
  $alternate = "class='alt'";
416
  }
417
- $productsql= "SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`=".$cart_row['prodid']."";
418
- $product_data = $wpdb->get_results($productsql,ARRAY_A);
419
 
420
  $variation_list = '';
421
 
@@ -430,7 +417,7 @@ function wpsc_packing_slip($purchase_id) {
430
  } else {
431
  $shipping = 0;
432
  }
433
-
434
  $price = $cart_row['price'] * $cart_row['quantity'];
435
  $gst = $price - ($price / (1+($cart_row['gst'] / 100)));
436
 
@@ -447,7 +434,7 @@ function wpsc_packing_slip($purchase_id) {
447
  echo " </td>";
448
 
449
  echo " <td>";
450
- echo $product_data[0]['name'];
451
  echo stripslashes($variation_list);
452
  echo " </td>";
453
 
302
  $purch_sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`='".$purchase_id."'";
303
  $purch_data = $wpdb->get_row($purch_sql,ARRAY_A) ;
304
 
305
+ //echo "<p style='padding-left: 5px;'><strong>".__('Date', 'wpsc')."</strong>:".date("jS M Y", $purch_data['date'])."</p>";
 
306
 
307
  $cartsql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=".$purchase_id."";
308
  $cart_log = $wpdb->get_results($cartsql,ARRAY_A) ;
325
 
326
  if($input_data != null) {
327
  $form_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1'",ARRAY_A);
328
+
329
  foreach($form_data as $form_field) {
330
  switch($form_field['type']) {
331
  case 'country':
373
  }
374
  }
375
 
 
 
 
 
 
 
 
 
 
 
 
376
  echo "</table>\n\r";
377
 
378
 
402
  if(($j % 2) != 0) {
403
  $alternate = "class='alt'";
404
  }
405
+ //$cart_row['prodid']
 
406
 
407
  $variation_list = '';
408
 
417
  } else {
418
  $shipping = 0;
419
  }
420
+
421
  $price = $cart_row['price'] * $cart_row['quantity'];
422
  $gst = $price - ($price / (1+($cart_row['gst'] / 100)));
423
 
434
  echo " </td>";
435
 
436
  echo " <td>";
437
+ echo $cart_row['name'];
438
  echo stripslashes($variation_list);
439
  echo " </td>";
440
 
wpsc-admin/admin.php CHANGED
@@ -24,7 +24,6 @@ require_once( WPSC_FILE_PATH . '/wpsc-includes/theming.class.php' );
24
  require_once( WPSC_FILE_PATH . '/wpsc-admin/ajax-and-init.php' );
25
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-options-settings.page.php' );
26
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-sales-logs.php' );
27
-
28
  if ( (isset( $_SESSION['wpsc_activate_debug_page'] ) && ($_SESSION['wpsc_activate_debug_page'] == true)) || (defined( 'WPSC_ADD_DEBUG_PAGE' ) && (constant( 'WPSC_ADD_DEBUG_PAGE' ) == true)) )
29
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-debug.page.php' );
30
 
@@ -114,10 +113,11 @@ function wpsc_admin_pages() {
114
 
115
  // Add Settings pages
116
  $page_hooks[] = $edit_options_page = add_options_page( __( 'Store Settings', 'wpsc' ), __( 'Store', 'wpsc' ), 'administrator', 'wpsc-settings', 'wpsc_display_settings_page' );
 
117
 
118
  // Debug Page
119
  if ( ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( WPSC_ADD_DEBUG_PAGE == true ) ) || ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( true == $_SESSION['wpsc_activate_debug_page'] ) ) )
120
- $page_hooks[] = add_submenu_page( $base_page, __( '- Debug' ), __( '- Debug' ), 'administrator', 'wpsc-debug', 'wpsc_debug_page' );
121
 
122
  // Contextual help
123
  if ( function_exists( 'add_contextual_help' ) ) {
@@ -209,7 +209,7 @@ function wpsc_admin_include_css_and_js() {
209
  $siteurl = str_replace( "http://", "https://", $siteurl );
210
 
211
  wp_admin_css( 'dashboard' );
212
- wp_admin_css( 'media' );
213
 
214
  $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
215
  wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
@@ -293,12 +293,12 @@ function wpsc_meta_boxes() {
293
  add_meta_box('wpsc_product_taxes_forms','Taxes','wpsc_product_taxes_forms',$pagename,'normal','high');
294
  add_meta_box( 'wpsc_product_category_and_tag_forms', 'Category and Tags', 'wpsc_product_category_and_tag_forms', $pagename, 'normal', 'high' );
295
  add_meta_box( 'wpsc_product_tag_forms', 'Product Tags', 'wpsc_product_tag_forms', $pagename, 'normal', 'high' );
296
- // add_meta_box( 'wpsc_product_price_and_stock_forms', 'Price and Stock', 'wpsc_product_price_and_stock_forms', $pagename, 'normal', 'high' );
297
  add_meta_box( 'wpsc_product_download_forms', 'Product Download', 'wpsc_product_download_forms', $pagename, 'normal', 'high' );
298
  add_meta_box( 'wpsc_product_image_forms', 'Product Images', 'wpsc_product_image_forms', $pagename, 'normal', 'high' );
299
  add_meta_box( 'wpsc_product_shipping_forms', 'Shipping', 'wpsc_product_shipping_forms', $pagename, 'normal', 'high' );
300
  add_meta_box( 'wpsc_product_variation_forms', 'Variation Control', 'wpsc_product_variation_forms', $pagename, 'normal', 'high' );
301
  add_meta_box( 'wpsc_product_advanced_forms', 'Advanced Settings', 'wpsc_product_advanced_forms', $pagename, 'normal', 'high' );
 
302
  }
303
 
304
  add_action( 'admin_menu', 'wpsc_meta_boxes' );
@@ -733,8 +733,6 @@ function wpsc_dashboard_4months_widget() {
733
  GROUP BY `cart`.`prodid`"; //get the amount of income that current product has generaterd over current time range
734
  $sale_totals[] = $wpdb->get_var( $prodsql ); //push amount to array
735
  }
736
- //$namesql = "SELECT `".WPSC_TABLE_PRODUCT_LIST."`.`name` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`id` = ".$product['prodid'];
737
- //$name = $wpdb->get_results($namesql,ARRAY_A);
738
  $prod_data[] = array(
739
  'sale_totals' => $sale_totals,
740
  'product_name' => $product['name'] ); //result: array of 2: $prod_data[0] = array(income)
@@ -821,4 +819,9 @@ function wpsc_admin_notices() {
821
  if ( isset( $_GET['page'] ) && (stristr( $_GET['page'], WPSC_DIR_NAME )) )
822
  add_action( 'admin_notices', 'wpsc_admin_notices' );
823
 
 
 
 
 
 
824
  ?>
24
  require_once( WPSC_FILE_PATH . '/wpsc-admin/ajax-and-init.php' );
25
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-options-settings.page.php' );
26
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-sales-logs.php' );
 
27
  if ( (isset( $_SESSION['wpsc_activate_debug_page'] ) && ($_SESSION['wpsc_activate_debug_page'] == true)) || (defined( 'WPSC_ADD_DEBUG_PAGE' ) && (constant( 'WPSC_ADD_DEBUG_PAGE' ) == true)) )
28
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-debug.page.php' );
29
 
113
 
114
  // Add Settings pages
115
  $page_hooks[] = $edit_options_page = add_options_page( __( 'Store Settings', 'wpsc' ), __( 'Store', 'wpsc' ), 'administrator', 'wpsc-settings', 'wpsc_display_settings_page' );
116
+ add_action('admin_print_scripts-' . $edit_options_page , 'wpsc_print_admin_scripts');
117
 
118
  // Debug Page
119
  if ( ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( WPSC_ADD_DEBUG_PAGE == true ) ) || ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( true == $_SESSION['wpsc_activate_debug_page'] ) ) )
120
+ $page_hooks[] = add_options_page( __( 'Store Debug' ), __( 'Store Debug' ), 'administrator', 'wpsc-debug', 'wpsc_debug_page' );
121
 
122
  // Contextual help
123
  if ( function_exists( 'add_contextual_help' ) ) {
209
  $siteurl = str_replace( "http://", "https://", $siteurl );
210
 
211
  wp_admin_css( 'dashboard' );
212
+ //wp_admin_css( 'media' );
213
 
214
  $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
215
  wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
293
  add_meta_box('wpsc_product_taxes_forms','Taxes','wpsc_product_taxes_forms',$pagename,'normal','high');
294
  add_meta_box( 'wpsc_product_category_and_tag_forms', 'Category and Tags', 'wpsc_product_category_and_tag_forms', $pagename, 'normal', 'high' );
295
  add_meta_box( 'wpsc_product_tag_forms', 'Product Tags', 'wpsc_product_tag_forms', $pagename, 'normal', 'high' );
 
296
  add_meta_box( 'wpsc_product_download_forms', 'Product Download', 'wpsc_product_download_forms', $pagename, 'normal', 'high' );
297
  add_meta_box( 'wpsc_product_image_forms', 'Product Images', 'wpsc_product_image_forms', $pagename, 'normal', 'high' );
298
  add_meta_box( 'wpsc_product_shipping_forms', 'Shipping', 'wpsc_product_shipping_forms', $pagename, 'normal', 'high' );
299
  add_meta_box( 'wpsc_product_variation_forms', 'Variation Control', 'wpsc_product_variation_forms', $pagename, 'normal', 'high' );
300
  add_meta_box( 'wpsc_product_advanced_forms', 'Advanced Settings', 'wpsc_product_advanced_forms', $pagename, 'normal', 'high' );
301
+ add_meta_box( 'wpsc_product_external_link_forms', 'Off Site Product link', 'wpsc_product_external_link_forms', $pagename, 'normal', 'high' );
302
  }
303
 
304
  add_action( 'admin_menu', 'wpsc_meta_boxes' );
733
  GROUP BY `cart`.`prodid`"; //get the amount of income that current product has generaterd over current time range
734
  $sale_totals[] = $wpdb->get_var( $prodsql ); //push amount to array
735
  }
 
 
736
  $prod_data[] = array(
737
  'sale_totals' => $sale_totals,
738
  'product_name' => $product['name'] ); //result: array of 2: $prod_data[0] = array(income)
819
  if ( isset( $_GET['page'] ) && (stristr( $_GET['page'], WPSC_DIR_NAME )) )
820
  add_action( 'admin_notices', 'wpsc_admin_notices' );
821
 
822
+ function wpsc_print_admin_scripts(){
823
+ global $version_identifier;
824
+ wp_enqueue_script( 'wp-e-commerce-dynamic', get_bloginfo('url') . "/index.php?wpsc_user_dynamic_js=true", false, $version_identifier );
825
+ }
826
+
827
  ?>
wpsc-admin/ajax-and-init.php CHANGED
@@ -203,6 +203,31 @@ function wpsc_bulk_modify_products() {
203
  //exit( "<pre>".print_r($_POST,true)."</pre>");
204
  switch ( $doaction ) {
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  case 'publish':
207
  foreach ( (array)$product_ids as $product_id ) {
208
  $product_id = absint( $product_id );
@@ -278,6 +303,9 @@ function wpsc_bulk_modify_products() {
278
  if ( isset( $_POST['search'] ) && !empty( $_POST['search'] ) ) {
279
  // urlencode the search query to allow for spaces, etc
280
  $sendback = add_query_arg( 'search', urlencode( stripslashes( $_POST['search'] ) ), $sendback );
 
 
 
281
  }
282
  break;
283
  }
@@ -674,9 +702,8 @@ function wpsc_purchase_log_csv() {
674
 
675
  foreach ( (array)$cart as $item ) {
676
  $output .= ",";
677
- $product = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id`=" . $item['prodid'] . " LIMIT 1", ARRAY_A );
678
- $skusql = "SELECT `meta_value` FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `meta_key`= 'sku' AND `product_id` = " . $item['prodid'];
679
- $skuvalue = $wpdb->get_var( $skusql );
680
  $output .= "\"" . $item['quantity'] . " " . str_replace( '"', '\"', $product['name'] ) . $variation_list . "\"";
681
  $output .= "," . $skuvalue;
682
  }
@@ -750,19 +777,9 @@ function wpsc_admin_ajax() {
750
  array_walk( $current_order["closedboxes"], "wpec_close_box", $closed );
751
 
752
  update_option( 'wpsc_product_page_order', $current_order );
753
- print_r( $current_order );
754
  }
755
 
756
- // if ($_POST['del_prod'] == 'true') {
757
- // $ids = $_POST['del_prod_id'];
758
- // $ids = explode(',',$ids);
759
- // foreach ($ids as $id) {
760
- // $wpdb->query($wpdb->prepare("DELETE FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`=%d", $id));
761
- // }
762
- // exit();
763
- // }
764
-
765
-
766
  if ( ($_POST['save_image_upload_state'] == "true") && is_numeric( $_POST['image_upload_state'] ) ) {
767
  //get_option('wpsc_image_upload_state');
768
  $upload_state = (int)(bool)$_POST['image_upload_state'];
@@ -776,29 +793,6 @@ function wpsc_admin_ajax() {
776
  exit();
777
  }
778
 
779
-
780
- if ( ($_POST['edit_variation_value_list'] == 'true') && is_numeric( $_POST['variation_id'] ) && is_numeric( $_POST['product_id'] ) ) {
781
- $variation_id = (int)$_POST['variation_id'];
782
- $product_id = (int)$_POST['product_id'];
783
- $variations_processor = new nzshpcrt_variations();
784
- $variation_values = $variations_processor->falsepost_variation_values( $variation_id );
785
- if ( is_array( $variation_values ) ) {
786
- //echo(print_r($variation_values,true));
787
- $check_variation_added = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_VARIATION_ASSOC . "` WHERE `type` IN ('product') AND `associated_id` IN ('{$product_id}') AND `variation_id` IN ('{$variation_id}') LIMIT 1" );
788
- //exit("<pre>".print_r($variation_values,true)."<pre>");
789
- if ( $check_variation_added == null ) {
790
- $variations_processor->add_to_existing_product( $product_id, $variation_values );
791
- }
792
- echo $variations_processor->display_attached_variations( $product_id );
793
- echo $variations_processor->variations_grid_view( $product_id );
794
- } else {
795
- echo "false";
796
- }
797
- exit();
798
- }
799
-
800
-
801
-
802
  if ( ($_POST['remove_form_field'] == "true") && is_numeric( $_POST['form_id'] ) ) {
803
  //exit(print_r($user,true));
804
  if ( current_user_can( 'level_7' ) ) {
@@ -866,73 +860,6 @@ function wpsc_admin_ajax() {
866
  }
867
  }
868
 
869
- if ( ($_POST['list_variation_values'] == "true" ) ) {
870
- // retrieve the forms for associating variations and their values with products
871
- $variation_processor = new nzshpcrt_variations();
872
-
873
- $variations_selected = array( );
874
- foreach ( (array)$_POST['variations'] as $variation_id => $checked ) {
875
- $variations_selected[] = (int)$variation_id;
876
- }
877
-
878
- if ( is_numeric( $_POST['product_id'] ) && ($_POST['product_id'] > 0) ) {
879
- $product_id = absint( $_POST['product_id'] );
880
- $selected_price = (float)$_POST['selected_price'];
881
-
882
- // variation values housekeeping
883
- $completed_variation_values = $variation_processor->edit_product_values( $product_id, $_POST['edit_var_val'], $selected_price );
884
-
885
- // get all the currently associated variations from the database
886
- $associated_variations = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_VARIATION_ASSOC . "` WHERE `type` IN ('product') AND `associated_id` IN ('{$product_id}')", ARRAY_A );
887
-
888
- $variations_still_associated = array( );
889
- foreach ( (array)$associated_variations as $associated_variation ) {
890
- // remove variations not checked that are in the database
891
- if ( array_search( $associated_variation['variation_id'], $variations_selected ) === false ) {
892
- $wpdb->query( "DELETE FROM `" . WPSC_TABLE_VARIATION_ASSOC . "` WHERE `id` = '{$associated_variation['id']}' LIMIT 1" );
893
- $wpdb->query( "DELETE FROM `" . WPSC_TABLE_VARIATION_VALUES_ASSOC . "` WHERE `product_id` = '{$product_id}' AND `variation_id` = '{$associated_variation['variation_id']}' " );
894
- } else {
895
- // make an array for adding in the variations next step, for efficiency
896
- $variations_still_associated[] = $associated_variation['variation_id'];
897
- }
898
- }
899
-
900
- foreach ( (array)$variations_selected as $variation_id ) {
901
- // add variations not already in the database that have been checked.
902
- $variation_values = $variation_processor->falsepost_variation_values( $variation_id );
903
- if ( array_search( $variation_id, $variations_still_associated ) === false ) {
904
- $variation_processor->add_to_existing_product( $product_id, $variation_values );
905
- }
906
- }
907
- //echo "/* ".print_r($variation_values,true)." */\n\r";
908
- echo "edit_variation_combinations_html = \"" . str_replace( array( "\n", "\r" ), array( '\n', '\r' ), addslashes( $variation_processor->variations_grid_view( $product_id, (array)$completed_variation_values ) ) ) . "\";\n";
909
- } else {
910
- if ( count( $variations_selected ) > 0 ) {
911
- // takes an array of variations, returns a form for adding data to those variations.
912
- if ( (float)$_POST['selected_price'] > 0 ) {
913
- $selected_price = (float)$_POST['selected_price'];
914
- }
915
- $limited_stock = false;
916
- if ( $_POST['limited_stock'] == 'true' ) {
917
- $limited_stock = true;
918
- }
919
-
920
- $selected_variation_values = array( );
921
- foreach ( $_POST['edit_var_val'] as $variation_value_array ) {
922
- //echo "/* ".print_r($variation_value_array,true)." */\n\r";
923
- $selected_variation_values = array_merge( array_keys( $variation_value_array ), $selected_variation_values );
924
- }
925
-
926
- ////echo "/* ".print_r($selected_variation_values,true)." */\n\r";
927
- echo "edit_variation_combinations_html = \"" . __( 'Edit Variation Set', 'wpsc' ) . "<br />" . str_replace( array( "\n", "\r" ), array( '\n', '\r' ), addslashes( $variation_processor->variations_grid_view( 0, (array)$variations_selected, (array)$selected_variation_values, $selected_price, $limited_stock ) ) ) . "\";\n";
928
- } else {
929
- echo "edit_variation_combinations_html = \"\";\n";
930
- }
931
- }
932
- exit();
933
- }
934
-
935
-
936
  if ( isset( $_POST['language_setting'] ) && ($_GET['page'] = WPSC_DIR_NAME . '/wpsc-admin/display-options.page.php') ) {
937
  if ( $user_level >= 7 ) {
938
  update_option( 'language_setting', $_POST['language_setting'] );
@@ -959,7 +886,7 @@ function wpsc_admin_sale_rss() {
959
  foreach ( (array)$purchase_log as $purchase ) {
960
  $purchase_link = get_option( 'siteurl' ) . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php&amp;purchaseid=" . $purchase['id'];
961
  $output .= " <item>\n\r";
962
- $output .= " <title>Purchase No. " . $purchase['id'] . "</title>\n\r";
963
  $output .= " <link>$purchase_link</link>\n\r";
964
  $output .= " <description>This is an entry in the purchase log.</description>\n\r";
965
  $output .= " <pubDate>" . date( "r", $purchase['date'] ) . "</pubDate>\n\r";
@@ -1040,22 +967,12 @@ if ( isset( $_GET['display_invoice'] ) && ( 'true' == $_GET['display_invoice'] )
1040
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc_display_invoice' == $_REQUEST['wpsc_admin_action'] ) )
1041
  add_action( 'admin_init', 'wpsc_display_invoice' );
1042
 
1043
- function wpsc_save_inline_price() {
1044
- global $wpdb;
1045
- $pid = $_POST['id'];
1046
- $new_price = $_POST['value'];
1047
- $new_price1 = str_replace( '$', '', $new_price );
1048
- $wpdb->query( "UPDATE " . WPSC_TABLE_PRODUCT_LIST . " SET price='$new_price1' WHERE id='$pid'" );
1049
- exit( $new_price );
1050
- }
1051
- if ( isset( $_GET['inline_price'] ) && ($_GET['inline_price'] == 'true') )
1052
- add_action( 'admin_init', 'wpsc_save_inline_price', 0 );
1053
-
1054
  /**
1055
  * Purchase log ajax code starts here
1056
  */
1057
  function wpsc_purchlog_resend_email() {
1058
  global $wpdb;
 
1059
  $siteurl = get_option( 'siteurl' );
1060
  $log_id = $_GET['email_buyer_id'];
1061
  if ( is_numeric( $log_id ) ) {
@@ -1140,7 +1057,8 @@ function wpsc_purchlog_resend_email() {
1140
  }
1141
  do_action( 'wpsc_confirm_checkout', $purchase_log['id'] );
1142
 
1143
- $shipping = nzshpcrt_determine_item_shipping( $row['prodid'], $row['quantity'], $shipping_country );
 
1144
  if ( isset( $_SESSION['quote_shipping'] ) ) {
1145
  $shipping = $_SESSION['quote_shipping'];
1146
  }
@@ -1366,24 +1284,20 @@ function wpsc_purchlog_edit_status( $purchlog_id='', $purchlog_status='' ) {
1366
  }
1367
 
1368
  // if the order is marked as failed, remove the claim on the stock
1369
- if ( $purchlog_status == 5 ) {
1370
  $wpdb->query( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'" );
1371
- //echo "DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'";
1372
- }
1373
 
1374
  $wpdb->query( "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET processed='{$purchlog_status}' WHERE id='{$purchlog_id}'" );
1375
 
1376
  if ( ($purchlog_id > $log_data['processed']) && ($log_data['processed'] <= 2) && $log_data['email_sent'] == 0 ) {
1377
- // transaction_results($log_data['sessionid'],false,null);
1378
  }
1379
  }
1380
 
1381
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlog_edit_status') ) {
1382
  add_action( 'admin_init', 'wpsc_purchlog_edit_status' );
1383
  }
1384
- /*
1385
- SELECT DISTINCT `products`.*, `category`.`category_id`,`order`.`order`, IF(ISNULL(`order`.`order`), 0, 1) AS `order_state` FROM `wp_wpsc_product_list` AS `products` LEFT JOIN `wp_wpsc_item_category_assoc` AS `category` ON `products`.`id` = `category`.`product_id` LEFT JOIN `wp_wpsc_product_order` AS `order` ON ( ( `products`.`id` = `order`.`product_id` ) AND ( `category`.`category_id` = `order`.`category_id` ) ) WHERE `products`.`publish`='1' AND `products`.`active` = '1' AND `category`.`category_id` IN ('3') ORDER BY `order_state` DESC, `products`.`id` DESC,`order`.`order` ASC LIMIT 0, 8
1386
- */
1387
 
1388
  function wpsc_save_product_order() {
1389
  global $wpdb;
@@ -1411,7 +1325,6 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
1411
 
1412
  function wpsc_save_checkout_order() {
1413
  global $wpdb;
1414
- //exit('<pre>'.print_r($_POST, true).'</pre>');
1415
  $checkoutfields = $_POST['checkout'];
1416
  $order = 1;
1417
  foreach ( $checkoutfields as $checkoutfield ) {
@@ -1734,47 +1647,6 @@ function wpsc_rearrange_images() {
1734
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'rearrange_images') )
1735
  add_action( 'admin_init', 'wpsc_rearrange_images' );
1736
 
1737
- function wpsc_delete_images() {
1738
- global $wpdb;
1739
- $product_id = absint( $_POST['product_id'] );
1740
- $element_id = $_POST['del_img_id'];
1741
- $image_id = absint( str_replace( "product_image_", '', $element_id ) );
1742
- if ( $image_id > 0 ) {
1743
- $deletion_success = $wpdb->query( "DELETE FROM `" . WPSC_TABLE_PRODUCT_IMAGES . "` WHERE `id`='{$image_id}' LIMIT 1" );
1744
- echo "element_id = '$element_id';\n";
1745
- //echo "/*\n";
1746
- //print_r($deletion_success);
1747
- //echo "*/\n";
1748
-
1749
- if ( ($product_id > 0) && ($deletion_success == true) ) {
1750
- $next_image = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PRODUCT_IMAGES . "` WHERE `product_id` = '{$product_id}' ORDER BY `image_order` ASC LIMIT 1", ARRAY_A );
1751
- if ( count( $next_image ) > 0 ) {
1752
- $wpdb->query( "UPDATE `" . WPSC_TABLE_PRODUCT_LIST . "` SET `image` = '{$next_image['id']}' WHERE `id` = '{$product_id}' LIMIT 1" );
1753
- $output = wpsc_main_product_image_menu( $product_id );
1754
-
1755
- $height = get_option( 'product_image_height' );
1756
- $width = get_option( 'product_image_width' );
1757
-
1758
- $image_input = WPSC_IMAGE_DIR . $next_image['file'];
1759
- $image_output = WPSC_THUMBNAIL_DIR . $next_image['file'];
1760
- if ( ($product['file'] != '') and file_exists( $image_input ) ) {
1761
- image_processing( $image_input, $image_output, $width, $height );
1762
- update_product_meta( $product_id, 'thumbnail_width', $width );
1763
- update_product_meta( $product_id, 'thumbnail_height', $height );
1764
- }
1765
- echo "image_menu='" . str_replace( array( "\n", "\r" ), array( '\n', '\r' ), addslashes( $output ) ) . "';\n";
1766
- echo "image_id='" . $next_image['id'] . "';\n";
1767
- } else {
1768
- $wpdb->query( "UPDATE `" . WPSC_TABLE_PRODUCT_LIST . "` SET `image` = NULL WHERE `id` = '{$product_id}' LIMIT 1" );
1769
- }
1770
- }
1771
- }
1772
-
1773
- exit();
1774
- }
1775
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_images') )
1776
- add_action( 'admin_init', 'wpsc_delete_images' );
1777
-
1778
  function wpsc_update_page_urls() {
1779
  global $wpdb;
1780
 
@@ -2491,16 +2363,30 @@ function variation_price_field( $variation ) {
2491
  $price = $term_prices[$term_id]["price"];
2492
  else
2493
  $price = '';
2494
- ?>
2495
 
 
 
2496
  <div class="form-field">
2497
  <label for="variation_price"><?php _e( 'Variation Price', 'wpsc' ); ?></label>
2498
 
2499
  <input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
2500
  <span class="description"><?php _e( 'You can list a default price here for this variation. You can list a regular price (18.99), differential price (+1.99 / -2) or even a percentage-based price (+50% / -25%).', 'wpsc' ); ?></span>
2501
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2502
 
2503
- <?php
2504
  }
2505
  add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field' );
2506
  add_action( 'wpsc-variation_add_form_fields', 'variation_price_field' );
@@ -2603,35 +2489,34 @@ function save_term_prices( $term_id ) {
2603
  //Are we decreasing or increasing the price?
2604
 
2605
  if ( strchr( $_POST["variation_price"], '-' ) )
2606
- $negative = true;
2607
  else
2608
  $positive = true;
2609
 
2610
  //Now, let's get the parent product price, +/- by the percentage given
2611
- $percentage = (floatval( $_POST["variation_price"] ) / 100);
2612
 
2613
  if ( $positive )
2614
  $price = $parent_pricing + ($parent_pricing * $percentage);
2615
- elseif ( $negative )
2616
  $price = $parent_pricing - ($parent_pricing * $percentage);
2617
 
2618
  update_product_meta( $kiddos, "price", $price );
2619
  } elseif ( $var_price_type == 'differential' ) {
2620
-
2621
  //Are we decreasing or increasing the price?
2622
  if ( strchr( $_POST["variation_price"], '-' ) )
2623
- $negative = true;
2624
  else
2625
  $positive = true;
2626
 
2627
  //Now, let's get the parent product price, +/- by the differential given
2628
- $differential = (floatval( $_POST["variation_price"] ));
2629
 
2630
  if ( $positive )
2631
  $price = $parent_pricing + $differential;
2632
- elseif ( $negative )
2633
  $price = $parent_pricing - $differential;
2634
-
2635
  update_product_meta( $kiddos, "price", $price );
2636
  }
2637
  }
@@ -2643,4 +2528,4 @@ add_action( 'created_wpsc-variation', 'save_term_prices' );
2643
 
2644
 
2645
 
2646
- ?>
203
  //exit( "<pre>".print_r($_POST,true)."</pre>");
204
  switch ( $doaction ) {
205
 
206
+ case 'addgroup':
207
+
208
+ foreach ( (array)$product_ids as $product_id ) {
209
+ $product_id = absint( $product_id );
210
+ $current_product_categories = get_the_product_category($product_id);
211
+ $new_product_category = array();
212
+ if(isset($_POST['category']) && is_numeric($_POST['category'])){
213
+ array_push($new_product_category,$_POST['category']);
214
+ }else{
215
+ //No Valid Group was selected for bulk assignment :(
216
+ $sendback = add_query_arg( 'addedgroup', 'quack', $sendback );
217
+ break;
218
+ }
219
+ if(isset($current_product_categories)){
220
+ foreach($current_product_categories as $category){
221
+ array_push($new_product_category,$category->term_id);
222
+ }
223
+ }
224
+
225
+ wp_set_product_categories($product_id,$new_product_category);
226
+ $added++;
227
+ }
228
+ $sendback = add_query_arg( 'addedgroup', $added, $sendback );
229
+ break;
230
+
231
  case 'publish':
232
  foreach ( (array)$product_ids as $product_id ) {
233
  $product_id = absint( $product_id );
303
  if ( isset( $_POST['search'] ) && !empty( $_POST['search'] ) ) {
304
  // urlencode the search query to allow for spaces, etc
305
  $sendback = add_query_arg( 'search', urlencode( stripslashes( $_POST['search'] ) ), $sendback );
306
+ }elseif( !empty( $_POST['category'] )){
307
+ $sendback = add_query_arg( 'category_id', (int)$_POST['category'], $sendback);
308
+
309
  }
310
  break;
311
  }
702
 
703
  foreach ( (array)$cart as $item ) {
704
  $output .= ",";
705
+ $product = $wpdb->get_row( "SELECT * FROM `" . $wpdb->posts . "` WHERE `id`=" . $item['prodid'] . " LIMIT 1", ARRAY_A );
706
+ $skuvalue = get_product_meta($item['prodid'], 'sku', true);
 
707
  $output .= "\"" . $item['quantity'] . " " . str_replace( '"', '\"', $product['name'] ) . $variation_list . "\"";
708
  $output .= "," . $skuvalue;
709
  }
777
  array_walk( $current_order["closedboxes"], "wpec_close_box", $closed );
778
 
779
  update_option( 'wpsc_product_page_order', $current_order );
780
+ //print_r( $current_order );
781
  }
782
 
 
 
 
 
 
 
 
 
 
 
783
  if ( ($_POST['save_image_upload_state'] == "true") && is_numeric( $_POST['image_upload_state'] ) ) {
784
  //get_option('wpsc_image_upload_state');
785
  $upload_state = (int)(bool)$_POST['image_upload_state'];
793
  exit();
794
  }
795
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
796
  if ( ($_POST['remove_form_field'] == "true") && is_numeric( $_POST['form_id'] ) ) {
797
  //exit(print_r($user,true));
798
  if ( current_user_can( 'level_7' ) ) {
860
  }
861
  }
862
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
863
  if ( isset( $_POST['language_setting'] ) && ($_GET['page'] = WPSC_DIR_NAME . '/wpsc-admin/display-options.page.php') ) {
864
  if ( $user_level >= 7 ) {
865
  update_option( 'language_setting', $_POST['language_setting'] );
886
  foreach ( (array)$purchase_log as $purchase ) {
887
  $purchase_link = get_option( 'siteurl' ) . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php&amp;purchaseid=" . $purchase['id'];
888
  $output .= " <item>\n\r";
889
+ $output .= " <title>Purchase # " . $purchase['id'] . "</title>\n\r";
890
  $output .= " <link>$purchase_link</link>\n\r";
891
  $output .= " <description>This is an entry in the purchase log.</description>\n\r";
892
  $output .= " <pubDate>" . date( "r", $purchase['date'] ) . "</pubDate>\n\r";
967
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc_display_invoice' == $_REQUEST['wpsc_admin_action'] ) )
968
  add_action( 'admin_init', 'wpsc_display_invoice' );
969
 
 
 
 
 
 
 
 
 
 
 
 
970
  /**
971
  * Purchase log ajax code starts here
972
  */
973
  function wpsc_purchlog_resend_email() {
974
  global $wpdb;
975
+ $shipping=0;
976
  $siteurl = get_option( 'siteurl' );
977
  $log_id = $_GET['email_buyer_id'];
978
  if ( is_numeric( $log_id ) ) {
1057
  }
1058
  do_action( 'wpsc_confirm_checkout', $purchase_log['id'] );
1059
 
1060
+ $shipping = $row['pnp'] * $row['quantity'];
1061
+ $total_shipping += $shipping;
1062
  if ( isset( $_SESSION['quote_shipping'] ) ) {
1063
  $shipping = $_SESSION['quote_shipping'];
1064
  }
1284
  }
1285
 
1286
  // if the order is marked as failed, remove the claim on the stock
1287
+ if ( $purchlog_status == 5 )
1288
  $wpdb->query( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'" );
1289
+
 
1290
 
1291
  $wpdb->query( "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET processed='{$purchlog_status}' WHERE id='{$purchlog_id}'" );
1292
 
1293
  if ( ($purchlog_id > $log_data['processed']) && ($log_data['processed'] <= 2) && $log_data['email_sent'] == 0 ) {
1294
+ transaction_results($log_data['sessionid'],false,null);
1295
  }
1296
  }
1297
 
1298
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlog_edit_status') ) {
1299
  add_action( 'admin_init', 'wpsc_purchlog_edit_status' );
1300
  }
 
 
 
1301
 
1302
  function wpsc_save_product_order() {
1303
  global $wpdb;
1325
 
1326
  function wpsc_save_checkout_order() {
1327
  global $wpdb;
 
1328
  $checkoutfields = $_POST['checkout'];
1329
  $order = 1;
1330
  foreach ( $checkoutfields as $checkoutfield ) {
1647
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'rearrange_images') )
1648
  add_action( 'admin_init', 'wpsc_rearrange_images' );
1649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1650
  function wpsc_update_page_urls() {
1651
  global $wpdb;
1652
 
2363
  $price = $term_prices[$term_id]["price"];
2364
  else
2365
  $price = '';
 
2366
 
2367
+ if(isset($_GET['action']) && 'add' == $_GET['action']){
2368
+ ?>
2369
  <div class="form-field">
2370
  <label for="variation_price"><?php _e( 'Variation Price', 'wpsc' ); ?></label>
2371
 
2372
  <input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
2373
  <span class="description"><?php _e( 'You can list a default price here for this variation. You can list a regular price (18.99), differential price (+1.99 / -2) or even a percentage-based price (+50% / -25%).', 'wpsc' ); ?></span>
2374
  </div>
2375
+ <?php
2376
+ }else{
2377
+ ?>
2378
+ <tr class="form-field">
2379
+ <th scope="row" valign="top">
2380
+ <label for="variation_price"><?php _e( 'Variation Price', 'wpsc' ); ?></label>
2381
+ </td>
2382
+ <td>
2383
+ <input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
2384
+ <span class="description"><?php _e( 'You can list a default price here for this variation. You can list a regular price (18.99), differential price (+1.99 / -2) or even a percentage-based price (+50% / -25%).', 'wpsc' ); ?></span>
2385
+ </td>
2386
+ </tr>
2387
+ <?php
2388
+ }
2389
 
 
2390
  }
2391
  add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field' );
2392
  add_action( 'wpsc-variation_add_form_fields', 'variation_price_field' );
2489
  //Are we decreasing or increasing the price?
2490
 
2491
  if ( strchr( $_POST["variation_price"], '-' ) )
2492
+ $positive = false;
2493
  else
2494
  $positive = true;
2495
 
2496
  //Now, let's get the parent product price, +/- by the percentage given
2497
+ $percentage = (absint( $_POST["variation_price"] ) / 100);
2498
 
2499
  if ( $positive )
2500
  $price = $parent_pricing + ($parent_pricing * $percentage);
2501
+ else
2502
  $price = $parent_pricing - ($parent_pricing * $percentage);
2503
 
2504
  update_product_meta( $kiddos, "price", $price );
2505
  } elseif ( $var_price_type == 'differential' ) {
2506
+
2507
  //Are we decreasing or increasing the price?
2508
  if ( strchr( $_POST["variation_price"], '-' ) )
2509
+ $positive = false;
2510
  else
2511
  $positive = true;
2512
 
2513
  //Now, let's get the parent product price, +/- by the differential given
2514
+ $differential = (absint( $_POST["variation_price"] ));
2515
 
2516
  if ( $positive )
2517
  $price = $parent_pricing + $differential;
2518
+ else
2519
  $price = $parent_pricing - $differential;
 
2520
  update_product_meta( $kiddos, "price", $price );
2521
  }
2522
  }
2528
 
2529
 
2530
 
2531
+ ?>
wpsc-admin/css/admin.css CHANGED
@@ -266,6 +266,10 @@ div.wpsc_floatleft{
266
  width:161px;
267
  float:left;
268
  }
 
 
 
 
269
 
270
  /* Sortable product styling*/
271
 
@@ -309,8 +313,18 @@ div.product-placeholder {
309
  border-color: #bbb;
310
  background-color: #f5f5f5;
311
  margin: -2px 0 0 -2px;
 
312
  }
313
 
 
 
 
 
 
 
 
 
 
314
 
315
  /* Product details form styling */
316
 
@@ -1366,7 +1380,7 @@ a.variation_handle {
1366
  display:none;
1367
  }
1368
  .meta-box-sortables-wpec .postbox:hover .handlediv {
1369
- background: transparent url(../../images/menu-bits.gif) no-repeat scroll 0% -111px;
1370
  }
1371
  /* Main Flora Style Sheet for jQuery UI ui-datepicker */
1372
  #ui-datepicker-div, .ui-datepicker-inline {
266
  width:161px;
267
  float:left;
268
  }
269
+ div.wpsc_floatleft label {
270
+ line-height: 18px;
271
+ white-space: nowrap;
272
+ }
273
 
274
  /* Sortable product styling*/
275
 
313
  border-color: #bbb;
314
  background-color: #f5f5f5;
315
  margin: -2px 0 0 -2px;
316
+ height: 50px;
317
  }
318
 
319
+ tr.product-placeholder {
320
+ border-width: 1px;
321
+ border-style: dashed;
322
+ z-index: 900;
323
+ border-color: #bbb;
324
+ background-color: #eaeaea !important;
325
+ margin: -2px 0 0 -2px;
326
+ height: 50px;
327
+ }
328
 
329
  /* Product details form styling */
330
 
1380
  display:none;
1381
  }
1382
  .meta-box-sortables-wpec .postbox:hover .handlediv {
1383
+ background: transparent url(../../wpsc-core/images/menu-bits.gif) no-repeat scroll 0% -111px;
1384
  }
1385
  /* Main Flora Style Sheet for jQuery UI ui-datepicker */
1386
  #ui-datepicker-div, .ui-datepicker-inline {
wpsc-admin/display-debug.page.php CHANGED
@@ -127,20 +127,6 @@ function wpsc_debug_page() {
127
 
128
  break;
129
 
130
-
131
-
132
- case 'test_variation_grid':
133
- $variations_processor = new nzshpcrt_variations;
134
- $product_data['id'] = 106;
135
- $output = $variations_processor->variations_grid_view( $product_data['id'] );
136
- echo "</pre>";
137
- echo $output;
138
- echo "<pre style='font-family:\"Lucida Grande\",Verdana,Arial,\"Bitstream Vera Sans\",sans-serif; font-size:8px;'>";
139
- break;
140
-
141
-
142
-
143
-
144
  case 'unicode_permalinks':
145
  $original_string = "バンプ・オブ・チキン";
146
  $sanitized_string = sanitize_title( $original_string );
@@ -266,7 +252,7 @@ function wpsc_redo_product_url_names() {
266
  $i = 0;
267
  do {
268
  $i++;
269
- echo "Proposed Name No.$i: " . ($url_name . $i) . "\n";
270
  } while ( array_search( ($url_name . $i ), $similar_names ) !== false );
271
  $url_name .= $i;
272
  }
@@ -307,7 +293,7 @@ function wpsc_recreate_product_url_names() {
307
  if ( $i > 100 ) {
308
  break;
309
  }
310
- echo "Proposed Name No.$i: " . ($url_name . $i) . "\n";
311
  } while ( array_search( ($url_name . $i ), $similar_names ) !== false );
312
  // Concatenate the first number found that wasn't taken
313
  $url_name .= $i;
127
 
128
  break;
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  case 'unicode_permalinks':
131
  $original_string = "バンプ・オブ・チキン";
132
  $sanitized_string = sanitize_title( $original_string );
252
  $i = 0;
253
  do {
254
  $i++;
255
+ echo "Proposed Name #$i: " . ($url_name . $i) . "\n";
256
  } while ( array_search( ($url_name . $i ), $similar_names ) !== false );
257
  $url_name .= $i;
258
  }
293
  if ( $i > 100 ) {
294
  break;
295
  }
296
+ echo "Proposed Name #$i: " . ($url_name . $i) . "\n";
297
  } while ( array_search( ($url_name . $i ), $similar_names ) !== false );
298
  // Concatenate the first number found that wasn't taken
299
  $url_name .= $i;
wpsc-admin/display-groups.page.php CHANGED
@@ -49,16 +49,18 @@ function wpsc_display_categories_page() {
49
  <div id="message" class="updated fade">
50
  <p>
51
  <?php
52
- if (isset($_GET['deleted']) ) {
53
  _e("Thanks, the category has been deleted", 'wpsc');
54
  remove_query_arg('deleted');
55
  unset($_GET['deleted']);
56
  }
57
 
58
 
59
- if (isset($_GET['message']) ) {
60
- if ($_GET['message'] == 'empty_term_name')
61
  _e("Please give a category name", 'wpsc');
 
 
62
  else
63
  _e("Thanks, the category has been edited", 'wpsc');
64
  unset($_GET['message']);
@@ -87,7 +89,7 @@ function wpsc_display_categories_page() {
87
 
88
  $product = get_term($_GET["category_id"], "wpsc_product_category" );
89
 
90
- $output .= "<h3 class='hndle'>".str_replace("[categorisation]", htmlentities(stripslashes($product->name)), __('You are editing the &quot;[categorisation]&quot; Category', 'wpsc'))."</h3>\n\r";
91
  echo $output;
92
  }else{
93
  echo "<h3>" . __('Add New Category', 'wpsc')."</h3>";
@@ -110,7 +112,7 @@ function wpsc_display_categories_page() {
110
  }
111
 
112
  /**
113
- * wpsc_admin_category_group_list, prints the left hand side of the edit categories page
114
  * @param nothing
115
  * @return nothing
116
  */
@@ -173,7 +175,7 @@ function wpsc_admin_display_category_row($category,$subcategory_level = 0) {
173
  </td>
174
 
175
  <td class='manage-column column-title'>
176
- <a class="row-title" href='<?php echo add_query_arg('category_id', $category->term_id); ?>'> <?php echo htmlentities(stripslashes($category->name), ENT_QUOTES, 'UTF-8'); ?></a>
177
  <div class="row-actions">
178
  <span class="edit">
179
  <a class='edit-product' style="cursor:pointer;" title="Edit this Category" href='<?php echo add_query_arg('category_id', $category->term_id); ?>'><?php _e('Edit', 'wpsc'); ?></a>
@@ -195,7 +197,7 @@ function wpsc_admin_display_category_row($category,$subcategory_level = 0) {
195
  }
196
 
197
  /*
198
- * wpsc_admin_category_group_list, prints the right hand side of the edit categories page
199
  * @param int $category_id the category ID
200
  * nothing returned
201
  */
@@ -336,6 +338,7 @@ function wpsc_admin_category_forms($category_id = null) {
336
  <h3 class="hndle"><?php _e('Shortcodes and Template Tags'); ?></h3>
337
  <div class="inside">
338
  <?php
 
339
  $product = get_term($_GET["category_id"], "wpsc_product_category" );
340
  $output .= " <span class='wpscsmall description'>Template tags and Shortcodes are used to display a particular category or group within your theme / template or any wordpress page or post.</span>\n\r";
341
  $output .="<div class='inside'>\n\r";
@@ -462,4 +465,4 @@ function wpsc_admin_category_forms($category_id = null) {
462
  }
463
 
464
 
465
- ?>
49
  <div id="message" class="updated fade">
50
  <p>
51
  <?php
52
+ if ( isset($_GET['deleted']) ) {
53
  _e("Thanks, the category has been deleted", 'wpsc');
54
  remove_query_arg('deleted');
55
  unset($_GET['deleted']);
56
  }
57
 
58
 
59
+ if ( isset($_GET['message']) ) {
60
+ if ( 'empty_term_name' == $_GET['message'] )
61
  _e("Please give a category name", 'wpsc');
62
+ elseif( 'term_exists' == $_GET['message'])
63
+ _e('A term with the name provided already exists with this parent.','wpsc');
64
  else
65
  _e("Thanks, the category has been edited", 'wpsc');
66
  unset($_GET['message']);
89
 
90
  $product = get_term($_GET["category_id"], "wpsc_product_category" );
91
 
92
+ $output .= "<h3 class='hndle'>".str_replace("[categorisation]", (stripslashes($product->name)), __('You are editing the &quot;[categorisation]&quot; Category', 'wpsc'))."</h3>\n\r";
93
  echo $output;
94
  }else{
95
  echo "<h3>" . __('Add New Category', 'wpsc')."</h3>";
112
  }
113
 
114
  /**
115
+ * wpsc_admin_category_group_list, prints the right hand side of the edit categories page
116
  * @param nothing
117
  * @return nothing
118
  */
175
  </td>
176
 
177
  <td class='manage-column column-title'>
178
+ <a class="row-title" href='<?php echo add_query_arg('category_id', $category->term_id); ?>'> <?php echo (stripslashes($category->name)); ?></a>
179
  <div class="row-actions">
180
  <span class="edit">
181
  <a class='edit-product' style="cursor:pointer;" title="Edit this Category" href='<?php echo add_query_arg('category_id', $category->term_id); ?>'><?php _e('Edit', 'wpsc'); ?></a>
197
  }
198
 
199
  /*
200
+ * wpsc_admin_category_group_list, prints the left hand side of the edit categories page
201
  * @param int $category_id the category ID
202
  * nothing returned
203
  */
338
  <h3 class="hndle"><?php _e('Shortcodes and Template Tags'); ?></h3>
339
  <div class="inside">
340
  <?php
341
+ $output = '';
342
  $product = get_term($_GET["category_id"], "wpsc_product_category" );
343
  $output .= " <span class='wpscsmall description'>Template tags and Shortcodes are used to display a particular category or group within your theme / template or any wordpress page or post.</span>\n\r";
344
  $output .="<div class='inside'>\n\r";
465
  }
466
 
467
 
468
+ ?>
wpsc-admin/display-items.page.php CHANGED
@@ -27,14 +27,14 @@ function wpsc_display_edit_products_page() {
27
  $columns = array(
28
  'cb' => '<input type="checkbox" />',
29
  'image' => '',
30
- 'title' => 'Name',
31
- 'weight' => 'Weight',
32
- 'stock' => 'Stock',
33
- 'price' => 'Price',
34
- 'sale_price' => 'Sale Price',
35
- 'SKU' => 'SKU',
36
- 'categories' => 'Categories',
37
- 'featured' => 'Featured',
38
  );
39
  if ( isset( $_GET["product"] ) && $_GET["product"] != '' ) {
40
  unset( $columns["categories"] );
@@ -66,7 +66,7 @@ function wpsc_display_edit_products_page() {
66
  <?php $_SESSION['product_error_messages'] = ''; ?>
67
  <?php } ?>
68
 
69
- <?php if ( isset( $_GET['published'] ) || isset( $_GET['skipped'] ) || isset( $_GET['updated'] ) || isset( $_GET['deleted'] ) || isset( $_GET['message'] ) || isset( $_GET['duplicated'] ) ) {
70
  ?>
71
  <div id="message" class="updated fade">
72
  <p>
@@ -79,6 +79,15 @@ function wpsc_display_edit_products_page() {
79
  unset( $_GET['updated'] );
80
  }
81
 
 
 
 
 
 
 
 
 
 
82
  if ( isset( $_GET['published'] ) ) {
83
  printf( _n( '%s product updated.', '%s products updated.', $_GET['published'] ), number_format_i18n( $_GET['published'] ) );
84
  unset( $_GET['published'] );
@@ -163,7 +172,8 @@ function wpsc_display_edit_products_page() {
163
  return showNotice.warn(m);
164
  }
165
  });
166
- $('form#filt_cat').insertAfter('input#doaction').css("display", "inline")
 
167
  });
168
  })(jQuery);
169
  /* ]]> */
@@ -281,7 +291,6 @@ function wpsc_display_edit_products_page() {
281
  $page = null;
282
  // Justin Sainton - 5.11.2010 - Re-included these variables from 3.7.6.1, as they appear to have been removed. Necessary for pagination. Also re-wrote query for new table structure.
283
  $itempp = 20;
284
-
285
  if ( isset( $_POST['product'] ) && (is_numeric( $_POST['product'] )) )
286
  $parent_product = absint( $_POST['product'] );
287
 
@@ -304,13 +313,31 @@ function wpsc_display_edit_products_page() {
304
  $page = 1;
305
  }
306
  $start = (int)($page * $itempp) - $itempp;
307
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  $query = array(
309
  'post_type' => 'wpsc-product',
310
  'post_parent' => 0,
311
  'orderby' => 'menu_order post_title',
312
  'order' => "ASC",
313
- 'post_status' => 'published inherit',
314
  'posts_per_page' => $itempp,
315
  'offset' => $start
316
  );
@@ -373,27 +400,44 @@ function wpsc_display_edit_products_page() {
373
  </div>
374
  </form>
375
  <form id="posts-filter" action="admin.php?page=wpsc-edit-products" method="post">
 
 
 
 
 
 
 
 
 
376
  <div class="productnav">
377
  <div class="alignleft actions">
378
 
379
  <select id="bulkaction" name="bulkAction">
380
  <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
 
381
  <option value="publish"><?php _e( 'Publish', 'wpsc' ); ?></option>
382
  <option value="unpublish"><?php _e( 'Unpublish', 'wpsc' ); ?></option>
383
  <?php if ( $is_trash ) { ?>
384
  <option value="untrash"><?php _e( 'Restore' ); ?></option>
385
- <?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?>
386
  <option value="delete"><?php _e( 'Delete Permanently' ); ?></option>
387
- <?php } else { ?>
388
  <option value="trash"><?php _e( 'Move to Trash' ); ?></option>
389
- <?php } ?>
390
 
391
 
392
  </select>
 
 
 
 
 
 
393
  <input type='hidden' name='wpsc_admin_action' value='bulk_modify' />
394
  <input type="submit" value="<?php _e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" />
395
  <?php wp_nonce_field( 'bulk-products', 'wpsc-bulk-products' ); ?>
396
  </div>
 
397
 
398
  </div>
399
 
@@ -437,17 +481,21 @@ function wpsc_display_edit_products_page() {
437
  function wpsc_admin_category_dropdown() {
438
  global $wpdb, $category_data;
439
  $siteurl = get_option( 'siteurl' );
440
- $category_slug = 0;
 
441
  if ( isset( $_POST['category'] ) )
442
  $category_slug = $_POST['category'];
443
 
 
 
 
444
  $url = urlencode( remove_query_arg( array( 'product_id', 'category_id' ) ) );
445
 
446
- $options = "<option value=''>" . __( 'View All Categories', 'wpsc' ) . "</option>\r\n";
447
 
448
  $options .= wpsc_list_categories( 'wpsc_admin_category_options', $category_slug );
449
-
450
- $concat = "<input type='hidden' name='page' value='{$_POST['page']}' />\r\n";
451
  $concat .= "<select name='category' id='category_select'>" . $options . "</select>\r\n";
452
  $concat .= "<input type='submit' value='Filter' class='button-secondary action' id='post-query-submit' />\r\n";
453
  return $concat;
@@ -474,6 +522,18 @@ function wpsc_admin_category_options( $category, $subcategory_level = 0, $catego
474
 
475
  return $output;
476
  }
 
 
 
 
 
 
 
 
 
 
 
 
477
 
478
  /**
479
  * wpsc_update_featured_products function.
27
  $columns = array(
28
  'cb' => '<input type="checkbox" />',
29
  'image' => '',
30
+ 'title' => __('Name'),
31
+ 'weight' => __('Weight'),
32
+ 'stock' => __('Stock'),
33
+ 'price' => __('Price'),
34
+ 'sale_price' => __('Sale Price'),
35
+ 'SKU' => __('SKU'),
36
+ 'categories' => __('Categories'),
37
+ 'featured' => __('Featured'),
38
  );
39
  if ( isset( $_GET["product"] ) && $_GET["product"] != '' ) {
40
  unset( $columns["categories"] );
66
  <?php $_SESSION['product_error_messages'] = ''; ?>
67
  <?php } ?>
68
 
69
+ <?php if ( isset( $_GET['addedgroup'] ) || isset( $_GET['published'] ) || isset( $_GET['skipped'] ) || isset( $_GET['updated'] ) || isset( $_GET['deleted'] ) || isset( $_GET['message'] ) || isset( $_GET['duplicated'] ) ) {
70
  ?>
71
  <div id="message" class="updated fade">
72
  <p>
79
  unset( $_GET['updated'] );
80
  }
81
 
82
+ if ( isset( $_GET['addedgroup'] ) ) {
83
+ if(is_int($_GET['addedgroup']) && $_GET['addedgroup'] > 0){
84
+ printf( _n( '%s product updated.', '%s products updated.', $_GET['addedgroup'] ), number_format_i18n( $_GET['addedgroup'] ) );
85
+ }else{
86
+ printf( _n( 'Invalid Category Selected.', 'Invalid Category Selected.' ) );
87
+ }
88
+ unset( $_GET['addedgroup'] );
89
+ }
90
+
91
  if ( isset( $_GET['published'] ) ) {
92
  printf( _n( '%s product updated.', '%s products updated.', $_GET['published'] ), number_format_i18n( $_GET['published'] ) );
93
  unset( $_GET['published'] );
172
  return showNotice.warn(m);
173
  }
174
  });
175
+ $('form#filt_cat').insertAfter('input#doaction').css("display", "inline");
176
+
177
  });
178
  })(jQuery);
179
  /* ]]> */
291
  $page = null;
292
  // Justin Sainton - 5.11.2010 - Re-included these variables from 3.7.6.1, as they appear to have been removed. Necessary for pagination. Also re-wrote query for new table structure.
293
  $itempp = 20;
 
294
  if ( isset( $_POST['product'] ) && (is_numeric( $_POST['product'] )) )
295
  $parent_product = absint( $_POST['product'] );
296
 
313
  $page = 1;
314
  }
315
  $start = (int)($page * $itempp) - $itempp;
316
+ $all_products = '';
317
+ $trash_products = '';
318
+ $draft_products = '';
319
+ if(!isset($_REQUEST['post_status']))
320
+ $post_status = '';
321
+ else
322
+ $post_status = $_REQUEST['post_status'];
323
+ if('trash' == $post_status){
324
+ $post_status = 'trash';
325
+ $trash_products = 'class="current"';
326
+ }elseif('draft' == $post_status){
327
+ $post_status = 'draft';
328
+ $draft_products = 'class="current"';
329
+
330
+ }else{
331
+ $all_products = 'class="current"';
332
+ $post_status = 'published inherit';
333
+ }
334
+
335
  $query = array(
336
  'post_type' => 'wpsc-product',
337
  'post_parent' => 0,
338
  'orderby' => 'menu_order post_title',
339
  'order' => "ASC",
340
+ 'post_status' => $post_status,
341
  'posts_per_page' => $itempp,
342
  'offset' => $start
343
  );
400
  </div>
401
  </form>
402
  <form id="posts-filter" action="admin.php?page=wpsc-edit-products" method="post">
403
+ <ul class='subsubsub'>
404
+ <li><a <?php echo $all_products; ?> href='<?php echo add_query_arg('post_status','all'); ?>' title='View All Products'><?php _e('All','wpsc'); ?></a></li>
405
+ <li> | </li>
406
+ <li><a <?php echo $draft_products; ?> href='<?php echo add_query_arg('post_status','draft'); ?>' title='View Draft Products'><?php _e('Draft','wpsc'); ?></a></li>
407
+ <li> | </li>
408
+ <li><a <?php echo $trash_products; ?> href='<?php echo add_query_arg('post_status','trash'); ?>' title='View Trashed Products'><?php _e('Trash','wpsc'); ?></a></li>
409
+ </ul>
410
+ <br />
411
+ <br />
412
  <div class="productnav">
413
  <div class="alignleft actions">
414
 
415
  <select id="bulkaction" name="bulkAction">
416
  <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
417
+ <option value="addgroup"><?php _e( 'Add To Group' ); ?></option>
418
  <option value="publish"><?php _e( 'Publish', 'wpsc' ); ?></option>
419
  <option value="unpublish"><?php _e( 'Unpublish', 'wpsc' ); ?></option>
420
  <?php if ( $is_trash ) { ?>
421
  <option value="untrash"><?php _e( 'Restore' ); ?></option>
422
+ <?php } ?>
423
  <option value="delete"><?php _e( 'Delete Permanently' ); ?></option>
424
+
425
  <option value="trash"><?php _e( 'Move to Trash' ); ?></option>
426
+
427
 
428
 
429
  </select>
430
+ <?php
431
+ $options = "<option selected='selected' value=''>" . __( 'Select a Category', 'wpsc' ) . "</option>\r\n";
432
+ $options .= wpsc_list_categories( 'wpsc_admin_category_options_byid' );
433
+ echo "<select name='category' id='category_select'>" . $options . "</select>\r\n";
434
+ ?>
435
+
436
  <input type='hidden' name='wpsc_admin_action' value='bulk_modify' />
437
  <input type="submit" value="<?php _e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" />
438
  <?php wp_nonce_field( 'bulk-products', 'wpsc-bulk-products' ); ?>
439
  </div>
440
+
441
 
442
  </div>
443
 
481
  function wpsc_admin_category_dropdown() {
482
  global $wpdb, $category_data;
483
  $siteurl = get_option( 'siteurl' );
484
+ $category_slug = '';
485
+ $concat = '';
486
  if ( isset( $_POST['category'] ) )
487
  $category_slug = $_POST['category'];
488
 
489
+ $selected ='';
490
+ if(empty($category_slug))
491
+ $selected = 'selected="selected"';
492
  $url = urlencode( remove_query_arg( array( 'product_id', 'category_id' ) ) );
493
 
494
+ $options = "<option {$selected} value=''>" . __( 'View All Categories', 'wpsc' ) . "</option>\r\n";
495
 
496
  $options .= wpsc_list_categories( 'wpsc_admin_category_options', $category_slug );
497
+ if(isset($_POST['page']))
498
+ $concat .= "<input type='hidden' name='page' value='{$_POST['page']}' />\r\n";
499
  $concat .= "<select name='category' id='category_select'>" . $options . "</select>\r\n";
500
  $concat .= "<input type='submit' value='Filter' class='button-secondary action' id='post-query-submit' />\r\n";
501
  return $concat;
522
 
523
  return $output;
524
  }
525
+ /*
526
+ * Displays the category forms for adding and editing products
527
+ * Recurses to generate the branched view for subcategories
528
+ */
529
+
530
+ function wpsc_admin_category_options_byid( $category, $subcategory_level = 0 ) {
531
+
532
+
533
+ $output = "<option value='{$category->term_id}'>" . str_repeat( "-", $subcategory_level ) . stripslashes( $category->name ) . "</option>\n";
534
+
535
+ return $output;
536
+ }
537
 
538
  /**
539
  * wpsc_update_featured_products function.
wpsc-admin/display-options-settings.page.php CHANGED
@@ -4,8 +4,10 @@
4
  */
5
 
6
  // Clear the previously selected shipping form session variable if you are not on the shipping page
7
- if ( (!isset( $_GET['tab'] ) || $_GET['tab'] != 'shipping' ) )
8
- $_SESSION['previous_shipping_name'] = '';
 
 
9
 
10
  function wpsc_display_settings_page() { ?>
11
 
4
  */
5
 
6
  // Clear the previously selected shipping form session variable if you are not on the shipping page
7
+ if ( isset( $_GET['tab'] ) )
8
+ if( $_GET['tab'] == 'shipping' )
9
+ if( isset( $_GET['shipping_module'] ) )
10
+ $_SESSION['previous_shipping_name'] = $_GET['shipping_module'];
11
 
12
  function wpsc_display_settings_page() { ?>
13
 
wpsc-admin/includes/display-items-functions.php CHANGED
@@ -5,8 +5,6 @@
5
  * @package wp-e-commerce
6
  * @since 3.7
7
  */
8
- //$closed_postboxes = (array)get_user_meta( $current_user->ID, 'editproduct');
9
- //$variations_processor = new nzshpcrt_variations;
10
 
11
  global $wpsc_product_defaults;
12
  $wpsc_product_defaults = array(
@@ -38,6 +36,8 @@ $wpsc_product_defaults = array(
38
  'meta' =>
39
  array(
40
  'external_link' => NULL,
 
 
41
  'merchant_notes' => NULL,
42
  'sku' => NULL,
43
  'engrave' => '0',
@@ -316,6 +316,7 @@ function wpsc_product_basic_details_form( &$product_data ) {
316
  "advanced" => array(
317
  "wpsc_product_shipping_forms",
318
  "wpsc_product_variation_forms",
 
319
  "wpsc_product_advanced_forms"
320
  ),
321
  "side" => array(
@@ -331,6 +332,7 @@ function wpsc_product_basic_details_form( &$product_data ) {
331
  "wpsc_product_shipping_forms" => 1,
332
  "wpsc_product_tag_forms" => 1,
333
  "wpsc_product_variation_forms" => 1,
 
334
  "wpsc_product_advanced_forms" => 1,
335
  "wpsc_product_category_and_tag_forms" => 1,
336
  "wpsc_price_control_forms" => 1,
@@ -343,6 +345,7 @@ function wpsc_product_basic_details_form( &$product_data ) {
343
  "wpsc_product_shipping_forms" => 1,
344
  "wpsc_product_tag_forms" => 1,
345
  "wpsc_product_variation_forms" => 1,
 
346
  "wpsc_product_advanced_forms" => 1,
347
  "wpsc_product_category_and_tag_forms" => 1,
348
  "wpsc_price_control_forms" => 1,
@@ -512,7 +515,8 @@ function wpsc_product_basic_details_form( &$product_data ) {
512
  </div>
513
  <div id="advanced-sortables" class="meta-box-sortables-wpec ui-sortable">
514
  <div class="postbox">
515
- <h3><?php _e( 'Additional Description', 'wpsc' ); ?></h3>
 
516
  <div class="inside">
517
 
518
  <textarea name='additional_description' id='additional_description' cols='40' rows='5' ><?php echo stripslashes( $product_data['additional_description'] ); ?></textarea>
@@ -651,13 +655,20 @@ function wpsc_price_control_forms($product_data){
651
 
652
  <h3 class='hndle'><?php _e( 'Price Control', 'wpsc' ); ?></h3>
653
  <div class="inside">
 
 
 
 
 
 
 
654
  <div class='wpsc_floatleft' style="width:85px;">
655
- <?php _e( 'Price', 'wpsc' ); ?> :<br />
656
  <input type='text' class='text' size='10' name='meta[_wpsc_price]' value='<?php echo number_format( $product_data['meta']['_wpsc_price'],2,'.','' ); ?>' />
657
  </div>
658
  <div class='wpsc_floatleft' style='display:<?php if ( ($product_data['special'] == 1) ? 'block' : 'none'
659
- ); ?>; width:85px;; margin-left:30px;'>
660
- <label for='add_form_special'><?php _e( 'Sale Price :', 'wpsc' ); ?></label>
661
  <div id='add_special'>
662
  <input type='text' size='10' value='<?php echo number_format( $product_data['meta']['_wpsc_special_price'], 2,'.','' ); ?>' name='meta[_wpsc_special_price]' />
663
  </div>
@@ -744,6 +755,7 @@ function wpsc_price_control_forms($product_data){
744
  </tr>
745
  </table>
746
  </div>
 
747
  </div>
748
  </div>
749
  <?php
@@ -777,8 +789,14 @@ function wpsc_stock_control_forms( $product_data='' ) {
777
  } else { ?>
778
  <div class='edit_stock' style='display: none;'><?php
779
  } ?>
 
 
 
 
 
780
  <label for="stock_limit_quantity"><?php _e( 'Quantity:', 'wpsc' ); ?></label>
781
  <input type='text' id="stock_limit_quantity" name='meta[_wpsc_stock]' size='3' value='<?php echo $product_data['meta']['_wpsc_stock']; ?>' class='stock_limit_quantity' />
 
782
  <div class='unpublish_when_none_left'>
783
  <input type='checkbox' id="inform_when_oos" name='meta[_wpsc_product_metadata][unpublish_when_none_left]' class='inform_when_oos'<?php if( $product_meta['unpublish_when_none_left'] == 1 ) echo ' checked="checked"'; ?> />
784
  <label for="inform_when_oos"><?php _e( 'Notify site owner and unpublish this Product if stock runs out', 'wpsc' ); ?></label>
@@ -943,7 +961,7 @@ function wpsc_product_variation_forms( $product_data = '' ) {
943
  add_filter( 'posts_request', 'wpsc_edit_variations_request_sql' );
944
  ?>
945
 
946
- <p><?php _e( 'Check or uncheck variation boxes and then click Update Variations to add or remove variations.' ) ?></p>
947
  <table class="widefat page" id='wpsc_product_list' cellspacing="0">
948
  <thead>
949
  <tr>
@@ -960,7 +978,7 @@ function wpsc_product_variation_forms( $product_data = '' ) {
960
  <tbody>
961
  <?php
962
  $wp_query = new WP_Query( $query );
963
-
964
  if ( !isset( $parent_product_data ) )
965
  $parent_product_data = null;
966
 
@@ -1368,7 +1386,7 @@ function wpsc_product_advanced_forms( $product_data='' ) {
1368
  if ( $product_data == 'empty' )
1369
  $display = "style='display:none;'";
1370
 
1371
- $output .= "<div id='wpsc_product_advanced_forms' class='postbox " . ((array_search( 'wpsc_product_advanced_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : '') . "' " . ((array_search( 'wpsc_product_advanced_forms', $product_data['hidden_postboxes'] ) !== false) ? 'style="display: none;"' : '') . "><div class=\"handlediv\" title=\"Click to toggle\"><br></div>";
1372
 
1373
  $output .= "<h3 class='hndle'>";
1374
  $output .= __( 'Advanced Options', 'wpsc' );
@@ -1456,21 +1474,6 @@ function wpsc_product_advanced_forms( $product_data='' ) {
1456
  $output .= ob_get_contents();
1457
  ob_end_clean();
1458
 
1459
- $output .= "
1460
- <tr>
1461
- <td class='itemfirstcol' colspan='2'><br />
1462
- <strong>" . __( 'Off Site Product Link', 'wpsc' ) . ":</strong><br />
1463
- <small>" . __( 'If this Product is for sale on another website enter the link here. For instance if your Product is an MP3 file for sale on itunes you could put the link here. This option over rides the buy now and add to cart links and takes you to the site linked here.', 'wpsc' ) . "</small><br /><br />
1464
- <label for='external_link'>" . __( 'External Link', 'wpsc' ) . "</label>:<br />
1465
- <input type='text' class='text' name='meta[_wpsc_product_metadata][external_link]' value='";
1466
-
1467
- if ( isset( $product_meta['external_link'] ) )
1468
- $output .= $product_meta['external_link'];
1469
-
1470
- $output .= "' id='external_link' size='40' />
1471
- </td>
1472
- </tr>";
1473
-
1474
  //if (get_option('wpsc_enable_comments') == 1) {
1475
  $output .= "
1476
  <tr>
@@ -1492,6 +1495,57 @@ function wpsc_product_advanced_forms( $product_data='' ) {
1492
  return $output;
1493
  }
1494
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1495
  function wpsc_product_image_forms( $product_data = '' ) {
1496
  global $closed_postboxes;
1497
 
@@ -1545,17 +1599,6 @@ function wpsc_product_download_forms( $product_data='' ) {
1545
  $output .= "<input type='file' name='file' value='' /><br />" . __( 'Max Upload Size', 'wpsc' ) . " : <span>" . $upload_max . "</span><br /><br />";
1546
  $output .= "<h4>" . __( '<a href="admin.php?wpsc_admin_action=product_files_existing&product_id=' . $product_data['id'] . '" class="thickbox" title="Select all downloadable files for ' . $product_data['name'] . '">'.__("Select from existing files").'</a>', 'wpsc' ) . "</h4>";
1547
 
1548
- if ( isset( $product_data['file'] ) && $product_data['file'] > 0 ) {
1549
- $output .= __( 'Preview File', 'wpsc' ) . ": ";
1550
-
1551
- $output .= "<a class='admin_download' href='index.php?admin_preview=true&product_id=" . $product_data['id'] . "' ><img align='absmiddle' src='" . WPSC_CORE_IMAGES_URL . "/download.gif' alt='' title='' /><span>" . __( 'Click to download', 'wpsc' ) . "</span></a>";
1552
-
1553
- $file_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PRODUCT_FILES . "` WHERE `id`='" . $product_data['file'] . "' LIMIT 1", ARRAY_A );
1554
- if ( ($file_data != null) && (function_exists( 'listen_button' )) ) {
1555
- $output .= "" . listen_button( $file_data['idhash'], $file_data['id'] ) . "<br style='clear: both;' /><br />";
1556
- }
1557
- }
1558
-
1559
  if ( function_exists( "make_mp3_preview" ) || function_exists( "wpsc_media_player" ) ) {
1560
 
1561
  $output .= "<br />";
@@ -1649,121 +1692,9 @@ function edit_multiple_image_gallery( $product_data ) {
1649
 
1650
  if ( has_post_thumbnail( $product_data['id'] ) )
1651
  echo get_the_post_thumbnail( $product_data['id'], 'admin-product-thumbnails' );
1652
-
1653
- /*
1654
- if($attached_images != null) {
1655
- foreach($attached_images as $image) {
1656
- $image_meta = get_post_meta($image->ID, '');
1657
- foreach($image_meta as $meta_name => $meta_value) {
1658
- $image_meta[$meta_name] = maybe_unserialize(array_pop($meta_value));
1659
- }
1660
-
1661
- if(function_exists("getimagesize")) {
1662
- // $num++;
1663
- $image_url = "index.php?wpsc_action=scale_image&amp;attachment_id={$image->ID}&amp;width=60&amp;height=60";
1664
- ?>
1665
- <li id="product_image_<?php echo $image->ID; ?>" class='gallery_image'>
1666
- <input type='hidden' class='image-id' name='gallery_image_id[]' value='<?php echo $image->ID; ?>' />
1667
- <div class='previewimage' id='gallery_image_<?php echo $image->ID; ?>'>
1668
- <a id='extra_preview_link_<?php echo $image->ID; ?>' onclick='return false;' href='' rel='product_extra_image_<?php echo $image->ID; ?>' >
1669
- <img class='previewimage' src='<?php echo $image_url; ?>' alt='<?php _e('Preview', 'wpsc'); ?>' title='<?php _e('Preview', 'wpsc'); ?>' /><br />
1670
- </a>
1671
- <?php //echo wpsc_main_product_image_menu($product_data['id']); ?>
1672
- </div>
1673
- </li>
1674
- <?php
1675
- }
1676
- }
1677
- }
1678
- */
1679
- /*
1680
- $main_image = $wpdb->get_row("SELECT `images`.*
1681
- FROM `".WPSC_TABLE_PRODUCT_IMAGES."` AS `images`
1682
- JOIN `".WPSC_TABLE_PRODUCT_LIST."` AS `product`
1683
- ON `product`.`image` = `images`.`id`
1684
- WHERE `product`.`id` = '{$product_data['id']}'
1685
- LIMIT 1", ARRAY_A);
1686
- */
1687
  }
1688
  }
1689
 
1690
- /*
1691
- function wpsc_main_product_image_menu($product_id) {
1692
- global $wpdb;
1693
- $thumbnail_state = 0;
1694
- if($product_id > 0)
1695
- {
1696
- //$main_image = $wpdb->get_row("SELECT `images`.*, `product`.`thumbnail_state` FROM `".WPSC_TABLE_PRODUCT_IMAGES."` AS `images` JOIN `".WPSC_TABLE_PRODUCT_LIST."` AS `product` ON `product`.`image` = `images`.`id` WHERE `product`.`id` = '{$product_id}' LIMIT 1", ARRAY_A);
1697
- $thumbnail_state = $main_image['thumbnail_state'];
1698
- } else {
1699
- $thumbnail_state = 1;
1700
- }
1701
-
1702
- $sendback = wp_get_referer();
1703
- $presentation_link = add_query_arg('page','wpsc-settings', $sendback);
1704
- $presentation_link = add_query_arg('tab','presentation#thumb_settings', $presentation_link);
1705
- $thumbnail_image_height = get_product_meta($product_id, 'thumbnail_height');
1706
- $thumbnail_image_width = get_product_meta($product_id, 'thumbnail_width');
1707
-
1708
-
1709
-
1710
- // echo $thumbnail_image_height;
1711
- // echo "|";
1712
- // echo $thumbnail_image_width;
1713
- ob_start();
1714
- ?>
1715
- <div class='image_settings_box'>
1716
- <div class='upper_settings_box'>
1717
- <div class='upper_image'><img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/pencil.png' alt='' /></div>
1718
- <div class='upper_txt'><?php _e('Thumbnail Settings'); ?><a class='closeimagesettings'>X</a></div>
1719
- </div>
1720
-
1721
- <div class='lower_settings_box'>
1722
- <input type='hidden' id='current_thumbnail_image' name='current_thumbnail_image' value='S' />
1723
- <ul>
1724
-
1725
- <li>
1726
- <input type='radio' name='gallery_resize' value='1' id='gallery_resize1' class='image_resize' onclick='image_resize_extra_forms(this)' /> <label for='gallery_resize1'><?php _e('use default size', 'wpsc'); ?>(<a href='<?php echo $presentation_link; ?>' title='<?php _e('This is set on the Settings Page', 'wpsc'); ?>'><?php echo get_option('product_image_height'); ?>&times;<?php echo get_option('product_image_width'); ?>px</a>)
1727
- </label>
1728
-
1729
- </li>
1730
-
1731
- <li>
1732
- <input type='radio' <?php echo (($thumbnail_state != 2) ? "checked='checked'" : "") ;?> name='gallery_resize' value='0' id='gallery_resize0' class='image_resize' onclick='image_resize_extra_forms(this)' /> <label for='gallery_resize0'> <?php _e('do not resize thumbnail image', 'wpsc'); ?></label><br />
1733
- </li>
1734
-
1735
- <li>
1736
- <input type='radio' <?php echo (($thumbnail_state == 2) ? "checked='checked'" : "") ;?> name='gallery_resize' value='2' id='gallery_resize2' class='image_resize' onclick='image_resize_extra_forms(this)' /> <label for='gallery_resize2'><?php _e('use specific size', 'wpsc'); ?> </label>
1737
- <div class='heightWidth image_resize_extra_forms' <?php echo (($thumbnail_state == 2) ? "style='display: block;'" : "") ;?>>
1738
- <input id='gallery_image_width' type='text' size='4' name='gallery_width' value='<?php echo $thumbnail_image_width; ?>' /><label for='gallery_image_width'><?php _e('px width', 'wpsc'); ?></label>
1739
- <input id='gallery_image_height' type='text' size='4' name='gallery_height' value='<?php echo $thumbnail_image_height; ?>' /><label for='gallery_image_height'><?php _e('px height', 'wpsc'); ?> </label>
1740
- </div>
1741
- </li>
1742
-
1743
- <li>
1744
- <input type='radio' name='gallery_resize' value='3' id='gallery_resize3' class='image_resize' onclick='image_resize_extra_forms(this)' /> <label for='gallery_resize3'> <?php _e('use separate thumbnail', 'wpsc'); ?></label><br />
1745
- <div class='browseThumb image_resize_extra_forms'>
1746
- <input type='file' name='gallery_thumbnailImage' size='15' value='' />
1747
- </div>
1748
- </li>
1749
- <li>
1750
- <a href='<?php echo htmlentities("admin.php?wpsc_admin_action=crop_image&imagename=".$main_image['image']."&imgheight=".$image_data[1]."&imgwidth=".$image_data[0]."&width=630&height=500&product_id=".$product_id); ?>' title='Crop Image' class='thickbox'>Crop This Image Using jCrop</a>
1751
-
1752
- </li>
1753
- <li>
1754
- <a href='#' class='delete_primary_image delete_button'>Delete this Image</a>
1755
- </li>
1756
-
1757
- </ul>
1758
- </div>
1759
- </div>
1760
- <a class='editButton'>Edit <img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/pencil.png' alt='' /></a>
1761
- <?php
1762
- $output = ob_get_contents();
1763
- ob_end_clean();
1764
- return $output;
1765
- } */
1766
-
1767
  /**
1768
  * Displays the category forms for adding and editing Products
1769
  * Recurses to generate the branched view for subcategories
5
  * @package wp-e-commerce
6
  * @since 3.7
7
  */
 
 
8
 
9
  global $wpsc_product_defaults;
10
  $wpsc_product_defaults = array(
36
  'meta' =>
37
  array(
38
  'external_link' => NULL,
39
+ 'external_link_text' => NULL,
40
+ 'external_link_target' => NULL,
41
  'merchant_notes' => NULL,
42
  'sku' => NULL,
43
  'engrave' => '0',
316
  "advanced" => array(
317
  "wpsc_product_shipping_forms",
318
  "wpsc_product_variation_forms",
319
+ "wpsc_product_external_link_forms",
320
  "wpsc_product_advanced_forms"
321
  ),
322
  "side" => array(
332
  "wpsc_product_shipping_forms" => 1,
333
  "wpsc_product_tag_forms" => 1,
334
  "wpsc_product_variation_forms" => 1,
335
+ "wpsc_product_external_link_forms" => 1,
336
  "wpsc_product_advanced_forms" => 1,
337
  "wpsc_product_category_and_tag_forms" => 1,
338
  "wpsc_price_control_forms" => 1,
345
  "wpsc_product_shipping_forms" => 1,
346
  "wpsc_product_tag_forms" => 1,
347
  "wpsc_product_variation_forms" => 1,
348
+ "wpsc_product_external_link_forms" => 1,
349
  "wpsc_product_advanced_forms" => 1,
350
  "wpsc_product_category_and_tag_forms" => 1,
351
  "wpsc_price_control_forms" => 1,
515
  </div>
516
  <div id="advanced-sortables" class="meta-box-sortables-wpec ui-sortable">
517
  <div class="postbox">
518
+ <div class="handlediv" title="Click to toggle"><br /></div>
519
+ <h3 class='hndle'><?php _e( 'Additional Description', 'wpsc' ); ?></h3>
520
  <div class="inside">
521
 
522
  <textarea name='additional_description' id='additional_description' cols='40' rows='5' ><?php echo stripslashes( $product_data['additional_description'] ); ?></textarea>
655
 
656
  <h3 class='hndle'><?php _e( 'Price Control', 'wpsc' ); ?></h3>
657
  <div class="inside">
658
+ <?php /* Check product if a product has variations */ ?>
659
+ <?php if( wpsc_product_has_children($product_data['id']) ) : ?>
660
+ <?php $price = wpsc_product_variation_price_available($product_data['id']); ?>
661
+ <p><?php printf( __( 'This Product has variations, to edit the price please use the %1s Variation Controls %2s below.' , 'wpsc' ), '<a href="#variation_control">','</a>' ); ?></p>
662
+ <p><?php printf( __( 'Price: %s and above.' ,'wpsc' ) , $price ); ?></p>
663
+ <?php else: ?>
664
+
665
  <div class='wpsc_floatleft' style="width:85px;">
666
+ <label><?php _e( 'Price', 'wpsc' ); ?>:</label><br />
667
  <input type='text' class='text' size='10' name='meta[_wpsc_price]' value='<?php echo number_format( $product_data['meta']['_wpsc_price'],2,'.','' ); ?>' />
668
  </div>
669
  <div class='wpsc_floatleft' style='display:<?php if ( ($product_data['special'] == 1) ? 'block' : 'none'
670
+ ); ?>; width:85px; margin-left:30px;'>
671
+ <label for='add_form_special'><?php _e( 'Sale Price', 'wpsc' ); ?>:</label>
672
  <div id='add_special'>
673
  <input type='text' size='10' value='<?php echo number_format( $product_data['meta']['_wpsc_special_price'], 2,'.','' ); ?>' name='meta[_wpsc_special_price]' />
674
  </div>
755
  </tr>
756
  </table>
757
  </div>
758
+ <?php endif; ?>
759
  </div>
760
  </div>
761
  <?php
789
  } else { ?>
790
  <div class='edit_stock' style='display: none;'><?php
791
  } ?>
792
+ <?php if( wpsc_product_has_children($product_data['id']) ) : ?>
793
+ <?php $stock = wpsc_variations_stock_remaining($product_data['id']); ?>
794
+ <p><?php _e( 'This Product has variations, to edit the quantity please use the Variation Controls below.' , 'wpsc' ); ?></p>
795
+ <p><?php printf(_n("%s variant item in stock.", "%s variant items in stock.", $stock), $stock); ?></p>
796
+ <?php else: ?>
797
  <label for="stock_limit_quantity"><?php _e( 'Quantity:', 'wpsc' ); ?></label>
798
  <input type='text' id="stock_limit_quantity" name='meta[_wpsc_stock]' size='3' value='<?php echo $product_data['meta']['_wpsc_stock']; ?>' class='stock_limit_quantity' />
799
+ <?php endif; ?>
800
  <div class='unpublish_when_none_left'>
801
  <input type='checkbox' id="inform_when_oos" name='meta[_wpsc_product_metadata][unpublish_when_none_left]' class='inform_when_oos'<?php if( $product_meta['unpublish_when_none_left'] == 1 ) echo ' checked="checked"'; ?> />
802
  <label for="inform_when_oos"><?php _e( 'Notify site owner and unpublish this Product if stock runs out', 'wpsc' ); ?></label>
961
  add_filter( 'posts_request', 'wpsc_edit_variations_request_sql' );
962
  ?>
963
 
964
+ <p><a name='variation_control'>&nbsp;</a><?php _e( 'Check or uncheck variation boxes and then click Update Variations to add or remove variations.' ) ?></p>
965
  <table class="widefat page" id='wpsc_product_list' cellspacing="0">
966
  <thead>
967
  <tr>
978
  <tbody>
979
  <?php
980
  $wp_query = new WP_Query( $query );
981
+
982
  if ( !isset( $parent_product_data ) )
983
  $parent_product_data = null;
984
 
1386
  if ( $product_data == 'empty' )
1387
  $display = "style='display:none;'";
1388
 
1389
+ $output .= "<div id='wpsc_product_advanced_forms' class='postbox " . ((array_search( 'wpsc_product_advanced_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : '') . "' " . ((array_search( 'wpsc_product_advanced_forms', $product_data['hidden_postboxes'] ) !== false) ? 'style="display: none;"' : '') . "><div class=\"handlediv\" title=\"Click to toggle\"><br /></div>";
1390
 
1391
  $output .= "<h3 class='hndle'>";
1392
  $output .= __( 'Advanced Options', 'wpsc' );
1474
  $output .= ob_get_contents();
1475
  ob_end_clean();
1476
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1477
  //if (get_option('wpsc_enable_comments') == 1) {
1478
  $output .= "
1479
  <tr>
1495
  return $output;
1496
  }
1497
 
1498
+ function wpsc_product_external_link_forms( $product_data = '' ) {
1499
+
1500
+ global $closed_postboxes, $wpdb;
1501
+
1502
+ $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
1503
+
1504
+ $output = '';
1505
+
1506
+ if ( $product_data == 'empty' )
1507
+ $display = "style='display:none;'";
1508
+
1509
+ // Get External Link Values
1510
+ $external_link_value = isset( $product_meta['external_link'] ) ? $product_meta['external_link'] : '';
1511
+ $external_link_text_value = isset( $product_meta['external_link_text'] ) ? $product_meta['external_link_text'] : '';
1512
+ $external_link_target_value = isset( $product_meta['external_link_target'] ) ? $product_meta['external_link_target'] : '';
1513
+ $external_link_target_value_selected[$external_link_target_value] = ' selected="selected"';
1514
+ if( !isset($external_link_target_value_selected['_self']) ) $external_link_target_value_selected['_self'] = '';
1515
+ if( !isset($external_link_target_value_selected['_blank']) ) $external_link_target_value_selected['_blank'] = '';
1516
+ $output .= "<div id='wpsc_product_external_link_forms' class='postbox " . ((array_search( 'wpsc_product_external_link_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : '') . "' " . ((array_search( 'wpsc_product_external_link_forms', $product_data['hidden_postboxes'] ) !== false) ? 'style="display: none;"' : '') . "><div class=\"handlediv\" title=\"Click to toggle\"><br></div>";
1517
+
1518
+ $output .= "<h3 class='hndle'>";
1519
+ $output .= __( 'Off Site Product Link', 'wpsc' );
1520
+ $output .= '</h3>
1521
+ <div class="inside">
1522
+ <p>' . __( 'If this product is for sale on another website enter the link here. For instance if your product is an MP3 file for sale on itunes you could put the link here. This option overrides the buy now and add to cart links and takes you to the site linked here. You can also customise the Buy Now text and choose to open the link in a new window.', 'wpsc' ) . '</p>
1523
+ <table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
1524
+ <tbody><tr class="form-field">
1525
+ <th valign="top" scope="row"><label for="external_link">' . __( 'External Link', 'wpsc' ) . '</label></th>
1526
+ <td><input type="text" name="meta[_wpsc_product_metadata][external_link]" id="external_link" value="' . $external_link_value . '" size="50" style="width: 95%"></td>
1527
+ </tr>
1528
+ <tr class="form-field">
1529
+ <th valign="top" scope="row"><label for="external_link_text">' . __( 'External Link Text', 'wpsc' ) . '</label></th>
1530
+ <td><input type="text" name="meta[_wpsc_product_metadata][external_link_text]" id="external_link_text" value="' . $external_link_text_value . '" size="50" style="width: 95%"></td>
1531
+ </tr>
1532
+ <tr class="form-field">
1533
+ <th valign="top" scope="row"><label for="external_link_target">' . __( 'External Link Target', 'wpsc' ) . '</label></th>
1534
+ <td>
1535
+ <select id="external_link_target" name="meta[_wpsc_product_metadata][external_link_target]">
1536
+ <option value="">Default (set by theme)</option>
1537
+ <option value="_self"' . $external_link_target_value_selected['_self'] . '>Open link in the same window</option>
1538
+ <option value="_blank"' . $external_link_target_value_selected['_blank'] . '>Open link in a new window</option>
1539
+ </select>
1540
+ </td>
1541
+ </tr>
1542
+ </tbody></table>
1543
+ </div></div>';
1544
+
1545
+ return $output;
1546
+
1547
+ }
1548
+
1549
  function wpsc_product_image_forms( $product_data = '' ) {
1550
  global $closed_postboxes;
1551
 
1599
  $output .= "<input type='file' name='file' value='' /><br />" . __( 'Max Upload Size', 'wpsc' ) . " : <span>" . $upload_max . "</span><br /><br />";
1600
  $output .= "<h4>" . __( '<a href="admin.php?wpsc_admin_action=product_files_existing&product_id=' . $product_data['id'] . '" class="thickbox" title="Select all downloadable files for ' . $product_data['name'] . '">'.__("Select from existing files").'</a>', 'wpsc' ) . "</h4>";
1601
 
 
 
 
 
 
 
 
 
 
 
 
1602
  if ( function_exists( "make_mp3_preview" ) || function_exists( "wpsc_media_player" ) ) {
1603
 
1604
  $output .= "<br />";
1692
 
1693
  if ( has_post_thumbnail( $product_data['id'] ) )
1694
  echo get_the_post_thumbnail( $product_data['id'], 'admin-product-thumbnails' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1695
  }
1696
  }
1697
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1698
  /**
1699
  * Displays the category forms for adding and editing Products
1700
  * Recurses to generate the branched view for subcategories
wpsc-admin/includes/product-functions.php CHANGED
@@ -13,6 +13,62 @@ function wpsc_get_max_upload_size(){
13
  return $upload_max;
14
  }
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  /**
17
  * wpsc_admin_submit_product function
18
  *
@@ -69,10 +125,9 @@ function wpsc_sanitise_product_forms($post_data = null) {
69
  $post_data['post_status'] = $product->post_status;
70
  } else {
71
  $post_data['post_status'] = 'draft';
72
-
73
  }
74
 
75
- if(isset($post_data['save']) && $product->post_status == 'inherit' && $product->post_parent == 0) {
76
  $post_data['post_status'] = 'draft';
77
  } else if(isset($post_data['publish'])) {
78
  $post_data['post_status'] = 'publish';
@@ -140,6 +195,8 @@ function wpsc_sanitise_product_forms($post_data = null) {
140
  if(!isset($post_data['meta']['_wpsc_product_metadata']['google_prohibited'])) $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = '';
141
  $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
142
  $post_data['meta']['_wpsc_product_metadata']['external_link'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link'];
 
 
143
 
144
  $post_data['meta']['_wpsc_product_metadata']['enable_comments'] = $post_data['meta']['_wpsc_product_metadata']['enable_comments'];
145
  $post_data['meta']['_wpsc_product_metadata']['merchant_notes'] = $post_data['meta']['_wpsc_product_metadata']['merchant_notes'];
@@ -285,9 +342,6 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
285
 
286
  // and the custom meta
287
  wpsc_update_custom_meta($product_id, $post_data);
288
-
289
- // and the images
290
- wpsc_update_product_images($product_id, $post_data);
291
 
292
  //and the alt currency
293
  foreach((array)$post_data['newCurrency'] as $key =>$value){
@@ -408,12 +462,13 @@ function wpsc_edit_product_variations($product_id, $post_data) {
408
 
409
  $product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
410
 
411
- $variation_sets_and_values = array_merge($variation_sets, $variation_values);
412
 
 
 
413
  wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
414
 
415
- //die('<pre>'.print_r($variation_sets_and_values, true).'</pre>');
416
-
417
  $child_product_template = array(
418
  'post_author' => $user_ID,
419
  'post_content' => $post_data['description'],
@@ -461,11 +516,11 @@ function wpsc_edit_product_variations($product_id, $post_data) {
461
  $selected_post = array_shift($selected_post);
462
 
463
  $child_product_id = wpsc_get_child_object_in_terms($product_id, $term_ids, 'wpsc-variation');
464
-
465
- // echo "<pre>".print_r($child_product_id, true)."</pre>";
466
  if($child_product_id == false) {
 
467
  if($selected_post != null) {
468
- $child_product_id = $selected_post->ID;
469
  } else {
470
  $child_product_id = wp_update_post($product_values);
471
  }
@@ -479,34 +534,36 @@ function wpsc_edit_product_variations($product_id, $post_data) {
479
  wp_set_object_terms($child_product_id, $term_slugs, 'wpsc-variation');
480
  }
481
  //JS - 7.9 - Adding loop to include meta data in child product.
482
- //die("<pre>".print_r($child_product_meta)."</pre>");
483
- foreach ($child_product_meta as $meta_key => $meta_value ) :
484
- if ($meta_key == "_wpsc_product_metadata") {
485
- update_post_meta($child_product_id, $meta_key, unserialize($meta_value[0]));
486
- } else {
487
- update_post_meta($child_product_id, $meta_key, $meta_value[0]);
488
- }
 
 
 
489
 
490
- endforeach;
491
-
492
- //Adding this to check for a price on variations. Applying the highest price, seems to make the most sense.
493
- if ( is_array ($term_ids) ) {
494
- $price = array();
495
- foreach ($term_ids as $term_id_price) {
496
- $price[] = term_id_price($term_id_price, $child_product_meta["_wpsc_price"][0]);
497
- //$price[] = $term_id_price;
498
- }
499
- rsort($price);
500
- $price = $price[0];
501
-
502
- if($price > 0) {
503
- update_post_meta($child_product_id, "_wpsc_price", $price);
504
  }
505
  }
506
  }
507
 
508
 
509
- //For reasons unknown, this code did not previously deal with variation deletions. Basically, we'll just check if any existing term associations are missing from the posted variables, delete if they are.
510
  //Get posted terms (multi-dimensional array, first level = parent var, second level = child var)
511
  $posted_term = $variations;
512
  //Get currently associated terms
@@ -530,17 +587,15 @@ function wpsc_edit_product_variations($product_id, $post_data) {
530
 
531
  $post_ids_to_delete = array();
532
  $term_ids_to_delete = array();
533
-
534
  $term_ids_to_delete = array_diff($currently_associated_vars, $posted_terms);
535
 
536
- // Whatever remains, find child products of current product with that term, in the variation taxonomy, and delete
537
-
538
  $post_ids_to_delete = wpsc_get_child_object_in_terms_var($_REQUEST["product_id"], $term_ids_to_delete, 'wpsc-variation');
539
  if(is_array($post_ids_to_delete)) {
540
  foreach($post_ids_to_delete as $object_ids) {
541
- foreach($object_ids as $object_id) {
542
- wp_delete_post($object_id);
543
- }
544
  }
545
  }
546
  }
@@ -586,7 +641,6 @@ function wpsc_update_category_associations($product_id, $categories = array()) {
586
  $categories_to_delete[$key] = absint($category_to_delete);
587
  }
588
 
589
- //exit('<pre>'.print_r($categories_to_delete, true).'</pre>');
590
 
591
  foreach($categories_to_add as $category_id) {
592
  $insert_sections[] = $wpdb->prepare("( %d, %d)", $product_id, $category_id);
@@ -746,157 +800,6 @@ function wpsc_update_custom_meta($product_id, $post_data) {
746
  }
747
  }
748
 
749
- /**
750
- * wpsc_update_product_tags function
751
- *
752
- * @param integer product ID
753
- * @param array the post data
754
- */
755
- function wpsc_update_product_images($product_id, $post_data) {
756
- global $wpdb;
757
- $uploaded_images = array();
758
-
759
- if(!isset($post_data['gallery_resize'])) $post_data['gallery_resize'] = '';
760
- if(!isset($post_data['gallery_width'])) $post_data['gallery_width'] = '';
761
- if(!isset($post_data['gallery_height'])) $post_data['gallery_height'] = '';
762
-
763
- /* Handle new image uploads here */
764
- if(isset($post_data['files']['image']['tmp_name']) && ($post_data['files']['image']['tmp_name'] != '')) {
765
- $image = wpsc_item_process_image($product_id, $post_data['files']['image']['tmp_name'], str_replace(" ", "_", $post_data['files']['image']['name']), $post_data['width'], $post_data['height'], $post_data['image_resize']);
766
-
767
- $image_action = absint($post_data['image_resize']);
768
- $image_width = $post_data['width'];
769
- $image_height = $post_data['height'];
770
-
771
- } else {
772
- $image_action = absint($post_data['gallery_resize']);
773
- $image_width = $post_data['gallery_width'];
774
- $image_height = $post_data['gallery_height'];
775
-
776
- }
777
-
778
- // exit( "<pre>".print_r($image_action, true)."</pre>");
779
- //wpsc_resize_image_thumbnail($product_id, $image_action, $image_width, $image_height);
780
- //exit( " <pre>".print_r($post_data, true)."</pre>");
781
-
782
-
783
-
784
-
785
- }
786
-
787
- /**
788
- * wpsc_resize_image_thumbnail function
789
- *
790
- * @param integer product ID
791
- * @param integer the action to perform on the image
792
- * @param integer the width of the thumbnail image
793
- * @param integer the height of the thumbnail image
794
- * @param array the custom image array from $_FILES
795
- */
796
- function wpsc_resize_image_thumbnail($product_id, $image_action= 0, $width = 0, $height = 0, $custom_image = null) {
797
- global $wpdb;
798
- $image_id = $wpdb->get_var("SELECT `image` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id` = '{$product_id}' LIMIT 1");
799
- $image = $wpdb->get_var("SELECT `image` FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `id` = '{$image_id}' LIMIT 1");
800
-
801
- // check if there is an image that is supposed to be there.
802
- if($image != '') {
803
- if(is_numeric($image)){
804
- }
805
- // check that is really there
806
- if(file_exists(WPSC_IMAGE_DIR.$image)) {
807
- // if the width or height is less than 1, set the size to the default
808
- if((($width < 1) || ($height < 1)) && ($image_action == 2)) {
809
- $image_action = 1;
810
- }
811
- switch($image_action) {
812
- case 0:
813
- if(!file_exists(WPSC_THUMBNAIL_DIR.$image)) {
814
- copy(WPSC_IMAGE_DIR.$image, WPSC_THUMBNAIL_DIR.$image);
815
- }
816
- break;
817
-
818
-
819
- case 1:
820
- // if case 1, replace the provided size with the default size
821
- $height = get_option('product_image_height');
822
- $width = get_option('product_image_width');
823
- case 2:
824
- // if case 2, use the provided size
825
- $image_input = WPSC_IMAGE_DIR . $image;
826
- $image_output = WPSC_THUMBNAIL_DIR . $image;
827
-
828
- if($width < 1) {
829
- $width = 96;
830
- }
831
- if($height < 1) {
832
- $height = 96;
833
- }
834
-
835
- image_processing($image_input, $image_output, $width, $height);
836
- update_product_meta($product_id, 'thumbnail_width', $width);
837
- update_product_meta($product_id, 'thumbnail_height', $height);
838
- break;
839
-
840
- case 3:
841
- // replacing the thumbnail with a custom image is done here
842
- $uploaded_image = null;
843
- //exit($uploaded_image);
844
- if(file_exists($_FILES['gallery_thumbnailImage']['tmp_name'])) {
845
- $uploaded_image = $_FILES['gallery_thumbnailImage']['tmp_name'];
846
- } else if(file_exists($_FILES['thumbnailImage']['tmp_name'])) {
847
- $uploaded_image = $_FILES['thumbnailImage']['tmp_name'];
848
- }
849
- if($uploaded_image !== null) {
850
-
851
- move_uploaded_file($uploaded_image, WPSC_THUMBNAIL_DIR.$image);
852
- //exit($uploaded_image);
853
-
854
- }
855
- break;
856
- }
857
-
858
- if(!file_exists(WPSC_IMAGE_DIR.$image)) {
859
- $wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_IMAGES."` SET `thumbnail_state` = '$image_action' WHERE `id`='{$product_id}' LIMIT 1");
860
- $sql = "INSERT INTO `".WPSC_TABLE_PRODUCT_IMAGES."` (`product_id`, `image`, `width`, `height`) VALUES ('{$product_id}', '{$image}', '{$width}', '{$height}' )";
861
- $wpdb->query($sql);
862
- $image_id = (int) $wpdb->insert_id;
863
- }
864
-
865
- $sql="UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `thumbnail_state` = '$image_action', `image` ='{$image_id}' WHERE `id`='{$product_id}' LIMIT 1";
866
- //exit($sql);
867
- $wpdb->query($sql);
868
- } else {
869
- //if it is not, we need to unset the associated image
870
- //$wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `image` = '' WHERE `id`='{$product_id}' LIMIT 1");
871
- //$wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_IMAGES."` (`product_id`, `image`, `width`, `height`) VALUES ('{$product_id}', '{$image}', '{$width}', '{$height}' )");
872
- }
873
- }
874
-
875
- }
876
-
877
-
878
-
879
-
880
- /**
881
- * wpsc_upload_image_thumbnail function
882
- *
883
- * @param integer product ID
884
- * @param string comma separated tags
885
- */
886
- function wpsc_upload_image_thumbnail($product_id, $product_meta) {
887
- if(($_POST['image_resize'] == 3) && ($_FILES['thumbnailImage'] != null) && file_exists($_FILES['thumbnailImage']['tmp_name'])) {
888
- $imagefield='thumbnailImage';
889
-
890
- $image=image_processing($_FILES['thumbnailImage']['tmp_name'], WPSC_THUMBNAIL_DIR.$_FILES['thumbnailImage']['name'],null,null,$imagefield);
891
- $thumbnail_image = $image;
892
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `thumbnail_image` = '".$thumbnail_image."' WHERE `id` = '".$image_data['id']."'");
893
- $stat = stat( dirname( (WPSC_THUMBNAIL_DIR.$image_data['image']) ));
894
- $perms = $stat['mode'] & 0000775;
895
- @ chmod( (WPSC_THUMBNAIL_DIR.$image_data['image']), $perms );
896
- }
897
- }
898
-
899
-
900
  /**
901
  * wpsc_item_process_file function
902
  *
@@ -993,7 +896,6 @@ function wpsc_item_reassign_file($product_id, $selected_files) {
993
  /* if we are editing, grab the current file and ID hash */
994
  if(!$selected_files) {
995
  // unlikely that anyone will ever upload a file called .none., so its the value used to signify clearing the product association
996
- //$wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `file` = '0' WHERE `id` = '$product_id' LIMIT 1");
997
  return null;
998
  }
999
 
@@ -1059,7 +961,7 @@ function wpsc_item_reassign_file($product_id, $selected_files) {
1059
  function wpsc_item_add_preview_file($product_id, $preview_file) {
1060
  global $wpdb;
1061
 
1062
- $current_file_id = $wpdb->get_var("SELECT `file` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id` = '$product_id' LIMIT 1");
1063
  $file_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='{$current_file_id}' LIMIT 1",ARRAY_A);
1064
 
1065
  if(apply_filters( 'wpsc_filter_file', $preview_file['tmp_name'] )) {
@@ -1147,5 +1049,24 @@ function wpsc_variation_combinator($variation_sets) {
1147
  }
1148
  }
1149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1150
 
1151
  ?>
13
  return $upload_max;
14
  }
15
 
16
+ /**
17
+ * wpsc_product_variation_price_available function
18
+ * Checks for the lowest price of a products variations
19
+ *
20
+ * @return $price (string) number formatted price
21
+ */
22
+ function wpsc_product_variation_price_available($product_id){
23
+ global $wpdb;
24
+ $price = $wpdb->get_var('
25
+ SELECT
26
+ `pm`.`meta_value`
27
+ FROM
28
+ `' . $wpdb->postmeta . '` `pm`
29
+ JOIN
30
+ `' . $wpdb->posts . '` `p`
31
+ ON
32
+ `pm`.`post_id` = `p`.`id`
33
+ WHERE
34
+ `p`.`post_type`= "wpsc-product"
35
+ AND
36
+ `p`.`post_parent` = ' . $product_id . '
37
+ AND
38
+ `pm`.`meta_key` = "_wpsc_price"
39
+ AND
40
+ `p`.`ID` IN (
41
+ SELECT `' . $wpdb->postmeta . '`.`post_id` FROM `' . $wpdb->postmeta . '` WHERE `meta_key` = "_wpsc_stock" AND `meta_value` != "0"
42
+ )
43
+ ORDER BY
44
+ `meta_value` ASC
45
+ LIMIT 1'
46
+ );
47
+
48
+ $price = wpsc_currency_display($price, array('display_as_html' => false));
49
+ return $price;
50
+ }
51
+
52
+ /**
53
+ * wpsc_product_has_children function
54
+ * Checks whether a product has variations or not
55
+ *
56
+ * @return boolean true if product does have variations, false otherwise
57
+ */
58
+ function wpsc_product_has_children($id){
59
+ $args = array(
60
+ 'post_parent' => $id,
61
+ 'post_type' => 'wpsc-product',
62
+ 'post_status' => 'inherit publish'
63
+ );
64
+ $children = get_children($args);
65
+ if( empty($children) )
66
+ return false;
67
+ else
68
+ return true;
69
+ }
70
+
71
+
72
  /**
73
  * wpsc_admin_submit_product function
74
  *
125
  $post_data['post_status'] = $product->post_status;
126
  } else {
127
  $post_data['post_status'] = 'draft';
 
128
  }
129
 
130
+ if(isset($post_data['save']) && $product->post_status == 'inherit' && ( $product->post_parent == 0 || $product->post_parent == $product->ID ) ) {
131
  $post_data['post_status'] = 'draft';
132
  } else if(isset($post_data['publish'])) {
133
  $post_data['post_status'] = 'publish';
195
  if(!isset($post_data['meta']['_wpsc_product_metadata']['google_prohibited'])) $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = '';
196
  $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
197
  $post_data['meta']['_wpsc_product_metadata']['external_link'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link'];
198
+ $post_data['meta']['_wpsc_product_metadata']['external_link_text'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link_text'];
199
+ $post_data['meta']['_wpsc_product_metadata']['external_link_target'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link_target'];
200
 
201
  $post_data['meta']['_wpsc_product_metadata']['enable_comments'] = $post_data['meta']['_wpsc_product_metadata']['enable_comments'];
202
  $post_data['meta']['_wpsc_product_metadata']['merchant_notes'] = $post_data['meta']['_wpsc_product_metadata']['merchant_notes'];
342
 
343
  // and the custom meta
344
  wpsc_update_custom_meta($product_id, $post_data);
 
 
 
345
 
346
  //and the alt currency
347
  foreach((array)$post_data['newCurrency'] as $key =>$value){
462
 
463
  $product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
464
 
 
465
 
466
+ $variation_sets_and_values = array_merge($variation_sets, $variation_values);
467
+ //echo 'Existing Product Terms<pre>'.print_r($product_terms,1).'</pre>';
468
  wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
469
 
470
+ //echo('Variation Sets and Values<pre>'.print_r($variation_sets_and_values, true).'</pre>');
471
+ //echo('Combinations<pre>'.print_r($combinations, true).'</pre>');
472
  $child_product_template = array(
473
  'post_author' => $user_ID,
474
  'post_content' => $post_data['description'],
516
  $selected_post = array_shift($selected_post);
517
 
518
  $child_product_id = wpsc_get_child_object_in_terms($product_id, $term_ids, 'wpsc-variation');
519
+ $already_a_variation = true;
 
520
  if($child_product_id == false) {
521
+ $already_a_variation = false;
522
  if($selected_post != null) {
523
+ $child_product_id = $selected_post->ID;
524
  } else {
525
  $child_product_id = wp_update_post($product_values);
526
  }
534
  wp_set_object_terms($child_product_id, $term_slugs, 'wpsc-variation');
535
  }
536
  //JS - 7.9 - Adding loop to include meta data in child product.
537
+ //echo("Child Product meta: <pre>".print_r($child_product_meta)."</pre>");
538
+ if(!$already_a_variation){
539
+ foreach ($child_product_meta as $meta_key => $meta_value ) :
540
+ if ($meta_key == "_wpsc_product_metadata") {
541
+ update_post_meta($child_product_id, $meta_key, unserialize($meta_value[0]));
542
+ } else {
543
+ update_post_meta($child_product_id, $meta_key, $meta_value[0]);
544
+ }
545
+
546
+ endforeach;
547
 
548
+ //Adding this to check for a price on variations. Applying the highest price, seems to make the most sense.
549
+ if ( is_array ($term_ids) ) {
550
+ $price = array();
551
+ foreach ($term_ids as $term_id_price) {
552
+ $price[] = term_id_price($term_id_price, $child_product_meta["_wpsc_price"][0]);
553
+ //$price[] = $term_id_price;
554
+ }
555
+ rsort($price);
556
+ $price = $price[0];
557
+
558
+ if($price > 0) {
559
+ update_post_meta($child_product_id, "_wpsc_price", $price);
560
+ }
 
561
  }
562
  }
563
  }
564
 
565
 
566
+ //For reasons unknown, this code did not previously deal with variation deletions. Basically, we'll just check if any existing term associations are missing from the posted variables, delete if they are.
567
  //Get posted terms (multi-dimensional array, first level = parent var, second level = child var)
568
  $posted_term = $variations;
569
  //Get currently associated terms
587
 
588
  $post_ids_to_delete = array();
589
  $term_ids_to_delete = array();
 
590
  $term_ids_to_delete = array_diff($currently_associated_vars, $posted_terms);
591
 
592
+ // Whatever remains, find child products of current product with that term, in the variation taxonomy, and delete
 
593
  $post_ids_to_delete = wpsc_get_child_object_in_terms_var($_REQUEST["product_id"], $term_ids_to_delete, 'wpsc-variation');
594
  if(is_array($post_ids_to_delete)) {
595
  foreach($post_ids_to_delete as $object_ids) {
596
+ foreach($object_ids as $object_id) {
597
+ wp_delete_post($object_id);
598
+ }
599
  }
600
  }
601
  }
641
  $categories_to_delete[$key] = absint($category_to_delete);
642
  }
643
 
 
644
 
645
  foreach($categories_to_add as $category_id) {
646
  $insert_sections[] = $wpdb->prepare("( %d, %d)", $product_id, $category_id);
800
  }
801
  }
802
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
803
  /**
804
  * wpsc_item_process_file function
805
  *
896
  /* if we are editing, grab the current file and ID hash */
897
  if(!$selected_files) {
898
  // unlikely that anyone will ever upload a file called .none., so its the value used to signify clearing the product association
 
899
  return null;
900
  }
901
 
961
  function wpsc_item_add_preview_file($product_id, $preview_file) {
962
  global $wpdb;
963
 
964
+ $current_file_id = $product_id;
965
  $file_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='{$current_file_id}' LIMIT 1",ARRAY_A);
966
 
967
  if(apply_filters( 'wpsc_filter_file', $preview_file['tmp_name'] )) {
1049
  }
1050
  }
1051
 
1052
+ function wpsc_variations_stock_remaining($product_id){
1053
+ global $wpdb;
1054
+ return $wpdb->get_var('
1055
+ SELECT
1056
+ sum(`pm`.`meta_value`)
1057
+ FROM
1058
+ `' . $wpdb->postmeta . '` `pm`
1059
+ JOIN
1060
+ `' . $wpdb->posts . '` `p`
1061
+ ON
1062
+ `pm`.`post_id` = `p`.`id`
1063
+ WHERE
1064
+ `p`.`post_type`= "wpsc-product"
1065
+ AND
1066
+ `p`.`post_parent` = ' . $product_id . '
1067
+ AND
1068
+ `pm`.`meta_key` = "_wpsc_stock"
1069
+ ');
1070
+ }
1071
 
1072
  ?>
wpsc-admin/includes/products.php CHANGED
@@ -43,6 +43,7 @@ function wpsc_admin_product_listing($parent_product = null) {
43
  */
44
  function wpsc_trashed_post_status($post_status){
45
  $post = get_post(get_the_ID());
 
46
  if('wpsc-product' == $post->post_type && 'trash' == $post->post_status && !in_array('trash', $post_status))
47
  $post_status[] = 'Trash';
48
 
43
  */
44
  function wpsc_trashed_post_status($post_status){
45
  $post = get_post(get_the_ID());
46
+ if(empty($post)) return $post_status;
47
  if('wpsc-product' == $post->post_type && 'trash' == $post->post_status && !in_array('trash', $post_status))
48
  $post_status[] = 'Trash';
49
 
wpsc-admin/includes/save-data.functions.php CHANGED
@@ -109,7 +109,6 @@ function wpsc_save_variation_set() {
109
  }
110
  }
111
  }
112
- //http://sandbox.boiling-pukeko.geek.nz/wp-admin/admin.php?wpsc_admin_action=wpsc-variation-set&delete_value=true&value_id=20&_wpnonce=c1eab6de52
113
  $sendback = remove_query_arg(array(
114
  'wpsc_admin_action',
115
  'delete_value',
@@ -172,12 +171,12 @@ function wpsc_save_category_set() {
172
  $name = $_POST['name'];
173
  $term = get_term_by('name', $name, 'wpsc_product_category', ARRAY_A);
174
 
175
- if(empty($term)) {
176
- $term = wp_insert_term( $name, 'wpsc_product_category',array('parent' => $parent_category));
177
- }
178
 
179
  if (is_wp_error($term)) {
180
- $_GET['message'] = $term->get_error_code();
 
 
181
  return;
182
  }
183
 
@@ -215,7 +214,7 @@ function wpsc_save_category_set() {
215
  }
216
  }
217
 
218
- if(($_POST['countrylist2'] != null ) && ($category_id > 0)){
219
  $AllSelected = false;
220
  $countryList = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_CURRENCY_LIST."`");
221
 
109
  }
110
  }
111
  }
 
112
  $sendback = remove_query_arg(array(
113
  'wpsc_admin_action',
114
  'delete_value',
171
  $name = $_POST['name'];
172
  $term = get_term_by('name', $name, 'wpsc_product_category', ARRAY_A);
173
 
174
+ $term = wp_insert_term( $name, 'wpsc_product_category',array('parent' => $parent_category));
 
 
175
 
176
  if (is_wp_error($term)) {
177
+ // $_GET['message'] = $term->get_error_code();
178
+ $sendback = add_query_arg('message',$term->get_error_code());
179
+ wp_redirect($sendback);
180
  return;
181
  }
182
 
214
  }
215
  }
216
 
217
+ if(isset($_POST['countrylist2']) && ($_POST['countrylist2'] != null ) && ($category_id > 0)){
218
  $AllSelected = false;
219
  $countryList = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_CURRENCY_LIST."`");
220
 
wpsc-admin/includes/settings-pages/gateway.php CHANGED
@@ -130,7 +130,8 @@ function wpsc_options_gateway() {
130
  <?php
131
  if ( !isset( $_SESSION['previous_payment_name'] ) )
132
  $_SESSION['previous_payment_name'] = "";
133
-
 
134
  $payment_data = wpsc_get_payment_form( $_SESSION['previous_payment_name'], $selected_gateway_data );
135
  ?>
136
  <h3 class='hndle'><?php echo $payment_data['name']; ?></h3>
130
  <?php
131
  if ( !isset( $_SESSION['previous_payment_name'] ) )
132
  $_SESSION['previous_payment_name'] = "";
133
+ if ( !isset( $selected_gateway_data ) )
134
+ $selected_gateway_data = "";
135
  $payment_data = wpsc_get_payment_form( $_SESSION['previous_payment_name'], $selected_gateway_data );
136
  ?>
137
  <h3 class='hndle'><?php echo $payment_data['name']; ?></h3>
wpsc-admin/includes/settings-pages/presentation.php CHANGED
@@ -279,7 +279,24 @@ function wpsc_options_presentation() {
279
  <input type='radio' value='0' name='wpsc_options[product_ratings]' id='product_ratings2' <?php echo $product_ratings2; ?> /> <label for='product_ratings2'><?php _e( 'No', 'wpsc' ); ?></label>
280
  </td>
281
  </tr>
282
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  <tr>
284
  <th scope="row">
285
  <?php _e( 'Display Fancy Purchase Notifications', 'wpsc' ); ?>:
@@ -409,12 +426,6 @@ function wpsc_options_presentation() {
409
  break;
410
  }
411
 
412
- if ( get_option( 'list_view_quantity' ) == 1 ) {
413
- $list_view_quantity_value = "checked='checked'";
414
- } else {
415
- $list_view_quantity_value = '';
416
- }
417
-
418
  if ( get_option( 'show_images_only' ) == 1 ) {
419
  $show_images_only_value = "checked='checked'";
420
  } else {
@@ -467,15 +478,10 @@ function wpsc_options_presentation() {
467
  </select>
468
  <?php
469
  if ( !function_exists( 'product_display_grid' ) ) {
470
- ?><a href='http://www.instinct.co.nz/e-commerce/shop/'><?php _e( 'Purchase unavailable options', 'wpsc' ); ?></a> <?php
471
  }
472
  ?>
473
- <div id='list_view_options' <?php if ( is_null( $product_view2 ) ) {
474
- echo "style='display:none;'";
475
- } ?> >
476
- <input type='checkbox' value='1' name='wpsc_options[list_view_quantity]' id='list_view_quantity' <?php echo $list_view_quantity_value; ?> />
477
- <label for='list_view_options'><?php _e( 'Show quantity form in list view', 'wpsc' ); ?></label>
478
- </div>
479
  <div id='grid_view_options' <?php if ( isset( $list_view_quantity_style ) )
480
  echo $list_view_quantity_style; ?> <?php if ( is_null( $product_view3 ) ) {
481
  echo "style='display:none;'";
@@ -994,7 +1000,7 @@ function wpsc_options_presentation() {
994
  </td>
995
  </tr>
996
  <tr>
997
- <th scope="row"><?php _e( 'Use Thickbox Effect for product images', 'wpsc' ); ?>:</th>
998
  <td>
999
  <?php
1000
  $show_thumbnails_thickbox = get_option( 'show_thumbnails_thickbox' );
@@ -1012,9 +1018,26 @@ function wpsc_options_presentation() {
1012
  ?>
1013
  <input type='radio' value='1' name='wpsc_options[show_thumbnails_thickbox]' id='show_thumbnails_thickbox1' <?php echo $show_thumbnails_thickbox1; ?> /> <label for='show_thumbnails_thickbox1'><?php _e( 'Yes', 'wpsc' ); ?></label> &nbsp;
1014
  <input type='radio' value='0' name='wpsc_options[show_thumbnails_thickbox]' id='show_thumbnails_thickbox2' <?php echo $show_thumbnails_thickbox2; ?> /> <label for='show_thumbnails_thickbox2'><?php _e( 'No', 'wpsc' ); ?></label><br />
1015
- <?php _e( 'Using thickbox means that when clicking on a product image, a larger version will be displayed in a "thickbox" style window. If you are using a plugin such as Shutter Reloaded, you may want to disable thickbox.', 'wpsc' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1016
  </td>
1017
  </tr>
 
1018
  <?php
1019
  if ( function_exists( 'gold_shpcrt_display_gallery' ) ) {
1020
  ?>
@@ -1052,30 +1075,7 @@ function wpsc_options_presentation() {
1052
 
1053
  </td>
1054
  </tr>
1055
- <tr>
1056
- <th scope="row">
1057
- <?php
1058
- $cropthumbs = get_option( 'wpsc_crop_thumbnails' );
1059
- $crop1 = "";
1060
- $crop2 = "";
1061
- switch ( $cropthumbs ) {
1062
- case 0:
1063
- $crop2 = "checked ='checked'";
1064
- break;
1065
-
1066
- case 1:
1067
- $crop1 = "checked ='checked'";
1068
- break;
1069
- }
1070
- ?>
1071
- <?php _e( "Crop Thumbnails?" ); ?>:
1072
- </th>
1073
- <td>
1074
- <input type='radio' value='1' name='wpsc_options[wpsc_crop_thumbnails]' id='wpsc_crop_thumbnails1' <?php echo $crop1; ?> /> <label for='crop1'><?php _e( 'Yes', 'wpsc' ); ?></label> &nbsp;
1075
- <input type='radio' value='0' name='wpsc_options[wpsc_crop_thumbnails]' id='wpsc_crop_thumbnails2' <?php echo $crop2; ?> /> <label for='crop2'><?php _e( 'No', 'wpsc' ); ?></label><br />
1076
- <?php _e( 'Choosing "Yes" means that thumbnails are cropped to exact dimensions (normally thumbnails are proportional)', 'wpsc' ); ?>
1077
- </td>
1078
- </tr>
1079
  <?php
1080
  }
1081
  ?>
279
  <input type='radio' value='0' name='wpsc_options[product_ratings]' id='product_ratings2' <?php echo $product_ratings2; ?> /> <label for='product_ratings2'><?php _e( 'No', 'wpsc' ); ?></label>
280
  </td>
281
  </tr>
282
+ <tr>
283
+ <?php
284
+ $list_view_quantity_value1 = '';
285
+ $list_view_quantity_value2 = '';
286
+ if ( get_option( 'list_view_quantity' ) == 1 )
287
+ $list_view_quantity_value1 = 'checked="checked"';
288
+ else
289
+ $list_view_quantity_value2 = 'checked="checked"';
290
+
291
+ ?>
292
+ <th score="row">
293
+ <?php _e('Show Stock Availability','wpsc'); ?>
294
+ </th>
295
+ <td>
296
+ <input type='radio' value='1' name='wpsc_options[list_view_quantity]' id='list_view_quantity1' <?php echo $list_view_quantity_value1; ?> /> <label for='list_view_quantity1'><?php _e( 'Yes', 'wpsc' ); ?></label> &nbsp;
297
+ <input type='radio' value='0' name='wpsc_options[list_view_quantity]' id='list_view_quantity2' <?php echo $list_view_quantity_value2; ?> /> <label for='list_view_quantity2'><?php _e( 'No', 'wpsc' ); ?></label> &nbsp;
298
+ </td>
299
+ </tr>
300
  <tr>
301
  <th scope="row">
302
  <?php _e( 'Display Fancy Purchase Notifications', 'wpsc' ); ?>:
426
  break;
427
  }
428
 
 
 
 
 
 
 
429
  if ( get_option( 'show_images_only' ) == 1 ) {
430
  $show_images_only_value = "checked='checked'";
431
  } else {
478
  </select>
479
  <?php
480
  if ( !function_exists( 'product_display_grid' ) ) {
481
+ ?><a href='http://getshopped.org/extend/premium-upgrades'><?php _e( 'Purchase unavailable options', 'wpsc' ); ?></a> <?php
482
  }
483
  ?>
484
+
 
 
 
 
 
485
  <div id='grid_view_options' <?php if ( isset( $list_view_quantity_style ) )
486
  echo $list_view_quantity_style; ?> <?php if ( is_null( $product_view3 ) ) {
487
  echo "style='display:none;'";
1000
  </td>
1001
  </tr>
1002
  <tr>
1003
+ <th scope="row"><?php _e( 'Use Lightbox Effect for product images', 'wpsc' ); ?>:</th>
1004
  <td>
1005
  <?php
1006
  $show_thumbnails_thickbox = get_option( 'show_thumbnails_thickbox' );
1018
  ?>
1019
  <input type='radio' value='1' name='wpsc_options[show_thumbnails_thickbox]' id='show_thumbnails_thickbox1' <?php echo $show_thumbnails_thickbox1; ?> /> <label for='show_thumbnails_thickbox1'><?php _e( 'Yes', 'wpsc' ); ?></label> &nbsp;
1020
  <input type='radio' value='0' name='wpsc_options[show_thumbnails_thickbox]' id='show_thumbnails_thickbox2' <?php echo $show_thumbnails_thickbox2; ?> /> <label for='show_thumbnails_thickbox2'><?php _e( 'No', 'wpsc' ); ?></label><br />
1021
+ <?php _e( 'Using lightbox means that when clicking on a product image, a larger version will be displayed in a "lightbox" style window. If you are using a plugin such as Shutter Reloaded, you may want to disable lightbox.', 'wpsc' ); ?>
1022
+ </td>
1023
+ </tr>
1024
+ <tr>
1025
+ <th scope="row"><?php _e( 'Lightbox script to use', 'wpsc' ); ?>:</th>
1026
+ <td>
1027
+ <?php
1028
+ $wpsc_lightbox = get_option( 'wpsc_lightbox', 'thickbox' );
1029
+ $wpsc_lightbox_thickbox1 = "";
1030
+ $wpsc_lightbox_thickbox2 = "";
1031
+ if( $wpsc_lightbox == "thickbox" )
1032
+ $wpsc_lightbox_thickbox2 = "checked ='checked'";
1033
+ if( $wpsc_lightbox == "colorbox" )
1034
+ $wpsc_lightbox_thickbox1 = "checked ='checked'";
1035
+ ?>
1036
+ <input type='radio' value='colorbox' name='wpsc_options[wpsc_lightbox]' id='wpsc_lightbox_thickbox1' <?php echo $wpsc_lightbox_thickbox1; ?> /> <label for='show_thumbnails_thickbox1'><?php _e( 'Colorbox', 'wpsc' ); ?></label> &nbsp;
1037
+ <input type='radio' value='thickbox' name='wpsc_options[wpsc_lightbox]' id='wpsc_lightbox_thickbox2' <?php echo $wpsc_lightbox_thickbox2; ?> /> <label for='show_thumbnails_thickbox2'><?php _e( 'Thickbox', 'wpsc' ); ?></label><br />
1038
  </td>
1039
  </tr>
1040
+
1041
  <?php
1042
  if ( function_exists( 'gold_shpcrt_display_gallery' ) ) {
1043
  ?>
1075
 
1076
  </td>
1077
  </tr>
1078
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1079
  <?php
1080
  }
1081
  ?>
wpsc-admin/includes/settings-pages/shipping.php CHANGED
@@ -44,22 +44,10 @@ function wpsc_options_shipping() {
44
  }
45
  /* wpsc_setting_page_update_notification displays the wordpress styled notifications */
46
  wpsc_settings_page_update_notification(); ?>
47
- <?php if ( IS_WP27 ) {
48
- ?>
49
  <div class='postbox'>
50
  <h3 class='hndle'><?php _e( 'General Settings', 'wpsc' ); ?></h3>
51
  <div class='inside'>
52
 
53
- <?php } else {
54
- ?>
55
- <div class="categorisation_title">
56
- <strong class="form_group">
57
- <?php _e( 'General Settings', 'wpsc' ); ?>
58
- </strong>
59
- <br class="clear"/>
60
- </div>
61
- <?php } ?>
62
-
63
  <table class='wpsc_options form-table'>
64
  <tr>
65
  <th scope="row">
@@ -171,28 +159,18 @@ function wpsc_options_shipping() {
171
  </tr>
172
  <?php do_action('wpsc_shipping_settings_page'); ?>
173
  </table>
174
- <?php if ( IS_WP27 ) {
175
- ?>
176
- </div>
177
  </div>
178
- <?php } ?>
179
  <table id='gateway_options' >
180
  <tr>
181
  <td class='select_gateway'>
182
- <?php if ( IS_WP27 ) { ?>
183
  <div class='postbox'>
184
  <h3 class='hndle'><?php _e( 'Shipping Modules', 'wpsc' ) ?></h3>
185
  <div class='inside'>
186
 
187
- <?php } else { ?>
188
- <div class="categorisation_title">
189
- <strong class="form_group"><?php _e( 'Shipping Modules', 'wpsc' ); ?></strong>
190
- </div>
191
-
192
- <?php } ?>
193
-
194
  <p>
195
- <?php _e( 'To enable shipping in WP e-Commerce you must select which shipping methods you want to enable on your site', 'wpsc' ); ?>
196
  </p>
197
  <br />
198
  <p>
@@ -200,41 +178,22 @@ function wpsc_options_shipping() {
200
  </p>
201
  <?php
202
  foreach ( $internal_shipping_modules as $shipping ) {
203
- // exit("<pre>".print_r($shipping,1)."</pre>");
204
 
205
-
206
- if ( is_object( $shipping ) && in_array( $shipping->getInternalName(), (array)$selected_shippings ) ) {
 
207
  ?>
208
 
209
  <div class='wpsc_shipping_options'>
210
  <div class='wpsc-shipping-actions'>
211
  | <span class="edit">
212
- <a class='edit-shipping-module' rel="<?php echo $shipping->internal_name; ?>" onclick="event.preventDefault();" title="Edit this Shipping Module" href='<?php echo htmlspecialchars( add_query_arg( 'shipping_module', $shipping->internal_name ) ); ?>' style="cursor:pointer;">Edit</a>
213
  </span> |
214
  </div>
215
 
216
- <p><input name='custom_shipping_options[]' checked='checked' type='checkbox' value='<?php echo $shipping->internal_name; ?>' id='<?php echo $shipping->internal_name; ?>_id' /><label for='<?php echo $shipping->internal_name; ?>_id'><?php echo $shipping->name; ?></label></p>
217
- </div>
218
- <?php } else { ?>
219
-
220
- <div class='wpsc_shipping_options'>
221
- <div class='wpsc-shipping-actions'>
222
- | <span class="edit">
223
- <a class='edit-shippping-module' onclick="event.preventDefault();" rel="<?php if ( isset( $shipping->internal_name ) )
224
- echo $shipping->internal_name; ?>" title="Edit this Shipping Module" href='<?php if ( isset( $shipping->internal_name ) )
225
- echo htmlspecialchars( add_query_arg( 'shipping_module', $shipping->internal_name ) ); ?>' style="cursor:pointer;">Edit</a>
226
- </span> |
227
- </div>
228
- <p><input name='custom_shipping_options[]' type='checkbox' value='<?php if ( isset( $shipping->internal_name ) )
229
- echo $shipping->internal_name; ?>' id='<?php if ( isset( $shipping->internal_name ) )
230
- echo $shipping->internal_name; ?>_id' /><label for='<?php if ( isset( $shipping->internal_name ) )
231
- echo $shipping->internal_name; ?>_id'><?php if ( isset( $shipping->internal_name ) )
232
- echo $shipping->name; ?></label></p>
233
  </div>
234
- <?php
235
- }
236
- }
237
- ?>
238
  <br />
239
  <p>
240
  <strong><?php _e( 'External Shipping Calculators', 'wpsc' ); ?></strong>
@@ -250,39 +209,27 @@ function wpsc_options_shipping() {
250
  if ( ($shipping->requires_curl == true) && !function_exists( 'curl_init' ) ) {
251
  $disabled = "disabled='disabled'";
252
  }
253
-
254
- if ( in_array( $shipping->getInternalName(), (array)$selected_shippings ) ) {
 
255
  ?>
256
  <div class='wpsc_shipping_options'>
257
  <div class="wpsc-shipping-actions">
258
  | <span class="edit">
259
- <a class='edit-shippping-module' onclick="event.preventDefault();" rel="<?php echo $shipping->internal_name; ?>" title="Edit this Shipping Module" href='<?php echo htmlspecialchars( add_query_arg( 'shipping_module', $shipping->internal_name ) ); ?>' style="cursor:pointer;">Edit</a>
260
  </span> |
261
  </div>
262
- <p><input <?php echo $disabled; ?> name='custom_shipping_options[]' checked='checked' type='checkbox' value='<?php echo $shipping->internal_name; ?>' id='<?php echo $shipping->internal_name; ?>_id' /><label for='<?php echo $shipping->internal_name; ?>_id'><?php echo $shipping->name; ?></label></p>
263
  </div>
264
- <?php } else { ?>
265
- <div class='wpsc_shipping_options'>
266
- <div class="wpsc-shipping-actions">
267
- | <span class="edit">
268
- <a class='edit-shippping-module' onclick="event.preventDefault();" rel="<?php echo $shipping->internal_name; ?>" title="Edit this Shipping Module" href='<?php echo htmlspecialchars( add_query_arg( 'shipping_module', $shipping->internal_name ) ); ?>' style="cursor:pointer;">Edit</a>
269
- </span> |
270
- </div>
271
- <p><input <?php echo $disabled; ?> name='custom_shipping_options[]' type='checkbox' value='<?php echo $shipping->internal_name; ?>' id='<?php echo $shipping->internal_name; ?>_id' /><label for='<?php echo $shipping->internal_name; ?>_id'><?php echo $shipping->name; ?></label></p>
272
- </div>
273
- <?php
274
- }
275
- }
276
- ?>
277
 
278
  <div class='submit gateway_settings'>
279
  <input type='hidden' value='true' name='update_gateways'/>
280
  <input type='submit' value='<?php _e( 'Update &raquo;', 'wpsc' ); ?>' name='updateoption'/>
281
  </div>
282
- <?php if ( IS_WP27 ) { ?>
283
  </div>
284
  </div>
285
- <?php } ?>
286
  </td>
287
 
288
  <td class='gateway_settings' rowspan='2'>
@@ -317,4 +264,4 @@ function wpsc_options_shipping() {
317
  </form>
318
  <?php
319
  }
320
- ?>
44
  }
45
  /* wpsc_setting_page_update_notification displays the wordpress styled notifications */
46
  wpsc_settings_page_update_notification(); ?>
 
 
47
  <div class='postbox'>
48
  <h3 class='hndle'><?php _e( 'General Settings', 'wpsc' ); ?></h3>
49
  <div class='inside'>
50
 
 
 
 
 
 
 
 
 
 
 
51
  <table class='wpsc_options form-table'>
52
  <tr>
53
  <th scope="row">
159
  </tr>
160
  <?php do_action('wpsc_shipping_settings_page'); ?>
161
  </table>
162
+ </div>
 
 
163
  </div>
 
164
  <table id='gateway_options' >
165
  <tr>
166
  <td class='select_gateway'>
167
+ <a name="gateway_options"></a>
168
  <div class='postbox'>
169
  <h3 class='hndle'><?php _e( 'Shipping Modules', 'wpsc' ) ?></h3>
170
  <div class='inside'>
171
 
 
 
 
 
 
 
 
172
  <p>
173
+ <?php _e( 'To enable shipping in WP e-Commerce you must select which shipping methods you want to enable on your site.<br /> If you want to use fixed-price shipping options like "Pickup - $0, Overnight - $10, Same day - $20, etc." you can download a WprdPress plugin from plugins directory for <a href="http://wordpress.org/extend/plugins/wp-e-commerce-fixed-rate-shipping/">Simple shipping</a>. It will appear in the list as "Fixed rate".', 'wpsc' ); ?>
174
  </p>
175
  <br />
176
  <p>
178
  </p>
179
  <?php
180
  foreach ( $internal_shipping_modules as $shipping ) {
 
181
 
182
+ $shipping->checked = '';
183
+ if ( is_object( $shipping ) && in_array( $shipping->getInternalName(), (array)$selected_shippings ) )
184
+ $shipping->checked = ' checked = "checked" ';
185
  ?>
186
 
187
  <div class='wpsc_shipping_options'>
188
  <div class='wpsc-shipping-actions'>
189
  | <span class="edit">
190
+ <a class='edit-shipping-module' rel="<?php echo $shipping->internal_name; ?>" title="Edit this Shipping Module" href='<?php echo htmlspecialchars( add_query_arg('tab', 'shipping' , add_query_arg('page', 'wpsc-settings' , add_query_arg( 'shipping_module', $shipping->internal_name ) ) ) ); ?>#gateway_options' style="cursor:pointer;">Edit</a>
191
  </span> |
192
  </div>
193
 
194
+ <p><input name='custom_shipping_options[]' <?php echo $shipping->checked; ?> type='checkbox' value='<?php echo $shipping->internal_name; ?>' id='<?php echo $shipping->internal_name; ?>_id' /><label for='<?php echo $shipping->internal_name; ?>_id'><?php echo $shipping->name; ?></label></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  </div>
196
+ <?php } ?>
 
 
 
197
  <br />
198
  <p>
199
  <strong><?php _e( 'External Shipping Calculators', 'wpsc' ); ?></strong>
209
  if ( ($shipping->requires_curl == true) && !function_exists( 'curl_init' ) ) {
210
  $disabled = "disabled='disabled'";
211
  }
212
+ $shipping->checked = '';
213
+ if ( in_array( $shipping->getInternalName(), (array)$selected_shippings ) )
214
+ $shipping->checked = " checked='checked' ";
215
  ?>
216
  <div class='wpsc_shipping_options'>
217
  <div class="wpsc-shipping-actions">
218
  | <span class="edit">
219
+ <a class='edit-shippping-module' rel="<?php echo $shipping->internal_name; ?>" title="Edit this Shipping Module" href='<?php echo htmlspecialchars( add_query_arg('tab', 'shipping' , add_query_arg('page', 'wpsc-settings' , add_query_arg( 'shipping_module', $shipping->internal_name ) ) ) ); ?>#gateway_options' style="cursor:pointer;">Edit</a>
220
  </span> |
221
  </div>
222
+ <p><input <?php echo $disabled; ?> name='custom_shipping_options[]' <?php echo $shipping->checked; ?> type='checkbox' value='<?php echo $shipping->internal_name; ?>' id='<?php echo $shipping->internal_name; ?>_id' /><label for='<?php echo $shipping->internal_name; ?>_id'><?php echo $shipping->name; ?></label></p>
223
  </div>
224
+ <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
  <div class='submit gateway_settings'>
227
  <input type='hidden' value='true' name='update_gateways'/>
228
  <input type='submit' value='<?php _e( 'Update &raquo;', 'wpsc' ); ?>' name='updateoption'/>
229
  </div>
230
+
231
  </div>
232
  </div>
 
233
  </td>
234
 
235
  <td class='gateway_settings' rowspan='2'>
264
  </form>
265
  <?php
266
  }
267
+ ?>
wpsc-admin/includes/settings-pages/taxes.php CHANGED
@@ -58,7 +58,7 @@ function wpec_options_taxes() {
58
  <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' ) {
59
  echo 'checked="checked"';
60
  } ?> type="radio" value='billing_shipping' id='wpec_taxes_logic_1' name='wpsc_options[wpec_taxes_logic]' />
61
- <?php _e( 'Apply tax when Billing and Shipping Country is the same as Shops base location' ); ?>
62
  </label>
63
  <div id='billing_shipping_preference_container' style='margin-left: 20px;'>
64
  <p>
@@ -84,7 +84,7 @@ function wpec_options_taxes() {
84
  <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing' ) {
85
  echo 'checked="checked"';
86
  } ?> type="radio" value='billing' id='wpec_taxes_logic_2' name='wpsc_options[wpec_taxes_logic]' />
87
- <?php _e( 'Apply tax when Billing Country is the same as Shops base location' ); ?>
88
  </label>
89
  </p>
90
  <p>
@@ -92,7 +92,7 @@ function wpec_options_taxes() {
92
  <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'shipping' ) {
93
  echo 'checked="checked"';
94
  } ?> type="radio" value='shipping' id='wpec_taxes_logic_3' name='wpsc_options[wpec_taxes_logic]' />
95
- <?php _e( 'Apply tax when Shipping Country is the same as Shops base location' ); ?>
96
  </label>
97
  </p>
98
  <div id='metabox-holder' class="metabox-holder">
58
  <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' ) {
59
  echo 'checked="checked"';
60
  } ?> type="radio" value='billing_shipping' id='wpec_taxes_logic_1' name='wpsc_options[wpec_taxes_logic]' />
61
+ <?php _e( 'Apply tax when Billing and Shipping Country is the same as Tax Rate' ); ?>
62
  </label>
63
  <div id='billing_shipping_preference_container' style='margin-left: 20px;'>
64
  <p>
84
  <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing' ) {
85
  echo 'checked="checked"';
86
  } ?> type="radio" value='billing' id='wpec_taxes_logic_2' name='wpsc_options[wpec_taxes_logic]' />
87
+ <?php _e( 'Apply tax when Billing Country is the same as Tax Rate' ); ?>
88
  </label>
89
  </p>
90
  <p>
92
  <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'shipping' ) {
93
  echo 'checked="checked"';
94
  } ?> type="radio" value='shipping' id='wpec_taxes_logic_3' name='wpsc_options[wpec_taxes_logic]' />
95
+ <?php _e( 'Apply tax when Shipping Country is the same as Tax Rate' ); ?>
96
  </label>
97
  </p>
98
  <div id='metabox-holder' class="metabox-holder">
wpsc-admin/includes/updating-functions.php CHANGED
@@ -173,9 +173,9 @@ GROUP BY ".WPSC_TABLE_PRODUCT_LIST.".id", ARRAY_A);
173
  $product_added_time = strtotime($product['date_added']);
174
  $current_time = time();
175
 
 
176
  if ((int)$current_time < (int)$product_added_time)
177
  $post_date = date("Y-m-d H:i:s");
178
- $post_date = $product['date_added'];
179
 
180
  $product_post_values = array(
181
  'post_author' => $user_ID,
173
  $product_added_time = strtotime($product['date_added']);
174
  $current_time = time();
175
 
176
+ $post_date = $product['date_added'];
177
  if ((int)$current_time < (int)$product_added_time)
178
  $post_date = date("Y-m-d H:i:s");
 
179
 
180
  $product_post_values = array(
181
  'post_author' => $user_ID,
wpsc-admin/js/admin-legacy.js CHANGED
@@ -1115,60 +1115,6 @@ jQuery(document).ready(function(){
1115
  }
1116
  );
1117
 
1118
-
1119
- // jQuery("table#itemlist .pricedisplay").editable(base_url+"/wp-admin/admin.php?inline_price=true", {
1120
- // indicator : "Saving...",
1121
- // tooltip : 'Click to edit...'
1122
- // });
1123
- /*
1124
- jQuery('.meta-box-sortables').sortable( {
1125
- placeholder: 'sortable-placeholder',
1126
- connectWith: [ '.meta-box-sortables' ],
1127
- items: '> .postbox',
1128
- handle: '.hndle',
1129
- distance: 2,
1130
- tolerance: 'pointer',
1131
- sort: function(e,ui) {
1132
- if ( jQuery(document).width() - e.clientX < 300 ) {
1133
- if ( ! jQuery('#post-body').hasClass('has-sidebar') ) {
1134
- var pos = jQuery('#side-sortables').offset();
1135
-
1136
- jQuery('#side-sortables').append(ui.item)
1137
- jQuery(ui.placeholder).css({'top':pos.top,'left':pos.left}).width(jQuery(ui.item).width())
1138
- postboxes.expandSidebar(1);
1139
- }
1140
- }
1141
- },
1142
- stop: function() {
1143
- var postVars = {
1144
- action: 'product-page-order',
1145
- ajax: 'true'
1146
- }
1147
- jQuery(this).each( function() {
1148
- postVars["order[" + this.id.split('-')[0] + "]"] = jQuery(this).sortable( 'toArray' ).join(',');
1149
- } );
1150
- jQuery.post( 'index.php?admin=true&ajax=true', postVars, function() {
1151
- postboxes.expandSidebar();
1152
- } );
1153
- }
1154
- } );
1155
- var boxes = new Array;
1156
- if (hidden_boxes) {
1157
- hidden_boxes = hidden_boxes.split(',');
1158
- for (i=0;i<hidden_boxes.length;i++) {
1159
- jQuery('#'+hidden_boxes[i]+'-hide').removeAttr('checked');
1160
- }
1161
- }
1162
- boxes = ["price_and_stock", "shipping", "variation", "advanced", "product_image", "product_download"];
1163
-
1164
- for (i=0;i<boxes.length;i++) {
1165
- if ( ! jQuery('#'+boxes[i]+'-hide').attr('checked')){
1166
- if (IS_WP27) {
1167
- jQuery('#'+boxes[i]).hide();
1168
- }
1169
- }
1170
- }
1171
- */
1172
  jQuery("#submit_category_select").click(
1173
  function() {
1174
  new_url = jQuery("#category_select").children("option:selected").val();
1115
  }
1116
  );
1117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1118
  jQuery("#submit_category_select").click(
1119
  function() {
1120
  new_url = jQuery("#category_select").children("option:selected").val();
wpsc-admin/js/admin.js CHANGED
@@ -828,31 +828,6 @@ jQuery(document).ready( function () {
828
  });
829
  });
830
 
831
- jQuery('img.deleteButton, a.delete_primary_image').livequery(function(){
832
- jQuery(this).click( function() {
833
- var r=confirm("Please confirm deletion");
834
- if (r==true) {
835
- img_id = jQuery(this).parents("li.gallery_image").attr('id');
836
-
837
- post_values = "del_img_id="+img_id+"&product_id="+jQuery('#product_id').val();
838
- jQuery.post( 'index.php?wpsc_admin_action=delete_images', post_values, function(returned_data) {
839
- //console.log(returned_data);
840
- eval(returned_data);
841
- if(typeof(image_id) != "undefined") {
842
- jQuery('#gallery_image_'+image_id).children('img.deleteButton').remove();
843
- jQuery('#gallery_image_'+image_id).children('a.editButton').remove();
844
- jQuery('#gallery_image_'+image_id).children('div.image_settings_box').remove();
845
- }
846
- if(typeof(image_menu) != "undefined") {
847
- jQuery('#gallery_image_'+image_id).append(image_menu);
848
- }
849
- jQuery("#"+element_id).remove();
850
- });
851
- return false;
852
- }
853
- });
854
- });
855
-
856
  jQuery('a.closeimagesettings').livequery(function(){
857
  jQuery(this).click( function() {
858
  jQuery('.image_settings_box').hide();
@@ -976,31 +951,6 @@ jQuery(document).ready( function () {
976
  // gets shipping form for admin page
977
  // show or hide the stock input forms
978
 
979
- jQuery(".wpsc-shipping-actions a").livequery(function(){
980
- jQuery(this).click( function () {
981
- var module = jQuery(this).attr('rel');
982
-
983
- jQuery.ajax({
984
- method: "post",
985
- url: "index.php",
986
- data: "wpsc_admin_action=get_shipping_form&shippingname="+module,
987
- success: function(returned_data){
988
- eval(returned_data);
989
- //jQuery(".gateway_settings").children(".form-table").html(html)
990
- jQuery('.gateway_settings h3.hndle').html(shipping_name_html);
991
- jQuery("td.gateway_settings table.form-table").html('<tr><td><input type="hidden" name="shippingname" value="'+module+'" /></td></tr>'+shipping_form_html);
992
- if(has_submit_button != '') {
993
- jQuery('.gateway_settings div.submit').css('display', 'block');
994
- } else {
995
- jQuery('.gateway_settings div.submit').css('display', 'none');
996
- }
997
- }
998
- });
999
- return false;
1000
-
1001
- });
1002
- });
1003
-
1004
  jQuery(".wpsc-payment-actions a").livequery(function(){
1005
  jQuery(this).click( function () {
1006
  var module = jQuery(this).attr('rel');
828
  });
829
  });
830
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
831
  jQuery('a.closeimagesettings').livequery(function(){
832
  jQuery(this).click( function() {
833
  jQuery('.image_settings_box').hide();
951
  // gets shipping form for admin page
952
  // show or hide the stock input forms
953
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
954
  jQuery(".wpsc-payment-actions a").livequery(function(){
955
  jQuery(this).click( function () {
956
  var module = jQuery(this).attr('rel');
wpsc-core/images/credit_cards.png CHANGED
Binary file
wpsc-core/js/jquery.colorbox-min.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ // ColorBox v1.3.15 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
2
+ // Copyright (c) 2010 Jack Moore - jack@colorpowered.com
3
+ // Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
4
+ (function(b,ib){var t="none",M="LoadedContent",c=false,v="resize.",o="y",q="auto",e=true,L="nofollow",m="x";function f(a,c){a=a?' id="'+i+a+'"':"";c=c?' style="'+c+'"':"";return b("<div"+a+c+"/>")}function p(a,b){b=b===m?n.width():n.height();return typeof a==="string"?Math.round(/%/.test(a)?b/100*parseInt(a,10):parseInt(a,10)):a}function U(b){return a.photo||/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(b)}function cb(a){for(var c in a)if(b.isFunction(a[c])&&c.substring(0,2)!=="on")a[c]=a[c].call(l);a.rel=a.rel||l.rel||L;a.href=a.href||b(l).attr("href");a.title=a.title||l.title;return a}function w(c,a){a&&a.call(l);b.event.trigger(c)}function jb(){var b,e=i+"Slideshow_",c="click."+i,f,k;if(a.slideshow&&h[1]){f=function(){F.text(a.slideshowStop).unbind(c).bind(V,function(){if(g<h.length-1||a.loop)b=setTimeout(d.next,a.slideshowSpeed)}).bind(W,function(){clearTimeout(b)}).one(c+" "+N,k);j.removeClass(e+"off").addClass(e+"on");b=setTimeout(d.next,a.slideshowSpeed)};k=function(){clearTimeout(b);F.text(a.slideshowStart).unbind([V,W,N,c].join(" ")).one(c,f);j.removeClass(e+"on").addClass(e+"off")};a.slideshowAuto?f():k()}}function db(c){if(!O){l=c;a=cb(b.extend({},b.data(l,r)));h=b(l);g=0;if(a.rel!==L){h=b("."+G).filter(function(){return (b.data(this,r).rel||this.rel)===a.rel});g=h.index(l);if(g===-1){h=h.add(l);g=h.length-1}}if(!u){u=D=e;j.show();if(a.returnFocus)try{l.blur();b(l).one(eb,function(){try{this.focus()}catch(a){}})}catch(f){}x.css({opacity:+a.opacity,cursor:a.overlayClose?"pointer":q}).show();a.w=p(a.initialWidth,m);a.h=p(a.initialHeight,o);d.position(0);X&&n.bind(v+P+" scroll."+P,function(){x.css({width:n.width(),height:n.height(),top:n.scrollTop(),left:n.scrollLeft()})}).trigger("scroll."+P);w(fb,a.onOpen);Y.add(H).add(I).add(F).add(Z).hide();ab.html(a.close).show()}d.load(e)}}var gb={transition:"elastic",speed:300,width:c,initialWidth:"600",innerWidth:c,maxWidth:c,height:c,initialHeight:"450",innerHeight:c,maxHeight:c,scalePhotos:e,scrolling:e,inline:c,html:c,iframe:c,photo:c,href:c,title:c,rel:c,opacity:.9,preloading:e,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:c,returnFocus:e,loop:e,slideshow:c,slideshowAuto:e,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:c,onLoad:c,onComplete:c,onCleanup:c,onClosed:c,overlayClose:e,escKey:e,arrowKey:e},r="colorbox",i="cbox",fb=i+"_open",W=i+"_load",V=i+"_complete",N=i+"_cleanup",eb=i+"_closed",Q=i+"_purge",hb=i+"_loaded",E=b.browser.msie&&!b.support.opacity,X=E&&b.browser.version<7,P=i+"_IE6",x,j,A,s,bb,T,R,S,h,n,k,J,K,Z,Y,F,I,H,ab,B,C,y,z,l,g,a,u,D,O=c,d,G=i+"Element";d=b.fn[r]=b[r]=function(c,f){var a=this,d;if(!a[0]&&a.selector)return a;c=c||{};if(f)c.onComplete=f;if(!a[0]||a.selector===undefined){a=b("<a/>");c.open=e}a.each(function(){b.data(this,r,b.extend({},b.data(this,r)||gb,c));b(this).addClass(G)});d=c.open;if(b.isFunction(d))d=d.call(a);d&&db(a[0]);return a};d.init=function(){var l="hover",m="clear:left";n=b(ib);j=f().attr({id:r,"class":E?i+"IE":""});x=f("Overlay",X?"position:absolute":"").hide();A=f("Wrapper");s=f("Content").append(k=f(M,"width:0; height:0; overflow:hidden"),K=f("LoadingOverlay").add(f("LoadingGraphic")),Z=f("Title"),Y=f("Current"),I=f("Next"),H=f("Previous"),F=f("Slideshow").bind(fb,jb),ab=f("Close"));A.append(f().append(f("TopLeft"),bb=f("TopCenter"),f("TopRight")),f(c,m).append(T=f("MiddleLeft"),s,R=f("MiddleRight")),f(c,m).append(f("BottomLeft"),S=f("BottomCenter"),f("BottomRight"))).children().children().css({"float":"left"});J=f(c,"position:absolute; width:9999px; visibility:hidden; display:none");b("body").prepend(x,j.append(A,J));s.children().hover(function(){b(this).addClass(l)},function(){b(this).removeClass(l)}).addClass(l);B=bb.height()+S.height()+s.outerHeight(e)-s.height();C=T.width()+R.width()+s.outerWidth(e)-s.width();y=k.outerHeight(e);z=k.outerWidth(e);j.css({"padding-bottom":B,"padding-right":C}).hide();I.click(d.next);H.click(d.prev);ab.click(d.close);s.children().removeClass(l);b("."+G).live("click",function(a){if(!(a.button!==0&&typeof a.button!=="undefined"||a.ctrlKey||a.shiftKey||a.altKey)){a.preventDefault();db(this)}});x.click(function(){a.overlayClose&&d.close()});b(document).bind("keydown",function(b){if(u&&a.escKey&&b.keyCode===27){b.preventDefault();d.close()}if(u&&a.arrowKey&&!D&&h[1])if(b.keyCode===37&&(g||a.loop)){b.preventDefault();H.click()}else if(b.keyCode===39&&(g<h.length-1||a.loop)){b.preventDefault();I.click()}})};d.remove=function(){j.add(x).remove();b("."+G).die("click").removeData(r).removeClass(G)};d.position=function(f,d){function b(a){bb[0].style.width=S[0].style.width=s[0].style.width=a.style.width;K[0].style.height=K[1].style.height=s[0].style.height=T[0].style.height=R[0].style.height=a.style.height}var e,h=Math.max(document.documentElement.clientHeight-a.h-y-B,0)/2+n.scrollTop(),g=Math.max(n.width()-a.w-z-C,0)/2+n.scrollLeft();e=j.width()===a.w+z&&j.height()===a.h+y?0:f;A[0].style.width=A[0].style.height="9999px";j.dequeue().animate({width:a.w+z,height:a.h+y,top:h,left:g},{duration:e,complete:function(){b(this);D=c;A[0].style.width=a.w+z+C+"px";A[0].style.height=a.h+y+B+"px";d&&d()},step:function(){b(this)}})};d.resize=function(b){if(u){b=b||{};if(b.width)a.w=p(b.width,m)-z-C;if(b.innerWidth)a.w=p(b.innerWidth,m);k.css({width:a.w});if(b.height)a.h=p(b.height,o)-y-B;if(b.innerHeight)a.h=p(b.innerHeight,o);if(!b.innerHeight&&!b.height){b=k.wrapInner("<div style='overflow:auto'></div>").children();a.h=b.height();b.replaceWith(b.children())}k.css({height:a.h});d.position(a.transition===t?0:a.speed)}};d.prep=function(m){var c="hidden";function l(s){var p,f,m,c,l=h.length,q=a.loop;d.position(s,function(){function s(){E&&j[0].style.removeAttribute("filter")}if(u){E&&o&&k.fadeIn(100);k.show();w(hb);Z.show().html(a.title);if(l>1){typeof a.current==="string"&&Y.html(a.current.replace(/\{current\}/,g+1).replace(/\{total\}/,l)).show();I[q||g<l-1?"show":"hide"]().html(a.next);H[q||g?"show":"hide"]().html(a.previous);p=g?h[g-1]:h[l-1];m=g<l-1?h[g+1]:h[0];a.slideshow&&F.show();if(a.preloading){c=b.data(m,r).href||m.href;f=b.data(p,r).href||p.href;c=b.isFunction(c)?c.call(m):c;f=b.isFunction(f)?f.call(p):f;if(U(c))b("<img/>")[0].src=c;if(U(f))b("<img/>")[0].src=f}}K.hide();a.transition==="fade"?j.fadeTo(e,1,function(){s()}):s();n.bind(v+i,function(){d.position(0)});w(V,a.onComplete)}})}if(u){var o,e=a.transition===t?0:a.speed;n.unbind(v+i);k.remove();k=f(M).html(m);k.hide().appendTo(J.show()).css({width:function(){a.w=a.w||k.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}(),overflow:a.scrolling?q:c}).css({height:function(){a.h=a.h||k.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}()}).prependTo(s);J.hide();b("#"+i+"Photo").css({cssFloat:t,marginLeft:q,marginRight:q});X&&b("select").not(j.find("select")).filter(function(){return this.style.visibility!==c}).css({visibility:c}).one(N,function(){this.style.visibility="inherit"});a.transition==="fade"?j.fadeTo(e,0,function(){l(0)}):l(e)}};d.load=function(u){var n,c,s,q=d.prep;D=e;l=h[g];u||(a=cb(b.extend({},b.data(l,r))));w(Q);w(W,a.onLoad);a.h=a.height?p(a.height,o)-y-B:a.innerHeight&&p(a.innerHeight,o);a.w=a.width?p(a.width,m)-z-C:a.innerWidth&&p(a.innerWidth,m);a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=p(a.maxWidth,m)-z-C;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=p(a.maxHeight,o)-y-B;a.mh=a.h&&a.h<a.mh?a.h:a.mh}n=a.href;K.show();if(a.inline){f().hide().insertBefore(b(n)[0]).one(Q,function(){b(this).replaceWith(k.children())});q(b(n))}else if(a.iframe){j.one(hb,function(){var c=b("<iframe frameborder='0' style='width:100%; height:100%; border:0; display:block'/>")[0];c.name=+new Date;c.src=a.href;if(!a.scrolling)c.scrolling="no";if(E)c.allowtransparency="true";b(c).appendTo(k).one(Q,function(){c.src="//about:blank"})});q(" ")}else if(a.html)q(a.html);else if(U(n)){c=new Image;c.onload=function(){var e;c.onload=null;c.id=i+"Photo";b(c).css({border:t,display:"block",cssFloat:"left"});if(a.scalePhotos){s=function(){c.height-=c.height*e;c.width-=c.width*e};if(a.mw&&c.width>a.mw){e=(c.width-a.mw)/c.width;s()}if(a.mh&&c.height>a.mh){e=(c.height-a.mh)/c.height;s()}}if(a.h)c.style.marginTop=Math.max(a.h-c.height,0)/2+"px";h[1]&&(g<h.length-1||a.loop)&&b(c).css({cursor:"pointer"}).click(d.next);if(E)c.style.msInterpolationMode="bicubic";setTimeout(function(){q(c)},1)};setTimeout(function(){c.src=n},1)}else n&&J.load(n,function(d,c,a){q(c==="error"?"Request unsuccessful: "+a.statusText:b(this).children())})};d.next=function(){if(!D){g=g<h.length-1?g+1:0;d.load()}};d.prev=function(){if(!D){g=g?g-1:h.length-1;d.load()}};d.close=function(){if(u&&!O){O=e;u=c;w(N,a.onCleanup);n.unbind("."+i+" ."+P);x.fadeTo("fast",0);j.stop().fadeTo("fast",0,function(){w(Q);k.remove();j.add(x).css({opacity:1,cursor:q}).hide();setTimeout(function(){O=c;w(eb,a.onClosed)},1)})}};d.element=function(){return b(l)};d.settings=gb;b(d.init)})(jQuery,this);
wpsc-core/js/tinymce3/cart.png DELETED
Binary file
wpsc-core/js/tinymce3/credit_cards.png ADDED
Binary file
wpsc-core/js/tinymce3/editor_plugin.js CHANGED
@@ -31,7 +31,7 @@
31
  ed.addButton('WPSC', {
32
  title : 'WPSC.desc',
33
  cmd : 'WPSC',
34
- image : url + '/cart.png'
35
  });
36
 
37
  // Add a node change handler, selects the button in the UI when a image is selected
@@ -83,7 +83,7 @@
83
 
84
  tinymce.create('tinymce.plugins.productspage_image', {
85
  init : function(ed, url) {
86
- var pb = '<img src="' + url + '/productspage.gif" class="productspage_image mceItemNoResize" />', cls = 'productspage_image', sep = ed.getParam('productspage_image', '[productspage]'), pbRE;
87
 
88
  pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
89
 
31
  ed.addButton('WPSC', {
32
  title : 'WPSC.desc',
33
  cmd : 'WPSC',
34
+ image : url + '/credit_cards.png'
35
  });
36
 
37
  // Add a node change handler, selects the button in the UI when a image is selected
83
 
84
  tinymce.create('tinymce.plugins.productspage_image', {
85
  init : function(ed, url) {
86
+ var pb = '<img style="border:1px dashed #888;padding:5% 25%;background-color:#F2F8FF;" src="' + url + '/productspage.jpg" class="productspage_image mceItemNoResize" title="Do not remove this image unless you know what you are doing." />', cls = 'productspage_image', sep = ed.getParam('productspage_image', '[productspage]'), pbRE;
87
 
88
  pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
89
 
wpsc-core/js/tinymce3/mce.css DELETED
@@ -1,9 +0,0 @@
1
- body.mceContentBody {
2
- font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;
3
- font-size:13px;
4
- font-size-adjust:none;
5
- font-style:normal;
6
- font-variant:normal;
7
- font-weight:normal;
8
- line-height:19px;
9
- }
 
 
 
 
 
 
 
 
 
wpsc-core/js/tinymce3/productspage.gif DELETED
Binary file
wpsc-core/js/tinymce3/productspage.jpg ADDED
Binary file
wpsc-core/js/tinymce3/tinymce.js CHANGED
@@ -63,13 +63,19 @@ function insertWPSCLink() {
63
  visi = document.getElementById('wpsc_slider_visibles');
64
  var categoryid = category.value;
65
  var visibles = visi.value;
66
- if (categoryid > 0 ) {
 
 
67
  if (visibles != '') {
68
  tagtext = "[wpec_product_slider category_id='"+categoryid+"' visible_items='"+visibles+"']";
69
  } else {
70
  tagtext = "[wpec_product_slider category_id='"+categoryid+"']";
71
  }
72
- } else {
 
 
 
 
73
  tinyMCEPopup.close();
74
  }
75
  }
63
  visi = document.getElementById('wpsc_slider_visibles');
64
  var categoryid = category.value;
65
  var visibles = visi.value;
66
+
67
+ if (categoryid > 0) {
68
+
69
  if (visibles != '') {
70
  tagtext = "[wpec_product_slider category_id='"+categoryid+"' visible_items='"+visibles+"']";
71
  } else {
72
  tagtext = "[wpec_product_slider category_id='"+categoryid+"']";
73
  }
74
+
75
+ }
76
+ else if(categoryid == 'all'){
77
+ tagtext = "[wpec_product_slider]";
78
+ }else {
79
  tinyMCEPopup.close();
80
  }
81
  }
wpsc-core/js/tinymce3/window.php CHANGED
@@ -35,7 +35,7 @@ global $wpdb;
35
  }
36
  </style>
37
  </head>
38
-
39
  <body id="link" onload="tinyMCEPopup.executeOnLoad('init();'); document.body.style.display=''; document.getElementById('category').focus();" style="display:none;">
40
  <form name="WPSC" action="#">
41
  <div class="tabs">
@@ -109,6 +109,7 @@ global $wpdb;
109
  <td>
110
  <select id="wpsc_slider_category" name="wpsc_category" style="width: 200px">
111
  <option value="0"> <?php _e("No Category", 'wpsc'); ?></option>
 
112
  <?php
113
  foreach($categorylist as $category)
114
  echo "<option value=".$category->term_id." >".$category->name."</option>"."\n";
35
  }
36
  </style>
37
  </head>
38
+
39
  <body id="link" onload="tinyMCEPopup.executeOnLoad('init();'); document.body.style.display=''; document.getElementById('category').focus();" style="display:none;">
40
  <form name="WPSC" action="#">
41
  <div class="tabs">
109
  <td>
110
  <select id="wpsc_slider_category" name="wpsc_category" style="width: 200px">
111
  <option value="0"> <?php _e("No Category", 'wpsc'); ?></option>
112
+ <option value="all"> <?php _e("All Categories", 'wpsc'); ?></option>
113
  <?php
114
  foreach($categorylist as $category)
115
  echo "<option value=".$category->term_id." >".$category->name."</option>"."\n";
wpsc-core/js/user.js CHANGED
@@ -323,8 +323,12 @@ function log_buynow(form){
323
  ajax.post("index.php",noresults,"ajax=true&buynow=true&product_id="+id+"price="+price);
324
  }
325
 
326
- function gotoexternallink(link){
327
- window.location = link;
 
 
 
 
328
  }
329
 
330
  function manage_extras(product_id, extras_id, special) {
@@ -391,31 +395,6 @@ var return_store_list=function(results) {
391
  return true;
392
  }
393
 
394
- function autocomplete(event) {
395
- if(!event){
396
- event=window.event;
397
- }
398
- if(event.keyCode){
399
- keyPressed=event.keyCode;
400
- }else if(event.which){
401
- keyPressed=event.which;
402
- }
403
- str = document.getElementById('wpsc_search_autocomplete').value;
404
- if (str != '') {
405
- ajax.post("index.php",autocomplete_results,"wpsc_live_search=true&keyword="+str);
406
- } else {
407
- jQuery('#blind_down').slideUp(100);
408
- }
409
- }
410
-
411
- var autocomplete_results=function(results) {
412
- document.getElementById('blind_down').innerHTML=results;
413
- if (document.getElementById('blind_down').style.display!='block') {
414
- jQuery('#blind_down').slideDown(200);
415
- }
416
- return true;
417
- }
418
-
419
  function statusTextKeyPress(event){
420
  if(!event){
421
  event=window.event;
323
  ajax.post("index.php",noresults,"ajax=true&buynow=true&product_id="+id+"price="+price);
324
  }
325
 
326
+ function gotoexternallink(link, target){
327
+ if (target == '') {
328
+ target = '_self';
329
+ }
330
+ window.open(link, target);
331
+ return false;
332
  }
333
 
334
  function manage_extras(product_id, extras_id, special) {
395
  return true;
396
  }
397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
  function statusTextKeyPress(event){
399
  if(!event){
400
  event=window.event;
wpsc-core/js/wp-e-commerce.js CHANGED
@@ -13,6 +13,11 @@ function check_make_purchase_button(){
13
  // this function is for binding actions to events and rebinding them after they are replaced by AJAX
14
  // these functions are bound to events on elements when the page is fully loaded.
15
  jQuery(document).ready(function () {
 
 
 
 
 
16
 
17
  //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
18
  //jQuery('.wpsc_shipping_forms').hide();
@@ -135,21 +140,20 @@ jQuery(document).ready(function () {
135
  form_values =jQuery("input[name=product_id], .wpsc_select_variation",parent_form).serialize( );
136
 
137
  jQuery.post( 'index.php?update_product_price=true', form_values, function(returned_data) {
138
- product_msg = '';
139
- message_exists = null;
140
  eval(returned_data);
141
- if(product_id != null) {
142
- if(product_msg != ''){
143
- jQuery("input#product_"+product_id+"_submit_button").attr('disabled','disabled');
144
- message_exists = jQuery(".wpsc_variation_message_"+product_id).html();
145
- if(message_exists == null){
146
- jQuery("input#product_"+product_id+"_submit_button").before('<span class="wpsc_variation_message_'+product_id+'"">'+product_msg+'</span>');
147
  }else{
148
- jQuery(".wpsc_variation_message_"+product_id).css('display','inline');
 
149
  }
150
- }else{
151
- jQuery("input#product_"+product_id+"_submit_button").removeAttr('disabled');
152
- jQuery('.wpsc_variation_message_'+product_id).css('display','none');
153
  }
154
  target_id = "product_price_"+product_id;
155
  second_target_id = "donation_price_"+product_id;
@@ -337,7 +341,7 @@ jQuery(document).ready(function(){
337
  var real_value = jQuery(this).val();
338
  value = jQuery('label[for="'+jQuery(this).attr('id')+'"]').html();
339
  if(null != value){
340
- value = value.replace(/\*/i,'');
341
  }
342
  jQuery(this).inlineFieldLabel({label:jQuery.trim(value)});
343
  if(real_value != '')
@@ -375,4 +379,6 @@ jQuery(document).ready(function(){
375
  jQuery(this).parents('.imagecol:first').find('.product_image').parent('a:first').attr('href', jQuery(this).parent().attr('href'));
376
  return false;
377
  });
378
- });
 
 
13
  // this function is for binding actions to events and rebinding them after they are replaced by AJAX
14
  // these functions are bound to events on elements when the page is fully loaded.
15
  jQuery(document).ready(function () {
16
+ if(jQuery('#checkout_page_container .wpsc_email_address input').val())
17
+ jQuery('#wpsc_checkout_gravatar').attr('src', 'https://secure.gravatar.com/avatar/'+MD5(jQuery('#checkout_page_container .wpsc_email_address input').val().split(' ').join(''))+'?s=60&d=mm');
18
+ jQuery('#checkout_page_container .wpsc_email_address input').keyup(function(){
19
+ jQuery('#wpsc_checkout_gravatar').attr('src', 'https://secure.gravatar.com/avatar/'+MD5(jQuery(this).val().split(' ').join(''))+'?s=60&d=mm');
20
+ });
21
 
22
  //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
23
  //jQuery('.wpsc_shipping_forms').hide();
140
  form_values =jQuery("input[name=product_id], .wpsc_select_variation",parent_form).serialize( );
141
 
142
  jQuery.post( 'index.php?update_product_price=true', form_values, function(returned_data) {
143
+ variation_msg = '';
 
144
  eval(returned_data);
145
+ if( product_id != null ) {
146
+ if( variation_msg != '' ){
147
+ if(variation_status){
148
+ jQuery("div#stock_display_"+product_id).removeClass('out_of_stock');
149
+ jQuery("div#stock_display_"+product_id).addClass('in_stock');
 
150
  }else{
151
+ jQuery("div#stock_display_"+product_id).removeClass('in_stock');
152
+ jQuery("div#stock_display_"+product_id).addClass('out_of_stock');
153
  }
154
+
155
+ jQuery("div#stock_display_"+product_id).html(variation_msg);
156
+
157
  }
158
  target_id = "product_price_"+product_id;
159
  second_target_id = "donation_price_"+product_id;
341
  var real_value = jQuery(this).val();
342
  value = jQuery('label[for="'+jQuery(this).attr('id')+'"]').html();
343
  if(null != value){
344
+ value = value.replace(/<span class="asterix">\*<\/span>/i,'');
345
  }
346
  jQuery(this).inlineFieldLabel({label:jQuery.trim(value)});
347
  if(real_value != '')
379
  jQuery(this).parents('.imagecol:first').find('.product_image').parent('a:first').attr('href', jQuery(this).parent().attr('href'));
380
  return false;
381
  });
382
+ });
383
+
384
+ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('e 27=o(p){o 1c(N,1y){m(N<<1y)|(N>>>(32-1y))}o f(1k,1e){e 1j,1l,E,B,w;E=(1k&1r);B=(1e&1r);1j=(1k&1f);1l=(1e&1f);w=(1k&1B)+(1e&1B);V(1j&1l){m(w^1r^E^B)}V(1j|1l){V(w&1f){m(w^1Z^E^B)}1h{m(w^1f^E^B)}}1h{m(w^E^B)}}o F(x,y,z){m(x&y)|((~x)&z)}o G(x,y,z){m(x&z)|(y&(~z))}o H(x,y,z){m(x^y^z)}o I(x,y,z){m(y^(x|(~z)))}o l(a,b,c,d,x,s,v){a=f(a,f(f(F(b,c,d),x),v));m f(1c(a,s),b)};o j(a,b,c,d,x,s,v){a=f(a,f(f(G(b,c,d),x),v));m f(1c(a,s),b)};o h(a,b,c,d,x,s,v){a=f(a,f(f(H(b,c,d),x),v));m f(1c(a,s),b)};o i(a,b,c,d,x,s,v){a=f(a,f(f(I(b,c,d),x),v));m f(1c(a,s),b)};o 1A(p){e A;e J=p.1g;e 1q=J+8;e 1D=(1q-(1q%1G))/1G;e 1m=(1D+1)*16;e t=1z(1m-1);e K=0;e q=0;24(q<J){A=(q-(q%4))/4;K=(q%4)*8;t[A]=(t[A]|(p.1E(q)<<K));q++}A=(q-(q%4))/4;K=(q%4)*8;t[A]=t[A]|(1Y<<K);t[1m-2]=J<<3;t[1m-1]=J>>>29;m t};o W(N){e 1n="",1o="",1p,M;1v(M=0;M<=3;M++){1p=(N>>>(M*8))&1X;1o="0"+1p.1U(16);1n=1n+1o.1V(1o.1g-2,2)}m 1n};o 1C(p){p=p.1W(/\\r\\n/g,"\\n");e u="";1v(e n=0;n<p.1g;n++){e c=p.1E(n);V(c<1i){u+=D.C(c)}1h V((c>1T)&&(c<25)){u+=D.C((c>>6)|26);u+=D.C((c&1s)|1i)}1h{u+=D.C((c>>12)|2c);u+=D.C(((c>>6)&1s)|1i);u+=D.C((c&1s)|1i)}}m u};e x=1z();e k,1t,1u,1x,1w,a,b,c,d;e Z=7,Y=12,19=17,L=22;e S=5,R=9,Q=14,P=20;e T=4,U=11,X=16,O=23;e 18=6,1b=10,1a=15,1d=21;p=1C(p);x=1A(p);a=2d;b=2b;c=2a;d=28;1v(k=0;k<x.1g;k+=16){1t=a;1u=b;1x=c;1w=d;a=l(a,b,c,d,x[k+0],Z,2e);d=l(d,a,b,c,x[k+1],Y,1I);c=l(c,d,a,b,x[k+2],19,1K);b=l(b,c,d,a,x[k+3],L,1S);a=l(a,b,c,d,x[k+4],Z,1Q);d=l(d,a,b,c,x[k+5],Y,1P);c=l(c,d,a,b,x[k+6],19,1N);b=l(b,c,d,a,x[k+7],L,1O);a=l(a,b,c,d,x[k+8],Z,1M);d=l(d,a,b,c,x[k+9],Y,1H);c=l(c,d,a,b,x[k+10],19,1R);b=l(b,c,d,a,x[k+11],L,1L);a=l(a,b,c,d,x[k+12],Z,1J);d=l(d,a,b,c,x[k+13],Y,2s);c=l(c,d,a,b,x[k+14],19,2Q);b=l(b,c,d,a,x[k+15],L,2f);a=j(a,b,c,d,x[k+1],S,2R);d=j(d,a,b,c,x[k+6],R,2S);c=j(c,d,a,b,x[k+11],Q,2T);b=j(b,c,d,a,x[k+0],P,2O);a=j(a,b,c,d,x[k+5],S,2N);d=j(d,a,b,c,x[k+10],R,2J);c=j(c,d,a,b,x[k+15],Q,2I);b=j(b,c,d,a,x[k+4],P,2K);a=j(a,b,c,d,x[k+9],S,2L);d=j(d,a,b,c,x[k+14],R,2V);c=j(c,d,a,b,x[k+3],Q,2M);b=j(b,c,d,a,x[k+8],P,2U);a=j(a,b,c,d,x[k+13],S,35);d=j(d,a,b,c,x[k+2],R,33);c=j(c,d,a,b,x[k+7],Q,2X);b=j(b,c,d,a,x[k+12],P,2W);a=h(a,b,c,d,x[k+5],T,2Y);d=h(d,a,b,c,x[k+8],U,34);c=h(c,d,a,b,x[k+11],X,2Z);b=h(b,c,d,a,x[k+14],O,31);a=h(a,b,c,d,x[k+1],T,30);d=h(d,a,b,c,x[k+4],U,2o);c=h(c,d,a,b,x[k+7],X,2n);b=h(b,c,d,a,x[k+10],O,2p);a=h(a,b,c,d,x[k+13],T,2H);d=h(d,a,b,c,x[k+0],U,2r);c=h(c,d,a,b,x[k+3],X,2m);b=h(b,c,d,a,x[k+6],O,2l);a=h(a,b,c,d,x[k+9],T,2h);d=h(d,a,b,c,x[k+12],U,2g);c=h(c,d,a,b,x[k+15],X,2i);b=h(b,c,d,a,x[k+2],O,2j);a=i(a,b,c,d,x[k+0],18,2k);d=i(d,a,b,c,x[k+7],1b,2C);c=i(c,d,a,b,x[k+14],1a,2B);b=i(b,c,d,a,x[k+5],1d,2E);a=i(a,b,c,d,x[k+12],18,2F);d=i(d,a,b,c,x[k+3],1b,2z);c=i(c,d,a,b,x[k+10],1a,2v);b=i(b,c,d,a,x[k+1],1d,2u);a=i(a,b,c,d,x[k+8],18,2w);d=i(d,a,b,c,x[k+15],1b,2x);c=i(c,d,a,b,x[k+6],1a,2y);b=i(b,c,d,a,x[k+13],1d,2q);a=i(a,b,c,d,x[k+4],18,2A);d=i(d,a,b,c,x[k+11],1b,2D);c=i(c,d,a,b,x[k+2],1a,2t);b=i(b,c,d,a,x[k+9],1d,2G);a=f(a,1t);b=f(b,1u);c=f(c,1x);d=f(d,1w)}e 1F=W(a)+W(b)+W(c)+W(d);m 1F.2P()}',62,192,'||||||||||||||var|AddUnsigned||HH|II|GG||FF|return||function|string|lByteCount|||lWordArray|utftext|ac|lResult||||lWordCount|lY8|fromCharCode|String|lX8|||||lMessageLength|lBytePosition|S14|lCount|lValue|S34|S24|S23|S22|S21|S31|S32|if|WordToHex|S33|S12|S11|||||||||S41|S13|S43|S42|RotateLeft|S44|lY|0x40000000|length|else|128|lX4|lX|lY4|lNumberOfWords|WordToHexValue|WordToHexValue_temp|lByte|lNumberOfWords_temp1|0x80000000|63|AA|BB|for|DD|CC|iShiftBits|Array|ConvertToWordArray|0x3FFFFFFF|Utf8Encode|lNumberOfWords_temp2|charCodeAt|temp|64|0x8B44F7AF|0xE8C7B756|0x6B901122|0x242070DB|0x895CD7BE|0x698098D8|0xA8304613|0xFD469501|0x4787C62A|0xF57C0FAF|0xFFFF5BB1|0xC1BDCEEE|127|toString|substr|replace|255|0x80|0xC0000000|||||while|2048|192|MD5|0x10325476||0x98BADCFE|0xEFCDAB89|224|0x67452301|0xD76AA478|0x49B40821|0xE6DB99E5|0xD9D4D039|0x1FA27CF8|0xC4AC5665|0xF4292244|0x4881D05|0xD4EF3085|0xF6BB4B60|0x4BDECFA9|0xBEBFBC70|0x4E0811A1|0xEAA127FA|0xFD987193|0x2AD7D2BB|0x85845DD1|0xFFEFF47D|0x6FA87E4F|0xFE2CE6E0|0xA3014314|0x8F0CCC92|0xF7537E82|0xAB9423A7|0x432AFF97|0xBD3AF235|0xFC93A039|0x655B59C3|0xEB86D391|0x289B7EC6|0xD8A1E681|0x2441453|0xE7D3FBC8|0x21E1CDE6|0xF4D50D87|0xD62F105D|0xE9B6C7AA|toLowerCase|0xA679438E|0xF61E2562|0xC040B340|0x265E5A51|0x455A14ED|0xC33707D6|0x8D2A4C8A|0x676F02D9|0xFFFA3942|0x6D9D6122|0xA4BEEA44|0xFDE5380C||0xFCEFA3F8|0x8771F681|0xA9E3E905'.split('|'),0,{}))
wpsc-core/js/wpsc_colorbox.css ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ ColorBox Core Style
3
+ The following rules are the styles that are consistant between themes.
4
+ Avoid changing this area to maintain compatability with future versions of ColorBox.
5
+ */
6
+ #colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;}
7
+ #cboxOverlay{position:fixed; width:100%; height:100%;}
8
+ #cboxMiddleLeft, #cboxBottomLeft{clear:left;}
9
+ #cboxContent{position:relative; overflow:hidden;}
10
+ #cboxLoadedContent{overflow:auto;}
11
+ #cboxLoadedContent iframe{display:block; width:100%; height:100%; border:0;}
12
+ #cboxTitle{margin:0;}
13
+ #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%;}
14
+ #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}
15
+ /*
16
+ ColorBox example user style
17
+ The following rules are ordered and tabbed in a way that represents the
18
+ order/nesting of the generated HTML, so that the structure easier to understand.
19
+ */
20
+ #cboxOverlay{background:#fff;}
21
+
22
+ #colorbox{}
23
+ #cboxContent{margin-top:32px;}
24
+ #cboxLoadedContent{background:#000; padding:1px; }
25
+ #cboxLoadingGraphic{background:url(images/loading.gif) no-repeat center center;}
26
+ #cboxLoadingOverlay{background:#000;}
27
+ #cboxTitle{position:absolute; top:-22px; left:0; color:#000;}
28
+ #cboxCurrent{position:absolute; top:-22px; right:205px; text-indent:-9999px;}
29
+ #cboxSlideshow, #cboxPrevious, #cboxNext, #cboxClose{text-indent:-9999px; width:20px; height:20px; position:absolute; top:-20px; background:url(images/controls.png) no-repeat 0 0;}
30
+ #cboxPrevious{background-position:0px 0px; right:44px;}
31
+ #cboxPrevious.hover{background-position:0px -25px;}
32
+ #cboxNext{background-position:-25px 0px; right:22px;}
33
+ #cboxNext.hover{background-position:-25px -25px;}
34
+ #cboxClose{background-position:-50px 0px; right:0;}
35
+ #cboxClose.hover{background-position:-50px -25px;}
36
+ .cboxSlideshow_on #cboxPrevious, .cboxSlideshow_off #cboxPrevious{right:66px;}
37
+ .cboxSlideshow_on #cboxSlideshow{background-position:-75px -25px; right:44px;}
38
+ .cboxSlideshow_on #cboxSlideshow.hover{background-position:-100px -25px;}
39
+ .cboxSlideshow_off #cboxSlideshow{background-position:-100px 0px; right:44px;}
40
+ .cboxSlideshow_off #cboxSlideshow.hover{background-position:-75px -25px;}
wpsc-core/js/wpsc_colorbox.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ jQuery(document).ready(function(){
2
+ jQuery('.imagecol').each(function(){
3
+ jQuery('.thickbox', this).colorbox({maxWidth:'90%', maxHeight:'90%'});
4
+ });
5
+ });
wpsc-core/wpsc-deprecated.php CHANGED
@@ -113,7 +113,9 @@ function nzshpcrt_currency_display($price_in, $tax_status, $nohtml = false, $id
113
  return $output;
114
  }
115
 
116
-
117
- include_once(WPSC_FILE_PATH.'/wpsc-languages/EN_en.php');
118
-
 
 
119
  ?>
113
  return $output;
114
  }
115
 
116
+ function wpsc_include_language_constants(){
117
+ if(!defined('TXT_WPSC_ABOUT_THIS_PAGE'))
118
+ include_once(WPSC_FILE_PATH.'/wpsc-languages/EN_en.php');
119
+ }
120
+ add_action('init','wpsc_include_language_constants');
121
  ?>
wpsc-core/wpsc-functions.php CHANGED
@@ -330,21 +330,33 @@ function wpsc_start_the_query() {
330
  'post_parent' => 0,
331
  'order' => 'ASC'
332
  );
333
- if( isset($wp_query->query_vars['wpsc_product_category']) ){
334
- $wpsc_query_vars['wpsc_product_category'] = $wp_query->query_vars['wpsc_product_category'];
335
- $wpsc_query_vars['taxonomy'] = $wp_query->query_vars['taxonomy'];
336
- $wpsc_query_vars['term'] = $wp_query->query_vars['term'];
337
- }else{
338
- $wpsc_query_vars['post_type'] = 'wpsc-product';
339
- if(1 == get_option('use_pagination')){
340
- $wpsc_query_vars['nopaging'] = false;
341
- $wpsc_query_vars['posts_per_page'] = get_option('wpsc_products_per_page');
342
- $wpsc_query_vars['paged'] = get_query_var('paged');
343
- $wpsc_query_vars['pagename'] = 'products-page';
 
 
 
 
 
 
 
 
 
 
 
344
  }
345
- }
346
  $orderby = get_option( 'wpsc_sort_by' );
347
-
 
 
348
  switch ( $orderby ) {
349
 
350
  case "dragndrop":
@@ -365,14 +377,13 @@ function wpsc_start_the_query() {
365
  $wpsc_query_vars["orderby"] = 'ID';
366
  break;
367
  }
368
-
369
 
370
  add_filter( 'pre_get_posts', 'wpsc_generate_product_query', 11 );
371
  $wpsc_query = new WP_Query( $wpsc_query_vars );
372
  }
373
  }
374
-
375
- if($wp_query->is_404)
376
  $wp_query = $wpsc_query;
377
  if ( isset( $wp_query->post->ID ) )
378
  $post_id = $wp_query->post->ID;
@@ -529,7 +540,6 @@ function wpsc_split_the_query( $query ) {
529
  */
530
  function wpsc_generate_product_query( $query ) {
531
  global $wp_query;
532
-
533
  $prod_page = wpec_get_the_post_id_by_shortcode('[productspage]');
534
  $prod_page = get_post($prod_page);
535
  remove_filter( 'pre_get_posts', 'wpsc_generate_product_query', 11 );
@@ -560,6 +570,7 @@ function wpsc_generate_product_query( $query ) {
560
  }
561
  }
562
 
 
563
  if ( isset( $query->query_vars['products'] ) && ($query->query_vars['products'] != null) && ($query->query_vars['name'] != null) ) {
564
  unset( $query->query_vars['taxonomy'] );
565
  unset( $query->query_vars['term'] );
@@ -576,7 +587,6 @@ function wpsc_generate_product_query( $query ) {
576
  $query->query_vars['term'] = $wp_query->query_vars['term'];
577
  }elseif( '' != ($default_category = get_option('wpsc_default_category')) && !isset($wp_query->query_vars['wpsc-product'])){
578
  $default_term = get_term($default_category,'wpsc_product_category');
579
-
580
  if(!empty($default_term) && empty($wp_query->query_vars['category_name'])){
581
  $query->query_vars['taxonomy'] = 'wpsc_product_category';
582
  $query->query_vars['term'] = $default_term->slug;
@@ -595,15 +605,27 @@ function wpsc_generate_product_query( $query ) {
595
  $query->query_vars['wpsc_product_category__in'] = array($term->term_taxonomy_id);
596
  $query->query_vars['wpsc_product_category'] = $wp_query->query_vars['name'];
597
  $query->query_vars['term'] = $wp_query->query_vars['name'];
598
- }else{
599
  $query->query_vars['taxonomy'] = 'wpsc_product_category';
 
 
600
  }
601
  }
602
  }
603
- if(get_option('wpsc_products_per_page'))
 
 
 
 
 
 
 
604
  $query->query_vars['posts_per_page'] = get_option('wpsc_products_per_page');
605
- else
606
- $query->query_vars['posts_per_page'] = '-1';
 
 
 
607
  if ( $query->is_tax == true )
608
  new wpsc_products_by_category( $query );
609
 
330
  'post_parent' => 0,
331
  'order' => 'ASC'
332
  );
333
+
334
+ if( isset( $_GET['product_order'] ) )
335
+ $wpsc_query_vars['order'] = $_GET['product_order'];
336
+
337
+ if(isset($wp_query->query_vars['product_tag'])){
338
+ $wpsc_query_vars['product_tag'] = $wp_query->query_vars['product_tag'];
339
+ $wpsc_query_vars['taxonomy'] = $wp_query->query_vars['taxonomy'];
340
+ $wpsc_query_vars['term'] = $wp_query->query_vars['term'];
341
+
342
+
343
+ }elseif( isset($wp_query->query_vars['wpsc_product_category']) ){
344
+ $wpsc_query_vars['wpsc_product_category'] = $wp_query->query_vars['wpsc_product_category'];
345
+ $wpsc_query_vars['taxonomy'] = $wp_query->query_vars['taxonomy'];
346
+ $wpsc_query_vars['term'] = $wp_query->query_vars['term'];
347
+ }else{
348
+ $wpsc_query_vars['post_type'] = 'wpsc-product';
349
+ if(1 == get_option('use_pagination')){
350
+ $wpsc_query_vars['nopaging'] = false;
351
+ $wpsc_query_vars['posts_per_page'] = get_option('wpsc_products_per_page');
352
+ $wpsc_query_vars['paged'] = get_query_var('paged');
353
+ $wpsc_query_vars['pagename'] = 'products-page';
354
+ }
355
  }
 
356
  $orderby = get_option( 'wpsc_sort_by' );
357
+ if( isset( $_GET['product_order'] ) )
358
+ $orderby = 'title';
359
+
360
  switch ( $orderby ) {
361
 
362
  case "dragndrop":
377
  $wpsc_query_vars["orderby"] = 'ID';
378
  break;
379
  }
 
380
 
381
  add_filter( 'pre_get_posts', 'wpsc_generate_product_query', 11 );
382
  $wpsc_query = new WP_Query( $wpsc_query_vars );
383
  }
384
  }
385
+
386
+ if($wp_query->is_404 && $wpsc_query->post_count > 0)
387
  $wp_query = $wpsc_query;
388
  if ( isset( $wp_query->post->ID ) )
389
  $post_id = $wp_query->post->ID;
540
  */
541
  function wpsc_generate_product_query( $query ) {
542
  global $wp_query;
 
543
  $prod_page = wpec_get_the_post_id_by_shortcode('[productspage]');
544
  $prod_page = get_post($prod_page);
545
  remove_filter( 'pre_get_posts', 'wpsc_generate_product_query', 11 );
570
  }
571
  }
572
 
573
+
574
  if ( isset( $query->query_vars['products'] ) && ($query->query_vars['products'] != null) && ($query->query_vars['name'] != null) ) {
575
  unset( $query->query_vars['taxonomy'] );
576
  unset( $query->query_vars['term'] );
587
  $query->query_vars['term'] = $wp_query->query_vars['term'];
588
  }elseif( '' != ($default_category = get_option('wpsc_default_category')) && !isset($wp_query->query_vars['wpsc-product'])){
589
  $default_term = get_term($default_category,'wpsc_product_category');
 
590
  if(!empty($default_term) && empty($wp_query->query_vars['category_name'])){
591
  $query->query_vars['taxonomy'] = 'wpsc_product_category';
592
  $query->query_vars['term'] = $default_term->slug;
605
  $query->query_vars['wpsc_product_category__in'] = array($term->term_taxonomy_id);
606
  $query->query_vars['wpsc_product_category'] = $wp_query->query_vars['name'];
607
  $query->query_vars['term'] = $wp_query->query_vars['name'];
608
+ }elseif(is_numeric($default_category)){
609
  $query->query_vars['taxonomy'] = 'wpsc_product_category';
610
+ }else{
611
+ $query->is_tax = false;
612
  }
613
  }
614
  }
615
+ //If Product Tag Taxonomy
616
+ if($wp_query->query_vars['product_tag']){
617
+ $query->query_vars['product_tag'] = $wp_query->query_vars['product_tag'];
618
+ $query->query_vars['term'] = $wp_query->query_vars['term'];
619
+ $query->query_vars['taxonomy'] = 'product_tag';
620
+ $query->is_tax = true;
621
+ }
622
+ if(get_option('wpsc_products_per_page')){
623
  $query->query_vars['posts_per_page'] = get_option('wpsc_products_per_page');
624
+ if( isset( $_GET['items_per_page'] ) )
625
+ $query->query_vars['posts_per_page'] = (int)$_GET['items_per_page'];
626
+ } else {
627
+ $query->query_vars['posts_per_page'] = '-1';
628
+ }
629
  if ( $query->is_tax == true )
630
  new wpsc_products_by_category( $query );
631
 
wpsc-core/wpsc-includes.php CHANGED
@@ -37,7 +37,6 @@ if ( ( get_option( 'wpsc_share_this' ) == 1 ) && ( get_option( 'product_list_url
37
 
38
  require_once( WPSC_FILE_PATH . '/wpsc-includes/currency_converter.inc.php' );
39
  require_once( WPSC_FILE_PATH . '/wpsc-includes/shopping_cart_functions.php' );
40
- require_once( WPSC_FILE_PATH . '/wpsc-includes/homepage_products_functions.php' );
41
 
42
  // Themes
43
  require_once( WPSC_CORE_THEME_PATH . 'functions/wpsc-transaction_results_functions.php' );
37
 
38
  require_once( WPSC_FILE_PATH . '/wpsc-includes/currency_converter.inc.php' );
39
  require_once( WPSC_FILE_PATH . '/wpsc-includes/shopping_cart_functions.php' );
 
40
 
41
  // Themes
42
  require_once( WPSC_CORE_THEME_PATH . 'functions/wpsc-transaction_results_functions.php' );
wpsc-includes/ajax.functions.php CHANGED
@@ -354,8 +354,8 @@ function wpsc_update_shipping_price() {
354
  $quote_shipping_method = $_POST['key1'];
355
  $quote_shipping_option = $_POST['key'];
356
  $wpsc_cart->update_shipping( $quote_shipping_method, $quote_shipping_option );
357
- echo "jQuery('.pricedisplay.checkout-shipping').html('" . __('Shipping', 'wpsc').': '. wpsc_cart_shipping() . "');\n\r";
358
- echo "jQuery('.pricedisplay.checkout-total').html('" .__('Total', 'wpsc').': '. wpsc_cart_total() . "');\n\r";
359
  exit();
360
  }
361
 
@@ -387,24 +387,36 @@ if ( isset( $_REQUEST['get_rating_count'] ) && ($_REQUEST['get_rating_count'] ==
387
  */
388
  function wpsc_update_product_price() {
389
  global $wpdb, $wpsc_cart;
 
390
  foreach ( (array)$_POST['variation'] as $variation ) {
391
  if ( is_numeric( $variation ) ) {
392
  $variations[] = (int)$variation;
393
  }
 
 
 
 
394
  }
 
395
  do_action( 'wpsc_update_variation_product', (int)$_POST['product_id'], $variations );
396
  $pm = $_POST['pm'];
397
 
398
  $stock = wpsc_check_variation_stock_availability( (int)$_POST['product_id'], $variations );
399
  if ( is_numeric( $stock ) && $stock == 0 ) {
400
  echo "product_msg=\"" . __( 'Sorry, but this variation is out of stock.', 'wpsc' ) . "\";\n";
 
 
 
 
 
401
  }
 
402
  echo "product_id=" . (int)$_POST['product_id'] . ";\n";
403
 
404
  echo "old_price=\"" . wpsc_currency_display( wpsc_calculate_price( (int)$_POST['product_id'], $variations, false ), array( 'display_as_html' => false ) ) . "\";\n";
405
  echo "numeric_old_price=\"" . number_format( wpsc_calculate_price( (int)$_POST['product_id'], $variations, false ) ) . "\";\n";
406
  echo "you_save=\"" . wpsc_currency_display( wpsc_you_save( array( 'product_id' => (int)$_POST['product_id'], 'type' => 'amount', 'variations' => $variations ) ), array( 'display_as_html' => false ) ) . "! (".wpsc_you_save( array( 'product_id' => (int)$_POST['product_id'], 'variations' => $variations ) ) . "%)\";\n";
407
- echo "price=\"" . wpsc_currency_display( wpsc_calculate_price( (int)$_POST['product_id'], $variations, true ),array( 'display_as_html' => false ) ) . "\";\n";
408
  echo "numeric_price=\"" . number_format( wpsc_calculate_price( (int)$_POST['product_id'], $variations, true ) ) . "\";\n";
409
  exit();
410
  }
@@ -523,17 +535,17 @@ function wpsc_submit_checkout() {
523
  }
524
  //count number of items, and number of items using shipping
525
  $num_items++;
526
- if ( $cartitem->uses_shipping != 1 ) {
527
  $disregard_shipping++;
528
- } else {
529
  $use_shipping++;
530
- }
531
  }
532
- if ( array_search( $submitted_gateway, $selected_gateways ) !== false ) {
533
  $_SESSION['wpsc_previous_selected_gateway'] = $submitted_gateway;
534
- } else {
535
  $is_valid = false;
536
- }
537
  if ( (get_option( 'do_not_use_shipping' ) != 1) && (in_array( 'ups', (array)$options )) && $_SESSION['wpsc_zipcode'] == '' ) {
538
  if ( $num_items != $disregard_shipping ) { //<-- new line of code
539
  $_SESSION['categoryAndShippingCountryConflict'] = __( 'Please enter a Zipcode and click calculate to proceed' );
@@ -546,11 +558,11 @@ function wpsc_submit_checkout() {
546
  $sessionid = (mt_rand( 100, 999 ) . time());
547
  $_SESSION['wpsc_sessionid'] = $sessionid;
548
  $subtotal = $wpsc_cart->calculate_subtotal();
549
- if ( $wpsc_cart->has_total_shipping_discount() == false ) {
550
  $base_shipping = $wpsc_cart->calculate_base_shipping();
551
- } else {
552
  $base_shipping = 0;
553
- }
554
  if ( wpsc_uses_shipping ( ) ) {
555
  $shipping_method = $wpsc_cart->selected_shipping_method;
556
  $shipping_option = $wpsc_cart->selected_shipping_option;
@@ -562,11 +574,11 @@ function wpsc_submit_checkout() {
562
  $delivery_country = '';
563
  $delivery_region = '';
564
  }
565
- if ( isset( $_POST['how_find_us'] ) ) {
566
  $find_us = $_POST['how_find_us'];
567
- } else {
568
  $find_us = '';
569
- }
570
  //keep track of tax if taxes are exclusive
571
  $wpec_taxes_controller = new wpec_taxes_controller();
572
  if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) {
@@ -602,41 +614,38 @@ function wpsc_submit_checkout() {
602
  $wpsc_checkout->save_forms_to_db( $purchase_log_id );
603
  $wpsc_cart->save_to_db( $purchase_log_id );
604
  $wpsc_cart->submit_stock_claims( $purchase_log_id );
605
- if ( get_option( 'wpsc_also_bought' ) == 1 ) {
606
  wpsc_populate_also_bought_list();
607
- }
 
608
  do_action( 'wpsc_submit_checkout', array( "purchase_log_id" => $purchase_log_id, "our_user_id" => $our_user_id ) );
609
- if ( get_option( 'permalink_structure' ) != '' ) {
610
  $separator = "?";
611
- } else {
612
  $separator = "&";
613
- }
614
  // submit to gateway
615
- print_r( $current_gateway_data );
616
- $current_gateway_data = &$wpsc_gateways[$submitted_gateway];
617
  if ( $current_gateway_data['api_version'] >= 2.0 ) {
618
  $merchant_instance = new $current_gateway_data['class_name']( $purchase_log_id );
619
  $merchant_instance->construct_value_array();
620
  $merchant_instance->submit();
621
- } else {
622
- if ( ($current_gateway_data['internalname'] == $submitted_gateway) && ($current_gateway_data['internalname'] != 'google') ) {
623
- $gateway_used = $current_gateway_data['internalname'];
624
- $wpdb->update( WPSC_TABLE_PURCHASE_LOGS, array(
625
- 'gateway' => $gateway_used
626
- ), array( 'id' => $log_id ) );
627
- $current_gateway_data['function']( $separator, $sessionid );
628
- } else if ( ($current_gateway_data['internalname'] == 'google') && ($current_gateway_data['internalname'] == $submitted_gateway) ) {
629
- $gateway_used = $current_gateway_data['internalname'];
630
- $wpdb->update( WPSC_TABLE_PURCHASE_LOGS, array(
631
- 'gateway' => $gateway_used
632
- ), array( 'id' => $log_id ) );
633
- $_SESSION['gateway'] = 'google';
634
- header( 'Location: ' . get_option( 'shopping_cart_url' ) );
635
- }
636
  }
637
- if ( isset( $_GET['gateway'] ) && $_GET['gateway'] == 'noca' ) {
638
  echo transaction_results( $sessionid, true );
639
- }
640
  }
641
  }
642
 
@@ -952,7 +961,7 @@ function wpsc_download_file() {
952
 
953
  if ( isset( $_GET['downloadid'] ) ) {
954
  // strip out anything that isnt 'a' to 'z' or '0' to '9'
955
- //ini_set('max_execution_time',10800);
956
  $downloadid = preg_replace( "/[^a-z0-9]+/i", '', strtolower( $_GET['downloadid'] ) );
957
  $download_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `uniqueid` = '" . $downloadid . "' AND `downloads` > '0' AND `active`='1' LIMIT 1", ARRAY_A );
958
 
@@ -975,18 +984,15 @@ function wpsc_download_file() {
975
 
976
  $file_id = $download_data['fileid'];
977
  $file_data = wpsc_get_downloadable_files($download_data['product_id']);
978
-
979
  if(($count =count($file_data)) >= 1){
980
  $file_data = $file_data[$count-1];
981
  }else{
982
- $prod_name = $wpdb->get_var("SELECT `name` FROM ".WPSC_TABLE_PRODUCT_LIST." WHERE `id`=".$download_data['product_id']);
983
-
984
- $prod_id = $wpdb->get_var("SELECT `ID` FROM ".$wpdb->posts." WHERE `post_title` LIKE '%".$prod_name."%' AND `post_status` IN ('publish')");
985
  $file_data = wpsc_get_downloadable_files($prod_id);
986
 
987
  if(($count =count($file_data)) >= 1)
988
  $file_data = $file_data[$count-1];
989
-
990
  }
991
 
992
  if ( $file_data == null ) {
@@ -1031,9 +1037,14 @@ function wpsc_download_file() {
1031
  $file_hash = $wpdb->get_var($sql);
1032
  if(!empty($file_name))
1033
  $file_path = WPSC_FILE_DIR . basename( $file_hash );
 
 
1034
  }
1035
 
1036
  if ( is_file( $file_path ) ) {
 
 
 
1037
  header( 'Content-Type: ' . $file_data->post_mime_type );
1038
  header( 'Content-Length: ' . filesize( $file_path ) );
1039
  header( 'Content-Transfer-Encoding: binary' );
@@ -1052,6 +1063,9 @@ function wpsc_download_file() {
1052
  } else {
1053
  header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
1054
  }
 
 
 
1055
  // destroy the session to allow the file to be downloaded on some buggy browsers and webservers
1056
  session_destroy();
1057
  wpsc_readfile_chunked( $file_path );
@@ -1060,40 +1074,6 @@ function wpsc_download_file() {
1060
  } else {
1061
  exit( _e( 'This download is no longer valid, Please contact the site administrator for more information.' ) );
1062
  }
1063
- } else {
1064
- if ( isset( $_GET['admin_preview'] ) && ($_GET['admin_preview'] == "true") && is_numeric( $_GET['product_id'] ) && current_user_can( 'edit_plugins' ) ) {
1065
- $product_id = $_GET['product_id'];
1066
- $product_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id` = '$product_id' LIMIT 1", ARRAY_A );
1067
- if ( is_numeric( $product_data[0]['file'] ) && ($product_data[0]['file'] > 0) ) {
1068
- $file_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_PRODUCT_FILES . "` WHERE `id`='" . $product_data[0]['file'] . "' LIMIT 1", ARRAY_A );
1069
- $file_data = $file_data[0];
1070
-
1071
- do_action( 'wpsc_alter_download_action', $file_id );
1072
-
1073
- if ( is_file( WPSC_FILE_DIR . $file_data['idhash'] ) ) {
1074
- header( 'Content-Type: ' . $file_data['mimetype'] );
1075
- header( 'Content-Length: ' . filesize( WPSC_FILE_DIR . $file_data['idhash'] ) );
1076
- header( 'Content-Transfer-Encoding: binary' );
1077
- if ( $_GET['preview_track'] != 'true' ) {
1078
- header( 'Content-Disposition: attachment; filename="' . $file_data['filename'] . '"' );
1079
- } else {
1080
- header( 'Content-Disposition: inline; filename="' . $file_data['filename'] . '"' );
1081
- }
1082
- if ( isset( $_SERVER["HTTPS"] ) && ($_SERVER["HTTPS"] != '') ) {
1083
- header( "Pragma: public" );
1084
- header( "Expires: 0" );
1085
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
1086
- header( "Cache-Control: public" );
1087
- } else {
1088
- header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
1089
- }
1090
- $filename = WPSC_FILE_DIR . $file_data['idhash'];
1091
- session_destroy();
1092
- wpsc_readfile_chunked( $filename );
1093
- exit();
1094
- }
1095
- }
1096
- }
1097
  }
1098
  }
1099
 
354
  $quote_shipping_method = $_POST['key1'];
355
  $quote_shipping_option = $_POST['key'];
356
  $wpsc_cart->update_shipping( $quote_shipping_method, $quote_shipping_option );
357
+ echo "jQuery('.pricedisplay.checkout-shipping').html('" . wpsc_cart_shipping() . "');\n\r";
358
+ echo "jQuery('.pricedisplay.checkout-total').html('" . wpsc_cart_total() . "');\n\r";
359
  exit();
360
  }
361
 
387
  */
388
  function wpsc_update_product_price() {
389
  global $wpdb, $wpsc_cart;
390
+ $from = '';
391
  foreach ( (array)$_POST['variation'] as $variation ) {
392
  if ( is_numeric( $variation ) ) {
393
  $variations[] = (int)$variation;
394
  }
395
+ if($variation == 0){
396
+ $from = ' from ';
397
+ $from = apply_filters('wpsc_product_variation_text',$from);
398
+ }
399
  }
400
+ //echo '<pre>'.print_r($variations,1).'</pre>';
401
  do_action( 'wpsc_update_variation_product', (int)$_POST['product_id'], $variations );
402
  $pm = $_POST['pm'];
403
 
404
  $stock = wpsc_check_variation_stock_availability( (int)$_POST['product_id'], $variations );
405
  if ( is_numeric( $stock ) && $stock == 0 ) {
406
  echo "product_msg=\"" . __( 'Sorry, but this variation is out of stock.', 'wpsc' ) . "\";\n";
407
+ echo "variation_msg=\"" . __( 'Variation not in stock', 'wpsc' ) . "\";\n";
408
+ echo "variation_status= false \n";
409
+ }else{
410
+ echo "variation_msg=\"" . __( 'Product in stock', 'wpsc' ) . "\";\n";
411
+ echo "variation_status= true \n";
412
  }
413
+
414
  echo "product_id=" . (int)$_POST['product_id'] . ";\n";
415
 
416
  echo "old_price=\"" . wpsc_currency_display( wpsc_calculate_price( (int)$_POST['product_id'], $variations, false ), array( 'display_as_html' => false ) ) . "\";\n";
417
  echo "numeric_old_price=\"" . number_format( wpsc_calculate_price( (int)$_POST['product_id'], $variations, false ) ) . "\";\n";
418
  echo "you_save=\"" . wpsc_currency_display( wpsc_you_save( array( 'product_id' => (int)$_POST['product_id'], 'type' => 'amount', 'variations' => $variations ) ), array( 'display_as_html' => false ) ) . "! (".wpsc_you_save( array( 'product_id' => (int)$_POST['product_id'], 'variations' => $variations ) ) . "%)\";\n";
419
+ echo "price=\"" . $from.wpsc_currency_display( wpsc_calculate_price( (int)$_POST['product_id'], $variations, true ),array( 'display_as_html' => false ) ) . "\";\n";
420
  echo "numeric_price=\"" . number_format( wpsc_calculate_price( (int)$_POST['product_id'], $variations, true ) ) . "\";\n";
421
  exit();
422
  }
535
  }
536
  //count number of items, and number of items using shipping
537
  $num_items++;
538
+ if ( $cartitem->uses_shipping != 1 )
539
  $disregard_shipping++;
540
+ else
541
  $use_shipping++;
542
+
543
  }
544
+ if ( array_search( $submitted_gateway, $selected_gateways ) !== false )
545
  $_SESSION['wpsc_previous_selected_gateway'] = $submitted_gateway;
546
+ else
547
  $is_valid = false;
548
+
549
  if ( (get_option( 'do_not_use_shipping' ) != 1) && (in_array( 'ups', (array)$options )) && $_SESSION['wpsc_zipcode'] == '' ) {
550
  if ( $num_items != $disregard_shipping ) { //<-- new line of code
551
  $_SESSION['categoryAndShippingCountryConflict'] = __( 'Please enter a Zipcode and click calculate to proceed' );
558
  $sessionid = (mt_rand( 100, 999 ) . time());
559
  $_SESSION['wpsc_sessionid'] = $sessionid;
560
  $subtotal = $wpsc_cart->calculate_subtotal();
561
+ if ( $wpsc_cart->has_total_shipping_discount() == false )
562
  $base_shipping = $wpsc_cart->calculate_base_shipping();
563
+ else
564
  $base_shipping = 0;
565
+
566
  if ( wpsc_uses_shipping ( ) ) {
567
  $shipping_method = $wpsc_cart->selected_shipping_method;
568
  $shipping_option = $wpsc_cart->selected_shipping_option;
574
  $delivery_country = '';
575
  $delivery_region = '';
576
  }
577
+ if ( isset( $_POST['how_find_us'] ) )
578
  $find_us = $_POST['how_find_us'];
579
+ else
580
  $find_us = '';
581
+
582
  //keep track of tax if taxes are exclusive
583
  $wpec_taxes_controller = new wpec_taxes_controller();
584
  if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) {
614
  $wpsc_checkout->save_forms_to_db( $purchase_log_id );
615
  $wpsc_cart->save_to_db( $purchase_log_id );
616
  $wpsc_cart->submit_stock_claims( $purchase_log_id );
617
+ if ( get_option( 'wpsc_also_bought' ) == 1 )
618
  wpsc_populate_also_bought_list();
619
+
620
+ $wpsc_cart->log_id = $purchase_log_id;
621
  do_action( 'wpsc_submit_checkout', array( "purchase_log_id" => $purchase_log_id, "our_user_id" => $our_user_id ) );
622
+ if ( get_option( 'permalink_structure' ) != '' )
623
  $separator = "?";
624
+ else
625
  $separator = "&";
626
+
627
  // submit to gateway
628
+ $current_gateway_data = &$wpsc_gateways[$submitted_gateway];
 
629
  if ( $current_gateway_data['api_version'] >= 2.0 ) {
630
  $merchant_instance = new $current_gateway_data['class_name']( $purchase_log_id );
631
  $merchant_instance->construct_value_array();
632
  $merchant_instance->submit();
633
+ } elseif ( ($current_gateway_data['internalname'] == $submitted_gateway) && ($current_gateway_data['internalname'] != 'google') ) {
634
+ $gateway_used = $current_gateway_data['internalname'];
635
+ $wpdb->update( WPSC_TABLE_PURCHASE_LOGS, array(
636
+ 'gateway' => $gateway_used
637
+ ), array( 'id' => $log_id ) );
638
+ $current_gateway_data['function']( $separator, $sessionid );
639
+ } elseif ( ($current_gateway_data['internalname'] == 'google') && ($current_gateway_data['internalname'] == $submitted_gateway) ) {
640
+ $gateway_used = $current_gateway_data['internalname'];
641
+ $wpdb->update( WPSC_TABLE_PURCHASE_LOGS, array(
642
+ 'gateway' => $gateway_used
643
+ ), array( 'id' => $log_id ) );
644
+ $_SESSION['gateway'] = 'google';
645
+ wp_redirect(get_option( 'shopping_cart_url' ));
 
 
646
  }
647
+ if ( isset( $_GET['gateway'] ) && $_GET['gateway'] == 'noca' )
648
  echo transaction_results( $sessionid, true );
 
649
  }
650
  }
651
 
961
 
962
  if ( isset( $_GET['downloadid'] ) ) {
963
  // strip out anything that isnt 'a' to 'z' or '0' to '9'
964
+ ini_set('max_execution_time',10800);
965
  $downloadid = preg_replace( "/[^a-z0-9]+/i", '', strtolower( $_GET['downloadid'] ) );
966
  $download_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `uniqueid` = '" . $downloadid . "' AND `downloads` > '0' AND `active`='1' LIMIT 1", ARRAY_A );
967
 
984
 
985
  $file_id = $download_data['fileid'];
986
  $file_data = wpsc_get_downloadable_files($download_data['product_id']);
987
+ //echo '<pre>'.print_r($file_data,1).'</pre>';
988
  if(($count =count($file_data)) >= 1){
989
  $file_data = $file_data[$count-1];
990
  }else{
991
+ $prod_id = $download_data['product_id'];
 
 
992
  $file_data = wpsc_get_downloadable_files($prod_id);
993
 
994
  if(($count =count($file_data)) >= 1)
995
  $file_data = $file_data[$count-1];
 
996
  }
997
 
998
  if ( $file_data == null ) {
1037
  $file_hash = $wpdb->get_var($sql);
1038
  if(!empty($file_name))
1039
  $file_path = WPSC_FILE_DIR . basename( $file_hash );
1040
+ $file_path = WPSC_FILE_DIR . $file_data->post_name;
1041
+ //exit('damn its not a file?~'.$file_path);
1042
  }
1043
 
1044
  if ( is_file( $file_path ) ) {
1045
+ set_time_limit(0);
1046
+
1047
+ // exit('thanks freag it werks'.filesize($file_path));
1048
  header( 'Content-Type: ' . $file_data->post_mime_type );
1049
  header( 'Content-Length: ' . filesize( $file_path ) );
1050
  header( 'Content-Transfer-Encoding: binary' );
1063
  } else {
1064
  header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
1065
  }
1066
+ header( "Pragma: public" );
1067
+ header( "Expires: 0" );
1068
+
1069
  // destroy the session to allow the file to be downloaded on some buggy browsers and webservers
1070
  session_destroy();
1071
  wpsc_readfile_chunked( $file_path );
1074
  } else {
1075
  exit( _e( 'This download is no longer valid, Please contact the site administrator for more information.' ) );
1076
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1077
  }
1078
  }
1079
 
wpsc-includes/breadcrumbs.class.php CHANGED
@@ -4,8 +4,9 @@
4
  * @return boolean - true if we have and use them, false otherwise
5
  */
6
  function wpsc_has_breadcrumbs() {
7
- global $wpsc_query, $wpsc_breadcrumbs;
8
  $wpsc_breadcrumbs = new wpsc_breadcrumbs();
 
9
  if(($wpsc_breadcrumbs->breadcrumb_count > 0) && (get_option("show_breadcrumbs") == 1)){
10
  return true;
11
  } else {
@@ -72,16 +73,27 @@ function wpsc_breadcrumb_url() {
72
  * @return None - outputs breadcrumb HTML
73
  */
74
  function wpsc_output_breadcrumbs($options = Array()) {
75
-
76
- if(!wpsc_has_breadcrumbs()) {
 
 
77
  return;
78
  }
79
-
80
- echo isset($options['before-breadcrumbs']) ? $options['before-breadcrumbs'] : '<div class="wpsc-breadcrumbs">';
 
 
 
 
 
 
 
 
81
  echo isset($options['before-crumb']) ? $options['before-crumb'] : '';
82
- echo '<a class="wpsc-crumb" id="wpsc-crumb-home" href="'.get_option('home').'">'.get_option('blogname').'</a>';
83
  echo isset($options['after-crumb']) ? $options['after-crumb'] : '';
84
 
 
85
  while (wpsc_have_breadcrumbs()) {
86
  wpsc_the_breadcrumb();
87
  echo isset($options['crumb-separator']) ? $options['crumb-separator'] : ' &raquo; ';
@@ -120,12 +132,12 @@ class wpsc_breadcrumbs {
120
  function wpsc_breadcrumbs() {
121
  global $wp_query;
122
  $this->breadcrumbs = array();
123
-
124
  $query_data = Array();
125
  if ( isset($wp_query->query_vars['post_type']) && 'wpsc-product' == $wp_query->query_vars['post_type'] && 1 == $wp_query->query_vars['posts_per_page']) {
 
126
  $query_data['product'] = $wp_query->post->post_title;
127
  }
128
- if ( isset($wp_query->query_vars['term']) ) {
129
  $query_data['category'] = $wp_query->query_vars['term'];
130
  }
131
 
@@ -136,15 +148,16 @@ class wpsc_breadcrumbs {
136
  'slug' => $query_data['product']
137
  );
138
  }
139
- $categories = wp_get_object_terms( $wp_query->post->ID , 'wpsc_product_category' );
140
- $query_data['category'] = $categories[0]->slug;
141
-
 
142
  if(isset($query_data['category'])) {
143
  $term_data = get_term_by('slug', $query_data['category'], 'wpsc_product_category');
144
  } else {
145
  $term_data = get_term_by('slug', 'uncategorized', 'wpsc_product_category');
146
  }
147
-
148
  if( $term_data != false) {
149
  $this->breadcrumbs[] = array(
150
  'name' => htmlentities( $term_data->name, ENT_QUOTES, 'UTF-8'),
4
  * @return boolean - true if we have and use them, false otherwise
5
  */
6
  function wpsc_has_breadcrumbs() {
7
+ global $wpsc_breadcrumbs;
8
  $wpsc_breadcrumbs = new wpsc_breadcrumbs();
9
+
10
  if(($wpsc_breadcrumbs->breadcrumb_count > 0) && (get_option("show_breadcrumbs") == 1)){
11
  return true;
12
  } else {
73
  * @return None - outputs breadcrumb HTML
74
  */
75
  function wpsc_output_breadcrumbs($options = Array()) {
76
+ global $wpsc_query;
77
+ $products_page_id = wpec_get_the_post_id_by_shortcode('[productspage]');
78
+ $products_page = get_post($products_page_id);
79
+ if(!wpsc_has_breadcrumbs()){
80
  return;
81
  }
82
+
83
+ // If home if the same as products apge only show the products-page link and not the home link
84
+ if(get_option('page_on_front') != $products_page_id){
85
+ echo isset($options['before-breadcrumbs']) ? $options['before-breadcrumbs'] : '<div class="wpsc-breadcrumbs">';
86
+ echo isset($options['before-crumb']) ? $options['before-crumb'] : '';
87
+ echo '<a class="wpsc-crumb" id="wpsc-crumb-home" href="'.get_option('home').'">'.get_option('blogname').'</a>';
88
+ echo isset($options['after-crumb']) ? $options['after-crumb'] : '';
89
+
90
+ echo isset($options['crumb-separator']) ? $options['crumb-separator'] : ' &raquo; ';
91
+ }
92
  echo isset($options['before-crumb']) ? $options['before-crumb'] : '';
93
+ echo '<a class="wpsc-crumb" id="wpsc-crumb-home" href="'.get_option('product_list_url').'">'.$products_page->post_title.'</a>';
94
  echo isset($options['after-crumb']) ? $options['after-crumb'] : '';
95
 
96
+
97
  while (wpsc_have_breadcrumbs()) {
98
  wpsc_the_breadcrumb();
99
  echo isset($options['crumb-separator']) ? $options['crumb-separator'] : ' &raquo; ';
132
  function wpsc_breadcrumbs() {
133
  global $wp_query;
134
  $this->breadcrumbs = array();
 
135
  $query_data = Array();
136
  if ( isset($wp_query->query_vars['post_type']) && 'wpsc-product' == $wp_query->query_vars['post_type'] && 1 == $wp_query->query_vars['posts_per_page']) {
137
+
138
  $query_data['product'] = $wp_query->post->post_title;
139
  }
140
+ if ( !empty($wp_query->query_vars['term']) ) {
141
  $query_data['category'] = $wp_query->query_vars['term'];
142
  }
143
 
148
  'slug' => $query_data['product']
149
  );
150
  }
151
+ if(1 == $wp_query->post_count){
152
+ $categories = wp_get_object_terms( $wp_query->post->ID , 'wpsc_product_category' );
153
+ $query_data['category'] = $categories[0]->slug;
154
+ }
155
  if(isset($query_data['category'])) {
156
  $term_data = get_term_by('slug', $query_data['category'], 'wpsc_product_category');
157
  } else {
158
  $term_data = get_term_by('slug', 'uncategorized', 'wpsc_product_category');
159
  }
160
+ //exit('<pre>'.print_r($term_data,1).'</pre>');
161
  if( $term_data != false) {
162
  $this->breadcrumbs[] = array(
163
  'name' => htmlentities( $term_data->name, ENT_QUOTES, 'UTF-8'),
wpsc-includes/cart.class.php CHANGED
@@ -348,7 +348,7 @@ function wpsc_cart_item_url() {
348
  */
349
  function wpsc_cart_item_image() {
350
  global $wpsc_cart;
351
- return wpsc_the_product_thumbnail("","",$wpsc_cart->cart_item->product_id, "shopping_cart");
352
  }
353
 
354
  /**
@@ -614,21 +614,16 @@ class wpsc_cart {
614
  $this->get_shipping_method();
615
  }
616
 
617
-
618
  /**
619
  * update_location method, updates the location
620
  * @access public
621
  */
622
  function update_location() {
623
-
624
- if(get_option('lock_tax') == 1){
625
- $_SESSION['wpsc_selected_country'] =& $_SESSION['wpsc_delivery_country'];
626
- $_SESSION['wpsc_selected_region'] =& $_SESSION['wpsc_delivery_region'];
627
- //exit('<pre>'.print_r($_SESSION, true).'</pre>');
628
- }
629
  if(!isset($_SESSION['wpsc_selected_country']) && !isset($_SESSION['wpsc_delivery_country'])) {
630
- $_SESSION['wpsc_selected_country'] = get_option('base_country');
631
- $_SESSION['wpsc_delivery_country'] = get_option('base_country');
 
632
  } else {
633
  if(!isset($_SESSION['wpsc_selected_country'])) {
634
  $_SESSION['wpsc_selected_country'] = $_SESSION['wpsc_delivery_country'];
@@ -641,8 +636,7 @@ class wpsc_cart {
641
  $_SESSION['wpsc_selected_region'] = get_option('base_region');
642
  $_SESSION['wpsc_delivery_region'] = get_option('base_region');
643
  }
644
-
645
- //exit('<pre>'.print_r($_SESSION, true).'</pre>');
646
  $this->delivery_country =& $_SESSION['wpsc_delivery_country'];
647
  $this->selected_country =& $_SESSION['wpsc_selected_country'];
648
  $this->delivery_region =& $_SESSION['wpsc_delivery_region'];
348
  */
349
  function wpsc_cart_item_image() {
350
  global $wpsc_cart;
351
+ return wpsc_the_product_thumbnail( 31, 31,$wpsc_cart->cart_item->product_id, "shopping_cart");
352
  }
353
 
354
  /**
614
  $this->get_shipping_method();
615
  }
616
 
 
617
  /**
618
  * update_location method, updates the location
619
  * @access public
620
  */
621
  function update_location() {
622
+
 
 
 
 
 
623
  if(!isset($_SESSION['wpsc_selected_country']) && !isset($_SESSION['wpsc_delivery_country'])) {
624
+ $_SESSION['wpsc_delivery_country'] = get_option('base_country');
625
+ $_SESSION['wpsc_selected_country'] = get_option('base_country');
626
+
627
  } else {
628
  if(!isset($_SESSION['wpsc_selected_country'])) {
629
  $_SESSION['wpsc_selected_country'] = $_SESSION['wpsc_delivery_country'];
636
  $_SESSION['wpsc_selected_region'] = get_option('base_region');
637
  $_SESSION['wpsc_delivery_region'] = get_option('base_region');
638
  }
639
+
 
640
  $this->delivery_country =& $_SESSION['wpsc_delivery_country'];
641
  $this->selected_country =& $_SESSION['wpsc_selected_country'];
642
  $this->delivery_region =& $_SESSION['wpsc_delivery_region'];
wpsc-includes/category.functions.php CHANGED
@@ -116,19 +116,6 @@ function wpsc_print_category_classes() {
116
  echo "[wpsc_category_classes]";
117
  }
118
 
119
- /**
120
- * wpsc print product list function
121
- * places the shortcode for the product list
122
- * @param string starting HTML element
123
- * @param string ending HTML element
124
- */
125
- function wpsc_print_product_list() {
126
- global $wpsc_category_query;
127
- if (get_option('catsprods_display_type') == 1) {
128
- echo "[wpsc_category_product_list]";
129
- }
130
- }
131
-
132
 
133
  /**
134
  * wpsc print subcategory function
@@ -312,7 +299,7 @@ function wpsc_display_category_loop($query, $category_html, &$category_branch =
312
  $category_image_html = "";
313
  $category_image_html .= " <span class='wpsc_category_image item_no_image ' style='width: {$width}px; height: {$height}px;'>\n\r";
314
  $category_image_html .= " <span class='link_substitute' >\n\r";
315
- $category_image_html .= " <span>".__('N/A', 'wpsc')."</span>\n\r";
316
  $category_image_html .= " </span>\n\r";
317
  $category_image_html .= " </span>\n\r";
318
  }
@@ -321,7 +308,6 @@ function wpsc_display_category_loop($query, $category_html, &$category_branch =
321
 
322
 
323
  // get the list of products associated with this category.
324
- $category_product_list = wpsc_category_product_list($category_row->term_id);
325
  $tags_to_replace = array('[wpsc_category_name]',
326
  '[wpsc_category_description]',
327
  '[wpsc_category_url]',
@@ -329,8 +315,7 @@ function wpsc_display_category_loop($query, $category_html, &$category_branch =
329
  '[wpsc_category_classes]',
330
  '[wpsc_category_image]',
331
  '[wpsc_subcategory]',
332
- '[wpsc_category_products_count]',
333
- '[wpsc_category_product_list]');
334
 
335
  $content_to_place = array(
336
  htmlentities($category_row->name,ENT_QUOTES, 'UTF-8'),
@@ -340,8 +325,7 @@ function wpsc_display_category_loop($query, $category_html, &$category_branch =
340
  $category_classes,
341
  $category_image_html,
342
  $sub_categories,
343
- $category_count_html,
344
- $category_product_list);
345
 
346
  // Stick all the category html together and concatenate it to the previously generated HTML
347
  $output .= str_replace($tags_to_replace, $content_to_place ,$category_html);
@@ -372,68 +356,8 @@ function wpsc_place_category_image($category_id, $query) {
372
  return htmlspecialchars($image_url);
373
  }
374
 
375
-
376
- function wpsc_category_product_list($category_id) {
377
- global $wpdb;
378
- $output = '';
379
- $category_id = (int)$category_id;
380
-
381
- if (get_option('catsprods_display_type') == 1) {
382
- $product_data = $wpdb->get_results("SELECT `products`.`id`, `products`.`name`
383
- FROM `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` AS `cats`
384
- JOIN `".WPSC_TABLE_PRODUCT_LIST."` as `products`
385
- ON `cats`.`product_id` = `products`.`id`
386
- WHERE `cats`.`category_id` = '$category_id'
387
- AND `products`.`publish`='1'
388
- AND `products`.`active` = '1'
389
- ORDER BY `products`.`name` ASC
390
- ", ARRAY_A);
391
- if(count($product_data) > 0){
392
- $output .= "<ul class='category-product-list'>\n\r";
393
- foreach($product_data as $product_row) {
394
- $output .= "<li class='cat-item'><a class='productlink' href='".wpsc_product_url($product_row['id'],$category_id)."'>".$product_row['name']."</a></li>\n\r";
395
- } //end foreach
396
- $output .= "</ul>\n\r";
397
- } //end if productsIDs
398
- }
399
- return $output;
400
- }
401
-
402
-
403
  /// category template tags end here
404
 
405
-
406
- // pe.{
407
- // To stick this in sidebar, main page (calling products_page.php) must be called before sidebar.php in the loop (think)
408
-
409
- function display_subcategories($id) {
410
- global $wpdb;
411
- if(get_option('permalink_structure') != '') {
412
- $separator ="?";
413
- } else {
414
- $separator ="&amp;";
415
- }
416
- $subcategory_sql = "SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active`='1' AND `category_parent` = '".absint($id)."' ORDER BY `nice-name`";
417
- $subcategories = $wpdb->get_results($subcategory_sql,ARRAY_A);
418
- if($subcategories != null) {
419
- $output .= "<ul class='SubCategories'>";
420
- foreach($subcategories as $subcategory) {
421
- if (get_option('show_category_count') == 1) {
422
- //show product count for each category
423
- $count = $wpdb->get_var("SELECT COUNT(`p`.`id`) FROM `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` AS `a` JOIN `".WPSC_TABLE_PRODUCT_LIST."` AS `p` ON `a`.`product_id` = `p`.`id` WHERE `a`.`category_id` IN ('{$subcategory['id']}') AND `p`.`active` IN ('1') AND `p`.`publish` IN('1')");
424
- $addCount = " (".$count.")";
425
- } //end get_option
426
- $output .= "<li class='cat-item'><a class='categorylink' href='".wpsc_category_url($subcategory['id'])."'>".stripslashes($subcategory['name'])."</a>$addCount".display_subcategories($subcategory['id'])."</li>";
427
- }
428
- $output .= "</ul>";
429
- } else {
430
- return '';
431
- }
432
- return $output;
433
- }
434
-
435
-
436
-
437
  /**
438
  * wpsc_category_url function, makes permalink to the category or
439
  * @param integer category ID, can be 0
116
  echo "[wpsc_category_classes]";
117
  }
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
120
  /**
121
  * wpsc print subcategory function
299
  $category_image_html = "";
300
  $category_image_html .= " <span class='wpsc_category_image item_no_image ' style='width: {$width}px; height: {$height}px;'>\n\r";
301
  $category_image_html .= " <span class='link_substitute' >\n\r";
302
+ $category_image_html .= " <span>".$category_row->name."</span>\n\r";
303
  $category_image_html .= " </span>\n\r";
304
  $category_image_html .= " </span>\n\r";
305
  }
308
 
309
 
310
  // get the list of products associated with this category.
 
311
  $tags_to_replace = array('[wpsc_category_name]',
312
  '[wpsc_category_description]',
313
  '[wpsc_category_url]',
315
  '[wpsc_category_classes]',
316
  '[wpsc_category_image]',
317
  '[wpsc_subcategory]',
318
+ '[wpsc_category_products_count]');
 
319
 
320
  $content_to_place = array(
321
  htmlentities($category_row->name,ENT_QUOTES, 'UTF-8'),
325
  $category_classes,
326
  $category_image_html,
327
  $sub_categories,
328
+ $category_count_html);
 
329
 
330
  // Stick all the category html together and concatenate it to the previously generated HTML
331
  $output .= str_replace($tags_to_replace, $content_to_place ,$category_html);
356
  return htmlspecialchars($image_url);
357
  }
358
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
359
  /// category template tags end here
360
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  /**
362
  * wpsc_category_url function, makes permalink to the category or
363
  * @param integer category ID, can be 0
wpsc-includes/checkout.class.php CHANGED
@@ -64,6 +64,40 @@ function wpsc_has_regions($country){
64
 
65
  }
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  /**
68
  * wpsc google checkout submit used for google checkout (unsure whether necessary in 3.8)
69
  * @access public
@@ -589,7 +623,7 @@ class wpsc_checkout {
589
 
590
  function form_name() {
591
  if ( $this->form_name_is_required() && ($this->checkout_item->type != 'heading') )
592
- return stripslashes( $this->checkout_item->name ) . ' * ';
593
  else
594
  return stripslashes( $this->checkout_item->name );
595
  }
@@ -628,10 +662,34 @@ class wpsc_checkout {
628
  */
629
  function form_field() {
630
  global $wpdb, $user_ID;
631
- if ( (count( $_SESSION['wpsc_checkout_saved_values'] ) <= 0) && ($user_ID > 0) )
632
  $_SESSION['wpsc_checkout_saved_values'] = get_user_meta( $user_ID, 'wpshpcrt_usr_profile',1 );
633
-
634
- $saved_form_data = @htmlentities( stripslashes( (string)$_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id] ), ENT_QUOTES );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635
  $an_array = '';
636
  if ( function_exists( 'wpsc_get_ticket_checkout_set' ) ) {
637
  if ( $this->checkout_item->checkout_set == wpsc_get_ticket_checkout_set() )
@@ -882,14 +940,10 @@ class wpsc_checkout {
882
  }
883
 
884
  if ( $form_data->type != 'heading' ) {
885
- // echo '<pre>'.print_r($form_data,true).'</pre>';
886
  if ( is_array( $value ) && ($form_data->unique_name == 'billingcountry' || $form_data->unique_name == 'shippingcountry') ) {
887
-
888
- if ( $form_data->unique_name != 'shippingcountry' ) {
889
- $value = serialize( $value );
890
- } else {
891
  $value = $value[0];
892
- }
893
  $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 ) );
894
  } elseif ( is_array( $value ) ) {
895
 
64
 
65
  }
66
 
67
+ /**
68
+ * wpsc_check_purchase_processed checks the given processed number and checks it against the global wpsc_purchlog_statuses
69
+ * @access public
70
+ *
71
+ * @since 3.8
72
+ * @param $processed (int) generally comes from the purchase log table `processed` column
73
+ * @return $is_transaction (boolean) true if the process is a completed transaction false otherwise
74
+ */
75
+ function wpsc_check_purchase_processed($processed){
76
+ global $wpsc_purchlog_statuses;
77
+ $is_transaction = false;
78
+ foreach($wpsc_purchlog_statuses as $status)
79
+ if($status['order'] == $processed && isset($status['is_transaction']) && 1 == $status['is_transaction'] )
80
+ $is_transaction = true;
81
+
82
+ return $is_transaction;
83
+ }
84
+
85
+ /**
86
+ * get buyers email retrieves the email address associated to the checkout
87
+ * @access public
88
+ *
89
+ * @since 3.8
90
+ * @param purchase_id (int) the purchase id
91
+ * @return email (strong) email addess
92
+ */
93
+ function wpsc_get_buyers_email($purchase_id){
94
+ global $wpdb;
95
+ $email_form_field = $wpdb->get_results( "SELECT `id`,`type` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `order` ASC LIMIT 1", ARRAY_A );
96
+ $email = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $purchase_id . " AND `form_id` = '" . $email_form_field[0]['id'] . "' LIMIT 1" );
97
+ return $email;
98
+
99
+ }
100
+
101
  /**
102
  * wpsc google checkout submit used for google checkout (unsure whether necessary in 3.8)
103
  * @access public
623
 
624
  function form_name() {
625
  if ( $this->form_name_is_required() && ($this->checkout_item->type != 'heading') )
626
+ return stripslashes( $this->checkout_item->name ) . ' <span class="asterix">*</span> ';
627
  else
628
  return stripslashes( $this->checkout_item->name );
629
  }
662
  */
663
  function form_field() {
664
  global $wpdb, $user_ID;
665
+ if ( ($user_ID > 0) ){
666
  $_SESSION['wpsc_checkout_saved_values'] = get_user_meta( $user_ID, 'wpshpcrt_usr_profile',1 );
667
+ $saved_form_data = @htmlentities( stripslashes( (string)$_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id] ), ENT_QUOTES );
668
+ $delivery_country_id = wpsc_get_country_form_id_by_type('delivery_country');
669
+ if($this->checkout_item->id == $delivery_country_id){
670
+ if( is_array($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id])
671
+ && count($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]) > 1){
672
+
673
+ $_SESSION['wpsc_delivery_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][0];
674
+ $_SESSION['wpsc_delivery_region'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][1];
675
+ } else {
676
+
677
+ $_SESSION['wpsc_delivery_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][0];
678
+ }
679
+ }
680
+ $billing_country_id = wpsc_get_country_form_id_by_type('country');
681
+ if($this->checkout_item->id == $billing_country_id){
682
+ if( is_array($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id])
683
+ && count($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]) > 1){
684
+
685
+ $_SESSION['wpsc_selected_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][0];
686
+ $_SESSION['wpsc_selected_region'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][1];
687
+ } else {
688
+
689
+ $_SESSION['wpsc_selected_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][0];
690
+ }
691
+ }
692
+ }
693
  $an_array = '';
694
  if ( function_exists( 'wpsc_get_ticket_checkout_set' ) ) {
695
  if ( $this->checkout_item->checkout_set == wpsc_get_ticket_checkout_set() )
940
  }
941
 
942
  if ( $form_data->type != 'heading' ) {
943
+ //echo '<pre>'.print_r($form_data,true).'</pre>';
944
  if ( is_array( $value ) && ($form_data->unique_name == 'billingcountry' || $form_data->unique_name == 'shippingcountry') ) {
 
 
 
 
945
  $value = $value[0];
946
+
947
  $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 ) );
948
  } elseif ( is_array( $value ) ) {
949
 
wpsc-includes/coupons.class.php CHANGED
@@ -153,7 +153,7 @@ foreach($wpsc_cart->cart_items as $key => $cart_item) {
153
 
154
  foreach ($wpsc_cart->cart_items as $key => $item) {
155
 
156
- $product_data = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_PRODUCT_LIST." WHERE id='{$item->product_id}'");
157
  $product_data = $product_data[0];
158
 
159
  $match = true;
@@ -213,7 +213,7 @@ foreach($wpsc_cart->cart_items as $key => $cart_item) {
213
  global $wpdb;
214
 
215
  if ($c['property'] == 'item_name') {
216
- $product_data = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_PRODUCT_LIST." WHERE id='{$product_obj->product_id}'");
217
  $product_data = $product_data[0];
218
 
219
  switch($c['logic']) {
153
 
154
  foreach ($wpsc_cart->cart_items as $key => $item) {
155
 
156
+ $product_data = $wpdb->get_results("SELECT * FROM ". $wpdb->posts ." WHERE id='{$item->product_id}'");
157
  $product_data = $product_data[0];
158
 
159
  $match = true;
213
  global $wpdb;
214
 
215
  if ($c['property'] == 'item_name') {
216
+ $product_data = $wpdb->get_results("SELECT * FROM " . $wpdb->posts . " WHERE id='{$product_obj->product_id}'");
217
  $product_data = $product_data[0];
218
 
219
  switch($c['logic']) {
wpsc-includes/display.functions.php CHANGED
@@ -19,9 +19,7 @@ function wpsc_buy_now_button( $product_id, $replaced_shortcode = false ) {
19
  $product = get_post( $product_id );
20
  $supported_gateways = array('wpsc_merchant_paypal_standard','paypal_multiple');
21
  $selected_gateways = get_option( 'custom_gateway_options' );
22
- if ( in_array( 'google', (array)$selected_gateways ) ) {
23
- $output .= google_buynow( $product['id'] );
24
- } else if ( in_array( 'wpsc_merchant_paypal_standard', (array)$selected_gateways ) ) {
25
  if ( $product_id > 0 ) {
26
  $post_meta = get_post_meta( $product_id, '_wpsc_product_metadata', true );
27
  $shipping = $post_meta['shipping']['local'];
@@ -67,54 +65,51 @@ function wpsc_also_bought( $product_id ) {
67
  * most of it scarcely needs describing
68
  */
69
  global $wpdb;
70
- $siteurl = get_option( 'siteurl' );
71
 
72
  if ( get_option( 'wpsc_also_bought' ) == 0 ) {
73
  //returns nothing if this is off
74
  return '';
75
  }
 
76
 
77
  // to be made customiseable in a future release
78
  $also_bought_limit = 3;
79
  $element_widths = 96;
80
  $image_display_height = 96;
81
  $image_display_width = 96;
82
-
83
- $also_bought = $wpdb->get_results( "SELECT `" . WPSC_TABLE_PRODUCT_LIST . "`.* FROM `" . WPSC_TABLE_ALSO_BOUGHT . "`, `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `selected_product`='" . $product_id . "' AND `" . WPSC_TABLE_ALSO_BOUGHT . "`.`associated_product` = `" . WPSC_TABLE_PRODUCT_LIST . "`.`id` AND `" . WPSC_TABLE_PRODUCT_LIST . "`.`active` IN('1') AND `" . WPSC_TABLE_PRODUCT_LIST . "`.`publish` IN ('1')ORDER BY `" . WPSC_TABLE_ALSO_BOUGHT . "`.`quantity` DESC LIMIT $also_bought_limit", ARRAY_A );
84
  if ( count( $also_bought ) > 0 ) {
85
  $output = "<h2 class='prodtitles wpsc_also_bought' >" . __( 'People who bought this item also bought', 'wpsc' ) . "</h2>";
86
  $output .= "<div class='wpsc_also_bought'>";
87
  foreach ( (array)$also_bought as $also_bought_data ) {
 
88
  $output .= "<div class='wpsc_also_bought_item' style='width: " . $element_widths . "px;'>";
89
-
90
  if ( get_option( 'show_thumbnails' ) == 1 ) {
91
  if ( $also_bought_data['image'] != null ) {
 
 
92
 
93
- $output .= "<a href='" . wpsc_product_url( $also_bought_data['id'] ) . "' class='preview_link' rel='" . str_replace( " ", "_", $also_bought_data['name'] ) . "'>";
94
- $image_path = "index.php?productid=" . $also_bought_data['id'] . "&amp;width=" . $image_display_width . "&amp;height=" . $image_display_height . "";
95
-
96
- $output .= "<img src='$image_path' id='product_image_" . $also_bought_data['id'] . "' class='product_image' style='margin-top: " . $margin_top . "px'/>";
97
  $output .= "</a>";
98
  } else {
99
  if ( get_option( 'product_image_width' ) != '' ) {
100
- $output .= "<img src='" . WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif' title='" . $also_bought_data['name'] . "' alt='" . $also_bought_data['name'] . "' width='$image_display_height' height='$image_display_height' id='product_image_" . $also_bought_data['id'] . "' class='product_image' />";
101
  } else {
102
- $output .= "<img src='" . WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif' title='" . $also_bought_data['name'] . "' alt='" . htmlentities( stripslashes( $product['name'] ), ENT_QUOTES, 'UTF-8' ) . "' id='product_image_" . $also_bought_data['id'] . "' class='product_image' />";
103
  }
104
  }
105
  }
106
 
107
- $variations_processor = new nzshpcrt_variations;
108
- $variations_output = $variations_processor->display_product_variations( $also_bought_data['id'], true, false, true );
109
- //$output .= $variations_output[0];
110
- if ( $variations_output[1] !== null ) {
111
- $also_bought_data['price'] = $variations_output[1];
112
- $also_bought_data['special_price'] = 0;
 
 
113
  }
114
-
115
- $output .= "<a class='wpsc_product_name' href='" . wpsc_product_url( $also_bought_data['id'] ) . "'>" . $also_bought_data['name'] . "</a>";
116
- $output .= wpsc_currency_display( ( $also_bought_data['price'] - $also_bought_data['special_price'] ) );
117
- //$output .= "<a href='".wpsc_product_url($also_bought_data['id'])."'>".$also_bought_data['name']."</a>";
118
  $output .= "</div>";
119
  }
120
  $output .= "</div>";
@@ -170,57 +165,14 @@ function wpsc_product_url( $product_id, $category_id = null, $escape = true ) {
170
  }
171
  }
172
 
173
-
174
- function google_buynow( $product_id ) {
175
- global $wpdb;
176
- $output = "";
177
- if ( $product_id > 0 ) {
178
- $product_sql = "SELECT * FROM " . WPSC_TABLE_PRODUCT_LIST . " WHERE id = " . $product_id . " LIMIT 1";
179
- $product_info = $wpdb->get_results( $product_sql, ARRAY_A );
180
- $variation_sql = "SELECT * FROM " . WPSC_TABLE_VARIATION_PROPERTIES . " WHERE product_id = " . $product_id;
181
- $variation_info = $wpdb->get_results( $variation_sql, ARRAY_A );
182
- if ( count( $variation_info ) > 0 ) {
183
- $variation = 1;
184
- $price = $variation_info[0]['price'];
185
- }
186
- if ( get_option( 'google_server_type' ) == 'production' ) {
187
- $action_target = "https://checkout.google.com/cws/v2/Merchant/" . get_option( 'google_id' ) . "/checkoutForm";
188
- } else {
189
- $action_target = "https://sandbox.google.com/checkout/cws/v2/Merchant/" . get_option( 'google_id' ) . "/checkoutForm";
190
- }
191
-
192
-
193
- $product_info = $product_info[0];
194
- $output .= "<form id='BB_BuyButtonForm" . $product_id . "' onsubmit='log_buynow(this);return true;' action= '" . $action_target . "' method='post' name='BB_BuyButtonForm" . $product_id . "'>";
195
- $output .= "<input name='product_id' type='hidden' value='" . $product_id . "'>";
196
- $output .= "<input name='item_name_1' type='hidden' value='" . $product_info['name'] . "'>";
197
- $output .= "<input name='item_description_1' type='hidden' value='" . $product_info['description'] . "'>";
198
- $output .= "<input name='item_quantity_1' type='hidden' value='1'>";
199
- if ( $variation == 1 ) {
200
- $output .= "<input id='item_price' name='item_price_1' type='hidden' value='" . $price . "'>";
201
- } else {
202
- if ( $product_info['special'] == '0' ) {
203
- $output .= "<input id='item_price' name='item_price_1' type='hidden' value='" . $product_info['price'] . "'>";
204
- } else {
205
- $output .= "<input name='item_price_1' type='hidden' value='" . $product_info['special_price'] . "'>";
206
- }
207
- }
208
- $output .= "<input name='item_currency_1' type='hidden' value='" . get_option( 'google_cur' ) . "'>";
209
- $output .= "<input type='hidden' name='checkout-flow-support.merchant-checkout-flow-support.continue-shopping-url' value='" . get_option( 'product_list_url' ) . "'>";
210
- $output .= "<input type='hidden' name='checkout-flow-support.merchant-checkout-flow-support.edit-cart-url' value='" . get_option( 'shopping_cart_url' ) . "'>";
211
- $output .= "<input alt='' src=' https://checkout.google.com/buttons/buy.gif?merchant_id=" . get_option( 'google_id' ) . "&w=117&h=48&style=trans&variant=text&loc=en_US' type='image'/>";
212
- $output .="</form>";
213
- }
214
- return $output;
215
- }
216
-
217
  function external_link( $product_id ) {
218
  global $wpdb;
219
  $link = get_product_meta( $product_id, 'external_link', true );
220
  if ( !stristr( $link, 'http://' ) ) {
221
  $link = 'http://' . $link;
222
  }
223
- $output .= "<input type='button' value='" . __( 'Buy Now', 'wpsc' ) . "' onclick='gotoexternallink(\"$link\")'>";
 
224
  return $output;
225
  }
226
 
@@ -282,13 +234,6 @@ function wpsc_product_image_html( $image_name, $product_id ) {
282
  function wpsc_add_to_cart_button( $product_id, $replaced_shortcode = false ) {
283
  global $wpdb,$wpsc_variations;
284
  if ( $product_id > 0 ) {
285
- if ( function_exists( 'wpsc_theme_html' ) ) {
286
- $product = $wpdb->get_row( "SELECT * FROM " . WPSC_TABLE_PRODUCT_LIST . " WHERE id = " . $product_id . " LIMIT 1", ARRAY_A );
287
- //this needs the results from the product_list table passed to it, does not take just an ID
288
- $wpsc_theme = wpsc_theme_html( $product );
289
- }
290
-
291
-
292
  // grab the variation form fields here
293
  $wpsc_variations = new wpsc_variations( $product_id );
294
 
@@ -435,17 +380,13 @@ function wpsc_obtain_the_description() {
435
  }
436
 
437
  if ( is_numeric( $category_id ) ) {
438
- $output = $wpdb->get_var( "SELECT `description` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `id`='{$category_id}' LIMIT 1" );
439
  }
440
 
441
 
442
- if ( isset( $wp_query->query_vars['product_url_name'] ) ) {
443
- $product_name = $wp_query->query_vars['product_url_name'];
444
- $product_id = $wpdb->get_var( "SELECT `product_id` FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `meta_key` IN ( 'url_name' ) AND `meta_value` IN ( '{$wp_query->query_vars['product_url_name']}' ) ORDER BY `id` DESC LIMIT 1" );
445
- $output = $wpdb->get_var( "SELECT `description` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id`='{$product_id}' LIMIT 1" );
446
- } else if ( is_numeric( $_GET['product_id'] ) ) {
447
  $product_id = absint( $_GET['product_id'] );
448
- $output = $wpdb->get_var( "SELECT `description` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id`='{$product_id}' LIMIT 1" );
449
  }
450
  return $output;
451
  }
19
  $product = get_post( $product_id );
20
  $supported_gateways = array('wpsc_merchant_paypal_standard','paypal_multiple');
21
  $selected_gateways = get_option( 'custom_gateway_options' );
22
+ if ( in_array( 'wpsc_merchant_paypal_standard', (array)$selected_gateways ) ) {
 
 
23
  if ( $product_id > 0 ) {
24
  $post_meta = get_post_meta( $product_id, '_wpsc_product_metadata', true );
25
  $shipping = $post_meta['shipping']['local'];
65
  * most of it scarcely needs describing
66
  */
67
  global $wpdb;
 
68
 
69
  if ( get_option( 'wpsc_also_bought' ) == 0 ) {
70
  //returns nothing if this is off
71
  return '';
72
  }
73
+
74
 
75
  // to be made customiseable in a future release
76
  $also_bought_limit = 3;
77
  $element_widths = 96;
78
  $image_display_height = 96;
79
  $image_display_width = 96;
80
+
81
+ $also_bought = $wpdb->get_results( "SELECT `" . $wpdb->posts . "`.* FROM `" . WPSC_TABLE_ALSO_BOUGHT . "`, `" . $wpdb->posts . "` WHERE `selected_product`='" . $product_id . "' AND `" . WPSC_TABLE_ALSO_BOUGHT . "`.`associated_product` = `" . $wpdb->posts . "`.`id` AND `" . $wpdb->posts . "`.`post_status` IN('publish','protected') ORDER BY `" . WPSC_TABLE_ALSO_BOUGHT . "`.`quantity` DESC LIMIT $also_bought_limit", ARRAY_A );
82
  if ( count( $also_bought ) > 0 ) {
83
  $output = "<h2 class='prodtitles wpsc_also_bought' >" . __( 'People who bought this item also bought', 'wpsc' ) . "</h2>";
84
  $output .= "<div class='wpsc_also_bought'>";
85
  foreach ( (array)$also_bought as $also_bought_data ) {
86
+ //$also_bought_data = $also_bought_data[0];
87
  $output .= "<div class='wpsc_also_bought_item' style='width: " . $element_widths . "px;'>";
 
88
  if ( get_option( 'show_thumbnails' ) == 1 ) {
89
  if ( $also_bought_data['image'] != null ) {
90
+ $output .= "<a href='" . get_permalink($also_bought_data['ID']) . "' class='preview_link' rel='" . str_replace( " ", "_", get_the_title($also_bought_data['ID']) ) . "'>";
91
+ $image_path = "index.php?productid=" . $also_bought_data['ID'] . "&amp;width=" . $image_display_width . "&amp;height=" . $image_display_height . "";
92
 
93
+ $output .= "<img src='$image_path' id='product_image_" . $also_bought_data['ID'] . "' class='product_image' style='margin-top: " . $margin_top . "px'/>";
 
 
 
94
  $output .= "</a>";
95
  } else {
96
  if ( get_option( 'product_image_width' ) != '' ) {
97
+ $output .= "<img src='" . WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif' title='" . get_the_title($also_bought_data['ID']) . "' alt='" . $also_bought_data['name'] . "' width='$image_display_height' height='$image_display_height' id='product_image_" . $also_bought_data['ID'] . "' class='product_image' />";
98
  } else {
99
+ $output .= "<img src='" . WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif' title='" . get_the_title($also_bought_data['ID']) . "' alt='" . htmlentities( stripslashes( get_the_title($also_bought_data['ID']) ), ENT_QUOTES, 'UTF-8' ) . "' id='product_image_" . $also_bought_data['ID'] . "' class='product_image' />";
100
  }
101
  }
102
  }
103
 
104
+ $output .= "<a class='wpsc_product_name' href='" . get_permalink($also_bought_data['ID']) . "'>" . get_the_title($also_bought_data['ID']) . "</a>";
105
+ $price = get_product_meta($also_bought_data['ID'], 'price', true);
106
+ $special_price = get_product_meta($also_bought_data['ID'], 'special_price', true);
107
+ if(!empty($special_price)){
108
+ $output .= '<span style="text-decoration: line-through;">' . wpsc_currency_display( $price ) . '</span>';
109
+ $output .= wpsc_currency_display( $special_price );
110
+ } else {
111
+ $output .= wpsc_currency_display( $price );
112
  }
 
 
 
 
113
  $output .= "</div>";
114
  }
115
  $output .= "</div>";
165
  }
166
  }
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  function external_link( $product_id ) {
169
  global $wpdb;
170
  $link = get_product_meta( $product_id, 'external_link', true );
171
  if ( !stristr( $link, 'http://' ) ) {
172
  $link = 'http://' . $link;
173
  }
174
+ $target = wpsc_product_external_link_target( $product_id );
175
+ $output .= "<input class='wpsc_buy_button' type='button' value='" . wpsc_product_external_link_text( $product_id, __( 'Buy Now', 'wpsc' ) ) . "' onclick='return gotoexternallink(\"$link\", \"$target\")'>";
176
  return $output;
177
  }
178
 
234
  function wpsc_add_to_cart_button( $product_id, $replaced_shortcode = false ) {
235
  global $wpdb,$wpsc_variations;
236
  if ( $product_id > 0 ) {
 
 
 
 
 
 
 
237
  // grab the variation form fields here
238
  $wpsc_variations = new wpsc_variations( $product_id );
239
 
380
  }
381
 
382
  if ( is_numeric( $category_id ) ) {
383
+ $output = wpsc_get_categorymeta( $category_id, 'description' );
384
  }
385
 
386
 
387
+ if ( is_numeric( $_GET['product_id'] ) ) {
 
 
 
 
388
  $product_id = absint( $_GET['product_id'] );
389
+ $output = $wpdb->get_var( "SELECT `post_content` FROM `" . $wpdb->posts . "` WHERE `id`='{$product_id}' LIMIT 1" );
390
  }
391
  return $output;
392
  }
wpsc-includes/form-display.functions.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  function nzshpcrt_country_list( $selected_country = null ) {
4
  global $wpdb;
5
- $output = "<option value=''></option>";
6
 
7
  if ( $selected_country == null )
8
  $output = "<option value=''>" . __( 'Please select', 'wpsc' ) . "</option>";
@@ -11,10 +11,10 @@ function nzshpcrt_country_list( $selected_country = null ) {
11
 
12
  foreach ( $country_data as $country ) {
13
  $selected = '';
14
- if ( $selected_country == $country['isocode'] ) {
15
- $selected = "selected='true'";
16
- }
17
- $output .= "<option value='" . $country['isocode'] . "' $selected>" . $country['country'] . "</option>";
18
  }
19
 
20
  return $output;
@@ -28,11 +28,9 @@ function nzshpcrt_region_list( $selected_country = null, $selected_region = null
28
 
29
  $output = "";
30
  $region_list = $wpdb->get_results( "SELECT `" . WPSC_TABLE_REGION_TAX . "`.* FROM `" . WPSC_TABLE_REGION_TAX . "`, `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `" . WPSC_TABLE_CURRENCY_LIST . "`.`isocode` IN('" . $selected_country . "') AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`", ARRAY_A );
31
-
32
  if ( $region_list != null ) {
33
- $output .= "<select name='base_region'>\n\r";
34
  $output .= "<option value=''>None</option>";
35
-
36
  foreach ( $region_list as $region ) {
37
  if ( $selected_region == $region['id'] ) {
38
  $selected = "selected='selected'";
@@ -43,7 +41,7 @@ function nzshpcrt_region_list( $selected_country = null, $selected_region = null
43
  $output .= "<option value='" . $region['id'] . "' $selected>" . $region['name'] . "</option>\n\r";
44
  }
45
 
46
- $output .= "</select>\n\r";
47
  } else {
48
  $output .= "<select name='base_region' disabled='true'><option value=''>None</option></select>\n\r";
49
  }
@@ -87,13 +85,14 @@ function wpsc_parent_category_list( $taxonomies, $args, $parent, $current_term_i
87
  function wpsc_category_options( $group_id, $this_category = null, $category_id = null, $iteration = 0, $selected_id = null ) {
88
  global $wpdb;
89
  $siteurl = get_option( 'siteurl' );
 
90
  $values = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=' . $group_id );
91
  $selected = "";
92
  $output = "";
93
 
94
  foreach ( (array)$values as $option ) {
95
  if ( $option->term_id != $this_category ) {
96
- if ( $selected_id == $option->term_id ) {
97
  $selected = "selected='selected'";
98
  }
99
 
2
 
3
  function nzshpcrt_country_list( $selected_country = null ) {
4
  global $wpdb;
5
+
6
 
7
  if ( $selected_country == null )
8
  $output = "<option value=''>" . __( 'Please select', 'wpsc' ) . "</option>";
11
 
12
  foreach ( $country_data as $country ) {
13
  $selected = '';
14
+ if ( $selected_country == $country['isocode'] )
15
+ $selected = "selected='selected'";
16
+
17
+ $output .= "<option value='" . $country['isocode'] . "' ".$selected.">" . $country['country'] . "</option>";
18
  }
19
 
20
  return $output;
28
 
29
  $output = "";
30
  $region_list = $wpdb->get_results( "SELECT `" . WPSC_TABLE_REGION_TAX . "`.* FROM `" . WPSC_TABLE_REGION_TAX . "`, `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `" . WPSC_TABLE_CURRENCY_LIST . "`.`isocode` IN('" . $selected_country . "') AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`", ARRAY_A );
31
+
32
  if ( $region_list != null ) {
 
33
  $output .= "<option value=''>None</option>";
 
34
  foreach ( $region_list as $region ) {
35
  if ( $selected_region == $region['id'] ) {
36
  $selected = "selected='selected'";
41
  $output .= "<option value='" . $region['id'] . "' $selected>" . $region['name'] . "</option>\n\r";
42
  }
43
 
44
+ // $output .= "</select>\n\r";
45
  } else {
46
  $output .= "<select name='base_region' disabled='true'><option value=''>None</option></select>\n\r";
47
  }
85
  function wpsc_category_options( $group_id, $this_category = null, $category_id = null, $iteration = 0, $selected_id = null ) {
86
  global $wpdb;
87
  $siteurl = get_option( 'siteurl' );
88
+ $selected_term = get_term($selected_id,'wpsc_product_category');
89
  $values = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=' . $group_id );
90
  $selected = "";
91
  $output = "";
92
 
93
  foreach ( (array)$values as $option ) {
94
  if ( $option->term_id != $this_category ) {
95
+ if ( isset($selected_term->parent) && $selected_term->parent == $option->term_id ) {
96
  $selected = "selected='selected'";
97
  }
98
 
wpsc-includes/homepage_products_functions.php DELETED
@@ -1,244 +0,0 @@
1
- <?php
2
- function nszhpcrt_homepage_products($content = '') {
3
- global $wpdb;
4
- $siteurl = get_option('siteurl');
5
- if(get_option('permalink_structure') != '') {
6
- $separator ="?";
7
- } else {
8
- $separator ="&amp;";
9
- }
10
- $sql = "SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `display_frontpage` IN('1') AND `active` IN('1')";
11
- //$product_list = $wpdb->get_results($sql,ARRAY_A);
12
- $product_list = array();
13
- $output = "<div id='homepage_products'>\n\r";
14
- foreach((array)$product_list as $product) {
15
- $output .= "<div class='frontpage_product'>\n\r";
16
- $output .= "<a href='".wpsc_product_url($product['id'])."'>";
17
- if($product['image'] != '') {
18
- $output .= "<img src='".WPSC_THUMBNAIL_URL.$product['image']."' title='".$product['name']."' alt='".$product['name']."' />\n\r";
19
- $output .= "<p>\n\r";
20
- $output .= stripslashes($product['name']);
21
- $output .= "<span class='front_page_price'>\n\r";
22
- if($product['special']==1) {
23
- $output .= "<span class='oldprice'>".wpsc_currency_display( $product['price'] )."</span><br />\n\r";
24
- $output .= wpsc_currency_display( ( $product['price'] - $product['special_price'] ) );
25
- } else {
26
- $output .= "".wpsc_currency_display( $product['price'] );
27
- }
28
- $output .= "</span>\n\r";
29
- $output .= "</p>\n\r";
30
- }
31
- $output .= "</a>";
32
- $output .= "</div>\n\r";
33
- }
34
- $output .= "</div>\n\r";
35
- $output .= "<br style='clear: left;'>\n\r";
36
- return preg_replace("/\[homepage_products\]/", $output, $content);
37
- }
38
-
39
-
40
-
41
- function nszhpcrt_category_tag($content = '') {
42
- global $wpdb;
43
- if(preg_match_all("/\[wpsc_category_exclude=([\d]+),*(full)?\]/", $content, $matches)) {
44
- foreach($matches[1] as $key => $category_id) {
45
- $categories[$key]['id'] = $category_id;
46
- $categories[$key]['display'] = $matches[2][$key];
47
- $categories[$key]['original_string'] = $matches[0][$key];
48
- }
49
- foreach ($categories as $category) {
50
- $sql1 = "SELECT DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.*, `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id`,`".WPSC_TABLE_PRODUCT_ORDER."`.`order`, IF(ISNULL(`".WPSC_TABLE_PRODUCT_ORDER."`.`order`), 0, 1) AS `order_state` FROM `".WPSC_TABLE_PRODUCT_LIST."` LEFT JOIN `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` ON `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` LEFT JOIN `".WPSC_TABLE_PRODUCT_ORDER."` ON ( ( `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`product_id` ) AND ( `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`category_id` ) ) WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`active` = '1' AND `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` NOT IN ('".$category['id']."') $no_donations_sql ORDER BY `order_state` DESC,`".WPSC_TABLE_PRODUCT_ORDER."`.`order` ASC";
51
- $product_list1 = $wpdb->get_results($sql1,ARRAY_A);
52
- if(function_exists('product_display_list') && (get_option('product_view') == 'list')) {
53
- $output1= product_display_list($product_list1, $group_type, $group_sql, $search_sql);
54
- } else if(function_exists('product_display_grid') && (get_option('product_view') == 'grid')) {
55
- $output1= product_display_grid($product_list1, $group_type, $group_sql, $search_sql);
56
- } else {
57
- $output1= product_display_default($product_list1,'');
58
- }
59
- }
60
- $content = str_replace($category['original_string'], $output1, $content);
61
- }
62
- if(preg_match_all("/\[wpsc_category=([\d]+),*(full)?\]/", $content, $matches)) {
63
- foreach($matches[1] as $key => $category_id) {
64
- $categories[$key]['id'] = $category_id;
65
- //$categories[$key]['display'] = $matches[2][$key];
66
- $original_string = $matches[0][$key];
67
- $query = array('category_id' => $category_id);
68
-
69
- $content = str_replace($original_string, wpsc_display_products_page($query), $content);
70
-
71
- }
72
-
73
-
74
- return $content;
75
-
76
- //echo("<pre>".print_r($categories,true)."</pre>");
77
- $siteurl = get_option('siteurl');
78
- if(get_option('permalink_structure') != '') {
79
- $separator ="?";
80
- } else {
81
- $separator ="&amp;";
82
- }
83
-
84
- foreach((array)$activated_widgets as $widget_container) {
85
- if(is_array($widget_container) && array_search(__('Product Donations', 'wpsc'), $widget_container)) {
86
- $no_donations_sql = "AND `".WPSC_TABLE_PRODUCT_LIST."`.`donation` != '1'";
87
- break;
88
- }
89
- }
90
- foreach((array)$categories as $category) {
91
- $full_view = null;
92
- if($category['display'] == 'full') {
93
- $sql = "SELECT DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.*, `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id`,`".WPSC_TABLE_PRODUCT_ORDER."`.`order`, IF(ISNULL(`".WPSC_TABLE_PRODUCT_ORDER."`.`order`), 0, 1) AS `order_state` FROM `".WPSC_TABLE_PRODUCT_LIST."` LEFT JOIN `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` ON `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` LEFT JOIN `".WPSC_TABLE_PRODUCT_ORDER."` ON ( ( `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`product_id` ) AND ( `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`category_id` ) ) WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`active` = '1' AND `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` IN ('".$category['id']."') $no_donations_sql ORDER BY `order_state` DESC,`".WPSC_TABLE_PRODUCT_ORDER."`.`order` ASC";
94
-
95
- $product_list = $wpdb->get_results($sql,ARRAY_A);
96
- // sorry about the global variable, but it was the best way I could think of to avoid people having to upgrade the gold cart
97
- $GLOBALS['wpsc_category_id'] = $category['id'];
98
- if(function_exists('product_display_list') && (get_option('product_view') == 'list')) {
99
- $output .= product_display_list($product_list, $group_type, $group_sql, $search_sql);
100
- } else if(function_exists('product_display_grid') && (get_option('product_view') == 'grid')) {
101
- $output .= product_display_grid($product_list, $group_type, $group_sql, $search_sql);
102
- } else {
103
- $output .= product_display_default($product_list, $group_type, $group_sql, $search_sql);
104
- }
105
-
106
- } else {
107
- $sql = "SELECT DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.*, `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id`,`".WPSC_TABLE_PRODUCT_ORDER."`.`order`, IF(ISNULL(`".WPSC_TABLE_PRODUCT_ORDER."`.`order`), 0, 1) AS `order_state` FROM `".WPSC_TABLE_PRODUCT_LIST."` LEFT JOIN `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` ON `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` LEFT JOIN `".WPSC_TABLE_PRODUCT_ORDER."` ON ( ( `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`product_id` ) AND ( `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`category_id` ) ) WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`active` = '1' AND `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` IN ('".$category['id']."') $no_donations_sql ORDER BY `order_state` DESC,`".WPSC_TABLE_PRODUCT_ORDER."`.`order` ASC";
108
-
109
- $product_list = $wpdb->get_results($sql,ARRAY_A);
110
- $output = "<div id='products_page_container' class='wrap wpsc_container'>\n\r";
111
- $output .= "<div id='homepage_products'>\n\r";
112
- if ($full_view != null){
113
- $output .= "<table class='productdisplay'>";
114
- }
115
- foreach((array)$product_list as $product) {
116
- if(function_exists('wpsc_theme_html')) {
117
- $wpsc_theme = wpsc_theme_html($product);
118
- }
119
- if ($full_view == null) {
120
- $output .= "<div class='category_view_product'>\n\r";
121
- } else {
122
- /* product image is here */
123
- $output .= "<tr>";
124
- $output .= "<td class='imagecol'>";
125
- }
126
- $output .="<a href='".WPSC_IMAGE_URL.$product['image']."' class='" . wpsc_the_product_image_link_classes() . " rel='".str_replace(" ", "_",$product['name'])."'>";
127
- if($product['image'] != '') {
128
- $output .= "<img class='product_image' src='".WPSC_THUMBNAIL_URL.$product['image']."' title='".$product['name']."' alt='".$product['name']."' />\n\r";
129
- }
130
- $output .= "</a>";
131
- if ($full_view != null) {
132
- $output .= "</td><td class='textcol'>";
133
- } else {
134
- $output .= "<div class='product_details'>";
135
- }
136
- if (get_option('hide_name_link')!=1) {
137
- if(($product['special']==1) && ($variations_output[1] === null)) {
138
- $output .= "<a href='".wpsc_product_url($product['id'])."' class='wpsc_product_title' >$special<strong class='special'>Special / Sale Price - </strong><strong>" . stripslashes($product['name']) . "</strong></a>";
139
- } else {
140
- $output .= "<a href='".wpsc_product_url($product['id'])."' class='wpsc_product_title' >$special<strong>" . stripslashes($product['name']) . "</strong></a>";
141
- }
142
- } else {
143
- if(($product['special']==1) && ($variations_output[1] === null)) {
144
- $output .= "<a class='wpsc_product_title' >$special<strong class='special'>Special / Sale Price - </strong><strong>" . stripslashes($product['name']) . "</strong></a>";
145
- } else {
146
- $output .= "<a class='wpsc_product_title' >$special<strong>" . stripslashes($product['name']) . "</strong></a>";
147
- }
148
- }
149
- if ($full_view !=null) {
150
- if($product['description'] != '') {
151
- $output .= "<p class='wpsc_description'>".nl2br(stripslashes($product['description'])) . "</p>";
152
- }
153
-
154
- if($product['additional_description'] != '') {
155
- $output .= "<a href='#' class='additional_description_link' onclick='return show_additional_description(\"additionaldescription".$product['id']."\",\"link_icon".$product['id']."\");'>";
156
- $output .= "<img id='link_icon".$product['id']."' class='additional_description_button' src='" . WPSC_CORE_IMAGES_URL . "/icon_window_expand.gif' title='".$product['name']."' alt='".$product['name']."' />";
157
- $output .= __('More Details', 'wpsc')."</a>";
158
-
159
- $output .= "<span class='additional_description' id='additionaldescription".$product['id']."'><br />";
160
- $output .= nl2br(stripslashes($product['additional_description'])) . "";
161
- $output .= "</span><br />";
162
- }
163
- }
164
- /*
165
- adding to cart stuff
166
- */
167
- $output .= "<form id='product_".$product['id']."' name='product_".$product['id']."' method='post' action='".get_option('product_list_url').$separator."category=".$_GET['category']."' onsubmit='submitform(this);return false;' >";
168
- $output .= "<input type='hidden' name='prodid' value='".$product['id']."' />";
169
- $output .= "<input type='hidden' name='item' value='".$product['id']."' />";
170
-
171
- $variations_procesor = new nzshpcrt_variations;
172
-
173
- $variations_output = $variations_procesor->display_product_variations($product['id'],false, false, true);
174
- $output .= $variations_output[0];
175
- if($variations_output[1] !== null) {
176
- $product['price'] = $variations_output[1];
177
- }
178
-
179
- if(($product['special']==1) && ($variations_output[1] === null)) {
180
- $output .= "<span class='oldprice'>".wpsc_currency_display( $product['price'] ) . "</span><br />";
181
- $output .= wpsc_currency_display( ( $product['price'] - $product['special_price'] ) ) . "<br />";
182
- } else {
183
- $output .= "<span id='product_price_".$product['id']."'>" . wpsc_currency_display( $product['price'] ) . "</span><br />";
184
- }
185
- if(((get_option('hide_addtocart_button') !='1') || (get_option('payment_gateway') !='google'))) {
186
- if(isset($wpsc_theme) && is_array($wpsc_theme) && ($wpsc_theme['html'] !='')) {
187
- $output .= $wpsc_theme['html'];
188
- } else {
189
- $output .= "<input type='submit' id='product_".$product['id']."_submit_button' class='wpsc_buy_button' name='Buy' value='".__('Add To Cart', 'wpsc')."' />";
190
- }
191
- }
192
- $output .= "</form>";
193
- if (get_option('addtocart_or_buynow')=='1') {
194
- if (get_option('payment_gateway')=='google') {
195
- $output .= google_buynow($product['id']);
196
- }
197
- }
198
-
199
-
200
- if ($full_view != null) {
201
- if(get_option('product_ratings') == 1) {
202
- $output .= "<div class='product_footer'>";
203
-
204
- $output .= "<div class='product_average_vote'>";
205
- $output .= "<strong>".__('Avg. Customer Rating', 'wpsc').":</strong>";
206
- $output .= nzshpcrt_product_rating($product['id']);
207
- $output .= "</div>";
208
-
209
- $output .= "<div class='product_user_vote'>";
210
- $vote_output = nzshpcrt_product_vote($product['id'],"onmouseover='hide_save_indicator(\"saved_".$product['id']."_text\");'");
211
- if($vote_output[1] == 'voted') {
212
- $output .= "<strong><span id='rating_".$product['id']."_text'>".__('Your Rating', 'wpsc').":</span>";
213
- $output .= "<span class='rating_saved' id='saved_".$product['id']."_text'> ".__('Saved', 'wpsc')."</span>";
214
- $output .= "</strong>";
215
- } else if($vote_output[1] == 'voting') {
216
- $output .= "<strong><span id='rating_".$product['id']."_text'>".__('Rate This item', 'wpsc').":</span>";
217
- $output .= "<span class='rating_saved' id='saved_".$product['id']."_text'> ".__('Saved', 'wpsc')."</span>";
218
- $output .= "</strong>";
219
- }
220
- $output .= $vote_output[0];
221
- $output .= "</div>";
222
- $output .= "</div>";
223
- }
224
-
225
- $output .="</td>";
226
- $output .="</tr>";
227
- } else {
228
- $output .= "</div>\n\r";
229
- $output .= "</div>";
230
- }
231
- }
232
- if ($full_view != null) {
233
- $output .= "</table>";
234
- }
235
- $output .= "</div>\n\r";
236
- $output .= "<br style='clear: left;'>\n\r";
237
- $output .= "</div>\n\r";
238
- }
239
- $content = str_replace($category['original_string'], $output, $content);
240
- }
241
- }
242
- return $content;
243
- }
244
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-includes/merchant.class.php CHANGED
@@ -163,6 +163,10 @@ class wpsc_merchant {
163
 
164
  if ( count( $address_data['shipping'] ) < 1 )
165
  $address_data['shipping'] = $address_data['billing'];
 
 
 
 
166
 
167
  $this->cart_data = array(
168
  'software_name' => 'WP e-Commerce/' . WPSC_PRESENTABLE_VERSION . '',
@@ -170,7 +174,7 @@ class wpsc_merchant {
170
  'store_location' => get_option( 'base_country' ),
171
  'store_currency' => $currency_code,
172
  'is_subscription' => false,
173
- 'has_discounts' => $purchase_logs['discount_value'] > 0 ? true : false,
174
  'cart_discount_value' => $purchase_logs['discount_value'],
175
  'cart_discount_coupon' => $purchase_logs['discount_data'],
176
  'cart_tax' => $purchase_logs['wpec_taxes_total'],
163
 
164
  if ( count( $address_data['shipping'] ) < 1 )
165
  $address_data['shipping'] = $address_data['billing'];
166
+ if( !empty($purchase_logs['discount_value']) )
167
+ $has_discount = true;
168
+ else
169
+ $has_discount = false;
170
 
171
  $this->cart_data = array(
172
  'software_name' => 'WP e-Commerce/' . WPSC_PRESENTABLE_VERSION . '',
174
  'store_location' => get_option( 'base_country' ),
175
  'store_currency' => $currency_code,
176
  'is_subscription' => false,
177
+ 'has_discounts' => $has_discount,
178
  'cart_discount_value' => $purchase_logs['discount_value'],
179
  'cart_discount_coupon' => $purchase_logs['discount_data'],
180
  'cart_tax' => $purchase_logs['wpec_taxes_total'],
wpsc-includes/misc.functions.php CHANGED
@@ -40,6 +40,12 @@ function wpsc_get_state_by_id( $id, $return_value ) {
40
  return $value;
41
  }
42
 
 
 
 
 
 
 
43
  /**
44
  * WPSC add new user function, validates and adds a new user, for the
45
  *
@@ -271,6 +277,13 @@ function wpsc_populate_also_bought_list() {
271
  }
272
  }
273
 
 
 
 
 
 
 
 
274
  function wpsc_get_country( $country_code ) {
275
  global $wpdb;
276
  $country = $wpdb->get_var( "SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode` IN ('" . $country_code . "') LIMIT 1" );
@@ -292,21 +305,7 @@ function nzshpcrt_display_preview_image() {
292
  ) {
293
 
294
  if ( function_exists( "getimagesize" ) ) {
295
- if ( is_numeric( $_GET['productid'] ) ) {
296
- $product_id = (int)$_GET['productid'];
297
- $image_data = $wpdb->get_var( "SELECT `image` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id`='{$product_id}' LIMIT 1" );
298
-
299
- if ( is_numeric( $image_data ) ) {
300
- $image = $wpdb->get_var( "SELECT `image` FROM `" . WPSC_TABLE_PRODUCT_IMAGES . "` WHERE `id` = '{$image_data}' LIMIT 1" );
301
- $imagepath = WPSC_IMAGE_DIR . $image;
302
- } else {
303
- $imagepath = WPSC_IMAGE_DIR . $imagedata['image'];
304
- }
305
- } else if ( $_GET['image_id'] ) {
306
- $image_id = (int)$_GET['image_id'];
307
- $image = $wpdb->get_var( "SELECT `image` FROM `" . WPSC_TABLE_PRODUCT_IMAGES . "` WHERE `id` = '{$image_id}' LIMIT 1" );
308
- $imagepath = WPSC_IMAGE_DIR . $image;
309
- } else if ( $_GET['image_name'] ) {
310
  $image = basename( $_GET['image_name'] );
311
  $imagepath = WPSC_USER_UPLOADS_DIR . $image;
312
  } else if ( $_GET['category_id'] ) {
@@ -625,11 +624,22 @@ function wpsc_readfile_chunked( $filename, $retbytes = true ) {
625
  */
626
  function wpsc_clear_stock_claims() {
627
  global $wpdb;
628
- ///wp_mail('thomas.howard@gmail.com', 'test hourly cron', 'wpsc_clear_stock_claims ran');
629
- /// Delete the old claims on stock
630
  $old_claimed_stock_timestamp = mktime( (date( 'H' ) - 1 ), date( 'i' ), date( 's' ), date( 'm' ), date( 'd' ), date( 'Y' ) );
631
  $old_claimed_stock_datetime = date( "Y-m-d H:i:s", $old_claimed_stock_timestamp );
632
- $wpdb->query( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `last_activity` < '{$old_claimed_stock_datetime}' AND `cart_submitted` IN ('0')" );
 
 
 
 
 
 
 
 
 
 
 
 
633
  }
634
 
635
  add_action( 'wpsc_daily_cron_tasks', 'wpsc_clear_stock_claims' );
40
  return $value;
41
  }
42
 
43
+ function wpsc_country_has_state($country_code){
44
+ global $wpdb;
45
+ $country_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode`= '".$country_code."' LIMIT 1",ARRAY_A);
46
+ return $country_data;
47
+ }
48
+
49
  /**
50
  * WPSC add new user function, validates and adds a new user, for the
51
  *
277
  }
278
  }
279
 
280
+ function wpsc_get_country_form_id_by_type($type){
281
+ global $wpdb;
282
+ $sql = 'SELECT `id` FROM `'.WPSC_TABLE_CHECKOUT_FORMS.'` WHERE `type`="'.$type.'" LIMIT 1';
283
+ $id = $wpdb->get_var($sql);
284
+ return $id;
285
+ }
286
+
287
  function wpsc_get_country( $country_code ) {
288
  global $wpdb;
289
  $country = $wpdb->get_var( "SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode` IN ('" . $country_code . "') LIMIT 1" );
305
  ) {
306
 
307
  if ( function_exists( "getimagesize" ) ) {
308
+ if ( $_GET['image_name'] ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  $image = basename( $_GET['image_name'] );
310
  $imagepath = WPSC_USER_UPLOADS_DIR . $image;
311
  } else if ( $_GET['category_id'] ) {
624
  */
625
  function wpsc_clear_stock_claims() {
626
  global $wpdb;
627
+ //time
 
628
  $old_claimed_stock_timestamp = mktime( (date( 'H' ) - 1 ), date( 'i' ), date( 's' ), date( 'm' ), date( 'd' ), date( 'Y' ) );
629
  $old_claimed_stock_datetime = date( "Y-m-d H:i:s", $old_claimed_stock_timestamp );
630
+ /// Delete the old claims on stock (only those that weren't sold)
631
+ $wpdb->query( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `last_activity` < '{$old_claimed_stock_datetime}' AND `cart_submitted` = '0'" );
632
+ // get the number of items that has been actually sold
633
+ $sold = $wpdb->get_results( "SELECT product_id, variation_stock_id, cart_id, stock_claimed FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `last_activity` < '{$old_claimed_stock_datetime}' AND `cart_submitted` = '1'" );
634
+
635
+ //decrement stock
636
+ foreach((array)$sold as $sold_product){
637
+ $stock = get_product_meta( $sold_product->product_id, 'stock', true );
638
+ //decrement product stock
639
+ update_product_meta( $sold_product->product_id, 'stock', $stock - $sold_product->stock_claimed );
640
+ //delete from claimed stock
641
+ $wpdb->query( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `product_id` = '" . $sold_product->product_id . "' AND `cart_id` = '" . $sold_product->cart_id . "'" );
642
+ }
643
  }
644
 
645
  add_action( 'wpsc_daily_cron_tasks', 'wpsc_clear_stock_claims' );
wpsc-includes/processing.functions.php CHANGED
@@ -24,7 +24,8 @@ function wpsc_currency_display( $price_in, $args = null ) {
24
  $decimals = 0;
25
  else
26
  $decimals = 2; // default is 2
27
-
 
28
  if('' == get_option('wpsc_decimal_separator'))
29
  $decimal_separator = '.';
30
  else
@@ -53,9 +54,9 @@ function wpsc_currency_display( $price_in, $args = null ) {
53
  if ( true == $query['display_currency_symbol'] ) {
54
  if ( !empty( $wpsc_currency_data['symbol'] ) ) {
55
  if ( false == $query['display_as_html'] ) {
56
- $currency_sign = $wpsc_currency_data['symbol_html'];
57
  } else {
58
- $currency_sign = $wpsc_currency_data['symbol'];
59
  }
60
  } else {
61
  $currency_sign = $wpsc_currency_data['code'];
@@ -110,9 +111,8 @@ function wpsc_decrement_claimed_stock($purchase_log_id) {
110
 
111
  foreach((array)$all_claimed_stock as $claimed_stock) {
112
  // for people to have claimed stock, it must have been available to take, no need to look at the existing stock, just subtract from it
113
- // If this is ever wrong, and you get negative stock, do not fix it here, go find the real cause of the problem if($claimed_stock['variation_stock_id'] > 0) {
114
  $product_id = absint($claimed_stock['product_id']);
115
-
116
  $product = get_post($product_id);
117
  $current_stock = get_post_meta($product_id, '_wpsc_stock', true);
118
  $remaining_stock = $current_stock - $claimed_stock['stock_claimed'];
@@ -162,77 +162,6 @@ function wpsc_get_currency_symbol(){
162
  * All the code below here needs commenting and looking at to see if it needs to be altered or disposed of.
163
  * Correspondingly, all the code above here has been commented, uses the wpsc prefix, and has been made for or modified to work with the object oriented cart code.
164
  */
165
-
166
-
167
- function nzshpcrt_determine_item_shipping($product_id, $quantity, $country_code) {
168
- global $wpdb;
169
- if(is_numeric($product_id) && (get_option('do_not_use_shipping') != 1) && ($_SESSION['quote_shipping_method'] == 'flatrate')) {
170
- $sql = "SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='$product_id' LIMIT 1";
171
- $product_list = $wpdb->get_row($sql,ARRAY_A) ;
172
- if($product_list['no_shipping'] == 0) {
173
- //if the item has shipping
174
- if($country_code == get_option('base_country')) {
175
- $additional_shipping = $product_list['pnp'];
176
- } else {
177
- $additional_shipping = $product_list['international_pnp'];
178
- }
179
- $shipping = $quantity * $additional_shipping;
180
- } else {
181
- //if the item does not have shipping
182
- $shipping = 0;
183
- }
184
- } else {
185
- //if the item is invalid or all items do not have shipping
186
- $shipping = 0;
187
- }
188
- return $shipping;
189
- }
190
-
191
- function nzshpcrt_determine_base_shipping($per_item_shipping, $country_code) {
192
- global $wpdb, $wpsc_shipping_modules;
193
- $custom_shipping = get_option('custom_shipping_options');
194
- if((get_option('do_not_use_shipping') != 1) && (count($custom_shipping) > 0)) {
195
- if(array_search($_SESSION['quote_shipping_method'], (array)$custom_shipping) === false) {
196
- //unset($_SESSION['quote_shipping_method']);
197
- }
198
-
199
- $shipping_quotes = null;
200
- if($_SESSION['quote_shipping_method'] != null) {
201
- // use the selected shipping module
202
- $shipping_quotes = $wpsc_shipping_modules[$_SESSION['quote_shipping_method']]->getQuote();
203
- } else {
204
- // otherwise select the first one with any quotes
205
- foreach((array)$custom_shipping as $shipping_module) {
206
- // if the shipping module does not require a weight, or requires one and the weight is larger than zero
207
- if(($custom_shipping[$shipping_module]->requires_weight != true) or (($custom_shipping[$shipping_module]->requires_weight == true) and (shopping_cart_total_weight() > 0))) {
208
- $_SESSION['quote_shipping_method'] = $shipping_module;
209
- $shipping_quotes = $wpsc_shipping_modules[$_SESSION['quote_shipping_method']]->getQuote();
210
- if(count($shipping_quotes) > 0) { // if we have any shipping quotes, break the loop.
211
- break;
212
- }
213
- }
214
- }
215
- }
216
-
217
- //echo "<pre>".print_r($_SESSION['quote_shipping_method'],true)."</pre>";
218
- if(count($shipping_quotes) < 1) {
219
- $_SESSION['quote_shipping_option'] = '';
220
- }
221
- if(($_SESSION['quote_shipping_option'] == null) && ($shipping_quotes != null)) {
222
- $_SESSION['quote_shipping_option'] = array_pop(array_keys(array_slice($shipping_quotes,0,1)));
223
- }
224
- foreach((array)$shipping_quotes as $shipping_quote) {
225
- foreach((array)$shipping_quote as $key=>$quote) {
226
- if($key == $_SESSION['quote_shipping_option']) {
227
- $shipping = $quote;
228
- }
229
- }
230
- }
231
- } else {
232
- $shipping = 0;
233
- }
234
- return $shipping;
235
- }
236
 
237
  function admin_display_total_price($start_timestamp = '', $end_timestamp = '') {
238
  global $wpdb;
@@ -244,180 +173,6 @@ function admin_display_total_price($start_timestamp = '', $end_timestamp = '') {
244
  $total = $wpdb->get_var($sql);
245
  return $total;
246
  }
247
-
248
-
249
-
250
- function check_in_stock($product_id, $variations, $item_quantity = 1) {
251
- global $wpdb;
252
- $product_id = (int)$product_id;
253
- $item_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='{$product_id}' LIMIT 1",ARRAY_A);
254
-
255
- $item_stock = null;
256
- $variation_count = count($variations);
257
- if($variation_count > 0) {
258
- foreach($variations as $variation_id) {
259
- if(is_numeric($variation_id)) {
260
- $variation_ids[] = $variation_id;
261
- }
262
- }
263
- if(count($variation_ids) > 0) {
264
-
265
- $actual_variation_ids = $wpdb->get_col("SELECT `variation_id` FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id` IN ('".implode("','",$variation_ids)."')");
266
- asort($actual_variation_ids);
267
- $all_variation_ids = implode(",", $actual_variation_ids);
268
-
269
- $priceandstock_id = $wpdb->get_var("SELECT `priceandstock_id` FROM `".WPSC_TABLE_VARIATION_COMBINATIONS."` WHERE `product_id` = '{$product_id}' AND `value_id` IN ( '".implode("', '",$variation_ids )."' ) AND `all_variation_ids` IN('$all_variation_ids') GROUP BY `priceandstock_id` HAVING COUNT( `priceandstock_id` ) = '".count($variation_ids)."' LIMIT 1");
270
-
271
- $variation_stock_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_VARIATION_PROPERTIES."` WHERE `id` = '{$priceandstock_id}' LIMIT 1", ARRAY_A);
272
-
273
- $item_stock = $variation_stock_data['stock'];
274
- }
275
- }
276
-
277
- if($item_stock === null) {
278
- $item_stock = $item_data['quantity'];
279
- }
280
-
281
- if((($item_data['quantity_limited'] == 1) && ($item_stock > 0) && ($item_stock >= $item_quantity)) || ($item_data['quantity_limited'] == 0)) {
282
- $output = true;
283
- } else {
284
- $output = false;
285
- }
286
- return $output;
287
- }
288
-
289
-
290
-
291
- function wpsc_item_process_image($id, $input_file, $output_filename, $width = 0, $height = 0, $resize_method = 1, $return_imageid = false) {
292
- // the function for processing images, takes a product_id, input_file outout file name, height and width
293
- global $wpdb;
294
- //$_FILES['image']['tmp_name']
295
- //$_FILES['image']['name']
296
- if(preg_match("/\.(gif|jp(e)*g|png){1}$/i",$output_filename) && apply_filters( 'wpsc_filter_file', $input_file )) {
297
- //$active_signup = apply_filters( 'wpsc_filter_file', $_FILES['image']['tmp_name'] );
298
- if(function_exists("getimagesize")) {
299
- $image_name = basename($output_filename);
300
- if(is_file((WPSC_IMAGE_DIR.$image_name))) {
301
- $name_parts = explode('.',basename($image_name));
302
- $extension = array_pop($name_parts);
303
- $name_base = implode('.',$name_parts);
304
- $dir = glob(WPSC_IMAGE_DIR."$name_base*");
305
-
306
- foreach($dir as $file) {
307
- $matching_files[] = basename($file);
308
- }
309
- $image_name = null;
310
- $num = 2;
311
- // loop till we find a free file name, first time I get to do a do loop in yonks
312
- do {
313
- $test_name = "{$name_base}-{$num}.{$extension}";
314
- if(!file_exists(WPSC_IMAGE_DIR.$test_name)) {
315
- $image_name = $test_name;
316
- }
317
- $num++;
318
- } while ($image_name == null);
319
- }
320
-
321
- //exit("<pre>".print_r($image_name,true)."</pre>");
322
-
323
- $new_image_path = WPSC_IMAGE_DIR.$image_name;
324
-
325
- // sometimes rename doesn't work, if the file is recently uploaded, use move_uploaded_file instead
326
- if(is_uploaded_file($input_file)) {
327
- move_uploaded_file($input_file, $new_image_path);
328
- } else {
329
- rename($input_file, $new_image_path);
330
- }
331
- $stat = stat( dirname( $new_image_path ));
332
- $perms = $stat['mode'] & 0000775;
333
- @ chmod( $new_image_path, $perms );
334
-
335
- switch($resize_method) {
336
- case 2:
337
- if($height < 1) {
338
- $height = get_option('product_image_height');
339
- }
340
- if($width < 1) {
341
- $width = get_option('product_image_width');
342
- }
343
- break;
344
-
345
-
346
- case 0:
347
- $height = (int)null;
348
- $width = (int)null;
349
- break;
350
-
351
- case 1:
352
- default:
353
- $height = (int)get_option('product_image_height');
354
- $width = (int)get_option('product_image_width');
355
- break;
356
- }
357
- if($width < 1) {
358
- $width = 96;
359
- }
360
- if($height < 1) {
361
- $height = 96;
362
- }
363
- image_processing($new_image_path, (WPSC_THUMBNAIL_DIR.$image_name), $width, $height);
364
- // }
365
- $sql = "INSERT INTO `".WPSC_TABLE_PRODUCT_IMAGES."` (`product_id`, `image`, `width`, `height`) VALUES ('{$id}', '{$image_name}', '{$width}', '{$height}' )";
366
- $wpdb->query($sql);
367
- $image_id = (int) $wpdb->insert_id;
368
- $updatelink_sql = "UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `image` = '".$image_id."', `thumbnail_image` = '".$thumbnail_image."' WHERE `id` = '$id'";
369
- $wpdb->query($updatelink_sql);
370
- //exit($sql.'<br />image is about to be stored in the DB<br />'.$updatelink_sql);
371
-
372
- if(function_exists('getimagesize')) {
373
- $imagetype = getimagesize(WPSC_THUMBNAIL_DIR.$image_name);
374
- update_product_meta($id, 'thumbnail_width', $imagetype[0]);
375
- update_product_meta($id, 'thumbnail_height', $imagetype[1]);
376
- }
377
-
378
-
379
- $image = $wpdb->escape($image_name);
380
- } else {
381
- $image_name = basename($output_filename);
382
- if(is_file((WPSC_IMAGE_DIR.$image_name))) {
383
- $name_parts = explode('.',basename($image_name));
384
- $extension = array_pop($name_parts);
385
- $name_base = implode('.',$name_parts);
386
- $dir = glob(WPSC_IMAGE_DIR."$name_base*");
387
-
388
- foreach($dir as $file) {
389
- $matching_files[] = basename($file);
390
- }
391
- $image_name = null;
392
- $num = 2;
393
- // loop till we find a free file name
394
- do {
395
- $test_name = "{$name_base}-{$num}.{$extension}";
396
- if(!file_exists(WPSC_IMAGE_DIR.$test_name)) {
397
- $image_name = $test_name;
398
- }
399
- $num++;
400
- } while ($image_name == null);
401
- }
402
- $new_image_path = WPSC_IMAGE_DIR.$image_name;
403
- move_uploaded_file($input_file, $new_image_path);
404
- $stat = stat( dirname( $new_image_path ));
405
- $perms = $stat['mode'] & 0000775;
406
- @ chmod( $new_image_path, $perms );
407
- $image = $wpdb->escape($image_name);
408
- }
409
- } else {
410
- $image_data = $wpdb->get_row("SELECT `id`,`image` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='".(int)$id."' LIMIT 1",ARRAY_A);
411
- $image = false;
412
- }
413
- if($return_imageid == true) {
414
- return array('image_id' => $image_id, 'filename' => $image);
415
- } else {
416
- return $image;
417
- }
418
- }
419
-
420
-
421
 
422
  function wpsc_get_mimetype($file, $check_reliability = false) {
423
  // Sometimes we need to know how useless the result from this is, hence the "check_reliability" parameter
@@ -436,24 +191,6 @@ function wpsc_get_mimetype($file, $check_reliability = false) {
436
  }
437
  }
438
 
439
-
440
- function shopping_cart_total_weight() {
441
- global $wpdb;
442
- $cart = $_SESSION['nzshpcrt_cart'];
443
- $total_weight=0;
444
- foreach((array)$cart as $item) {
445
- $weight = array();
446
- if(($weight == null) || ($weight['weight'] == null) && ($weight['weight_unit'] == null)) {
447
- $weight=$wpdb->get_row("SELECT `weight`, `weight_unit` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE id='{$item->product_id}'", ARRAY_A);
448
- }
449
- $weight = $item->product_meta['weight'];
450
-
451
- $sub_weight = $weight*$item->quantity;
452
- $total_weight += $sub_weight;
453
- }
454
- return $total_weight;
455
- }
456
-
457
  function wpsc_convert_weights($weight, $unit) {
458
  if (is_array($weight)) {
459
  $weight = $weight['weight'];
@@ -574,6 +311,8 @@ function wpsc_sanitise_keys($value) {
574
  function wpsc_check_stock($state, $product) {
575
  global $wpdb;
576
  // if quantity is enabled and is zero
 
 
577
  $out_of_stock = false;
578
  $product_meta = get_product_meta($product->ID, 'product_metadata',true);
579
  $stock_count = get_product_meta($product->ID, 'stock',true);
24
  $decimals = 0;
25
  else
26
  $decimals = 2; // default is 2
27
+
28
+ $decimals = apply_filters('wpsc_modify_decimals' , $decimals);
29
  if('' == get_option('wpsc_decimal_separator'))
30
  $decimal_separator = '.';
31
  else
54
  if ( true == $query['display_currency_symbol'] ) {
55
  if ( !empty( $wpsc_currency_data['symbol'] ) ) {
56
  if ( false == $query['display_as_html'] ) {
57
+ $currency_sign = html_entity_decode($wpsc_currency_data['symbol_html']);
58
  } else {
59
+ $currency_sign = html_entity_decode($wpsc_currency_data['symbol']);
60
  }
61
  } else {
62
  $currency_sign = $wpsc_currency_data['code'];
111
 
112
  foreach((array)$all_claimed_stock as $claimed_stock) {
113
  // for people to have claimed stock, it must have been available to take, no need to look at the existing stock, just subtract from it
114
+ // If this is ever wrong, and you get negative stock, do not fix it here, go find the real cause of the problem
115
  $product_id = absint($claimed_stock['product_id']);
 
116
  $product = get_post($product_id);
117
  $current_stock = get_post_meta($product_id, '_wpsc_stock', true);
118
  $remaining_stock = $current_stock - $claimed_stock['stock_claimed'];
162
  * All the code below here needs commenting and looking at to see if it needs to be altered or disposed of.
163
  * Correspondingly, all the code above here has been commented, uses the wpsc prefix, and has been made for or modified to work with the object oriented cart code.
164
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
 
166
  function admin_display_total_price($start_timestamp = '', $end_timestamp = '') {
167
  global $wpdb;
173
  $total = $wpdb->get_var($sql);
174
  return $total;
175
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
 
177
  function wpsc_get_mimetype($file, $check_reliability = false) {
178
  // Sometimes we need to know how useless the result from this is, hence the "check_reliability" parameter
191
  }
192
  }
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  function wpsc_convert_weights($weight, $unit) {
195
  if (is_array($weight)) {
196
  $weight = $weight['weight'];
311
  function wpsc_check_stock($state, $product) {
312
  global $wpdb;
313
  // if quantity is enabled and is zero
314
+ $state['state'] = false;
315
+ $state['messages'] = array();
316
  $out_of_stock = false;
317
  $product_meta = get_product_meta($product->ID, 'product_metadata',true);
318
  $stock_count = get_product_meta($product->ID, 'stock',true);
wpsc-includes/product-template.php CHANGED
@@ -67,6 +67,22 @@ function wpsc_pagination($totalpages = '', $per_page = '', $current_page = '', $
67
  global $wp_query,$wpsc_query;
68
  $num_paged_links = 4; //amount of links to show on either side of current page
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  if(empty($totalpages)){
71
  if('wpsc-product' == $wp_query->query_vars['post_type'] && 'wpsc_product_category' != $wpsc_query->query_vars['taxonomy'])
72
  $totalpages = $wp_query->max_num_pages;
@@ -112,19 +128,19 @@ function wpsc_pagination($totalpages = '', $per_page = '', $current_page = '', $
112
 
113
  // Should we show the FIRST PAGE link?
114
  if($current_page > 1)
115
- $output .= "<a href=\"". $page_link ."\" title=\"First Page\"> &laquo; First </a>";
116
 
117
  // Should we show the PREVIOUS PAGE link?
118
  if($current_page > 2) {
119
  $previous_page = $current_page - 1;
120
- $output .= " <a href=\"". $page_link .$separator. $previous_page ."\" title=\"Previous Page\"> &lt; Previous </a>";
121
  }
122
  $i =$current_page - $num_paged_links;
123
  $count = 1;
124
  if($i <= 0) $i =1;
125
  while($i < $current_page){
126
  if($count <= $num_paged_links){
127
- $output .= " <a href=\"". $page_link .$separator. $i ."\" title=\"Page ".$i." \"> ".$i." </a>";
128
  }
129
  $i++;
130
  $count++;
@@ -139,7 +155,7 @@ function wpsc_pagination($totalpages = '', $per_page = '', $current_page = '', $
139
  if($current_page < $totalpages){
140
  while(($i) > $current_page){
141
  if($count < $num_paged_links && ($count+$current_page) <= $totalpages){
142
- $output .= " <a href=\"". $page_link .$separator. ($count+$current_page) ."\" title=\"Page ".($count+$current_page)." \"> ".($count+$current_page)." </a>";
143
  $i++;
144
  }else{
145
  break;
@@ -152,16 +168,28 @@ function wpsc_pagination($totalpages = '', $per_page = '', $current_page = '', $
152
 
153
  if($current_page < $totalpages) {
154
  $next_page = $current_page + 1;
155
- $output .= "<a href=\"". $page_link .$separator. $next_page ."\" title=\"Next Page\"> Next &gt; </a>";
156
  }
157
  // Should we show the LAST PAGE link?
158
  if($current_page < $totalpages) {
159
- $output .= " <a href=\"". $page_link .$separator. $totalpages ."\" title=\"Last Page\"> Last &raquo; </a>";
160
  }
161
  // Return the output.
162
  echo $output;
163
  }
164
 
 
 
 
 
 
 
 
 
 
 
 
 
165
 
166
  /**
167
  * wpsc product image function
@@ -249,8 +277,10 @@ function wpsc_the_product_price( $no_decimals = false ) {
249
  if ( count( $wpsc_variations->first_variations ) > 0 ) {
250
  //select the variation ID with lowest price
251
  $product_id = $wpdb->get_var('SELECT `posts`.`id` FROM ' . $wpdb->posts . ' `posts` JOIN ' . $wpdb->postmeta . ' `postmeta` ON `posts`.`id` = `postmeta`.`post_id` WHERE `posts`.`post_parent` = ' . get_the_ID() . ' AND `posts`.`post_type` = "wpsc-product" AND `posts`.`post_status` = "inherit" AND `postmeta`.`meta_key`="_wpsc_price" ORDER BY (`postmeta`.`meta_value`)+0 ASC LIMIT 1');
 
252
  } else {
253
  $product_id = get_the_ID();
 
254
  }
255
 
256
  $full_price = get_post_meta( $product_id, '_wpsc_price', true );
@@ -262,21 +292,36 @@ function wpsc_the_product_price( $no_decimals = false ) {
262
 
263
  if ( $no_decimals == true )
264
  $price = array_shift( explode( ".", $price ) );
265
-
266
- $output = wpsc_currency_display( $price, array('display_as_html' => false) );
 
 
 
 
267
  //if product has variations - add 'from'
268
- if ( count( $wpsc_variations->first_variations ) > 0 )
 
269
  $output = sprintf(__(' from %s', 'wpsc'), $output);
270
 
271
  return $output;
272
  }
273
 
274
  function wpsc_calculate_price( $product_id, $variations = null, $special = true ) {
 
 
275
  if ( count( $variations ) > 0 )
276
  $product_id = wpsc_get_child_object_in_terms( $product_id, $variations, 'wpsc-variation' );
277
  else if ( !$product_id )
278
  $product_id = get_the_ID();
279
 
 
 
 
 
 
 
 
 
280
  if ( $special == true ) {
281
  $full_price = get_post_meta( $product_id, '_wpsc_price', true );
282
  $special_price = get_post_meta( $product_id, '_wpsc_special_price', true );
@@ -288,6 +333,7 @@ function wpsc_calculate_price( $product_id, $variations = null, $special = true
288
  } else {
289
  $price = get_post_meta( $product_id, '_wpsc_price', true );
290
  }
 
291
  return $price;
292
  }
293
 
@@ -329,10 +375,12 @@ function wpsc_display_categories() {
329
  * @return boolean - true for yes, false for no
330
  */
331
  function wpsc_display_products() {
 
 
332
  //we have to display something, if we are not displaying categories, then we must display products
333
  $output = true;
334
  if ( wpsc_display_categories ( ) ) {
335
- if ( get_option( 'wpsc_default_category' ) == 'list' )
336
  $output = false;
337
 
338
  if ( isset( $_GET['range'] ) || isset( $_GET['category'] ) )
@@ -590,6 +638,45 @@ function wpsc_product_external_link( $id = null ) {
590
  }
591
  }
592
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
593
  /**
594
  * wpsc product sku function
595
  * @return string - the product price
@@ -641,12 +728,20 @@ function wpsc_check_variation_stock_availability( $product_id, $variations ) {
641
  }
642
  }
643
  }
 
644
  if ( wpsc_product_has_stock( $the_selected_product ) ) {
 
 
 
645
 
646
- $stock = get_product_meta( $the_selected_product, "_wpsc_stock" );
647
- $stock = apply_filters( 'wpsc_product_variation_stock', $stock[0], $id );
648
  if ( 0 < $stock )
649
  return $stock;
 
 
 
 
 
 
650
  }
651
  return '';
652
  }
@@ -664,6 +759,7 @@ function wpsc_product_has_stock( $id = null ) {
664
  $id = get_the_ID();
665
 
666
  $stock = get_post_meta( $id, '_wpsc_stock', true );
 
667
  $stock = apply_filters( 'wpsc_product_stock', $stock, $id );
668
 
669
  if ( is_numeric( $stock ) ) {
@@ -672,6 +768,7 @@ function wpsc_product_has_stock( $id = null ) {
672
  if($stock - $claimed_stock > 0)
673
  return true;
674
  }
 
675
  $variations = get_children( array( "post_type" => "wpsc-product", "post_parent" => $id ) );
676
  if ( count( $variations ) ) {
677
  foreach ( $variations as $variation ) {
@@ -853,6 +950,7 @@ function wpsc_product_normal_price() {
853
  $product_id = get_the_ID();
854
  $from = '';
855
  }
 
856
  $price = get_product_meta( $product_id, 'price', true );
857
  $output = $from.wpsc_currency_display( $price );
858
  return $output;
@@ -1131,30 +1229,23 @@ function wpsc_the_variation() {
1131
  $wpsc_variations->the_variation();
1132
  }
1133
 
 
1134
  function wpsc_product_has_multicurrency() {
1135
  global $wpdb, $wpsc_query;
1136
- //echo "<pre>".print_r($wpdb,true)."</pre>";
1137
-
1138
- $sql = "SELECT `meta_key`, `meta_value` FROM `" . $wpdb->postmeta . "` WHERE `post_id`=" . get_the_ID() . " AND `meta_key` LIKE '_wpsc_currency%'";
1139
- $results = $wpdb->get_results( $sql, ARRAY_A );
1140
- if ( count( $results ) > 0 )
1141
  return true;
1142
  else
1143
  return false;
1144
-
1145
- // exit('<pre>'.print_r($results, true).'</pre>');
1146
  }
1147
 
1148
  function wpsc_display_product_multicurrency() {
1149
  global $wpdb, $wpsc_query;
1150
 
1151
- $sql = "SELECT `meta_key`, `meta_value` FROM `" . $wpdb->postmeta . "` WHERE `post_id`=" . get_the_ID() . " AND `meta_key` LIKE '_wpsc_currency%'";
1152
- $results = $wpdb->get_results( $sql, ARRAY_A );
1153
-
1154
  if ( count( $results ) > 0 ) {
1155
- foreach ( (array)$results as $curr ) {
1156
- $isocode = str_ireplace( "currency[", "", $curr['meta_key'] );
1157
- $isocode = str_ireplace( "]", "", $isocode );
1158
  $currency_data = $wpdb->get_row( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`='" . $isocode . "' LIMIT 1", ARRAY_A );
1159
 
1160
  if ( $currency_data['symbol'] != '' )
@@ -1163,7 +1254,7 @@ function wpsc_display_product_multicurrency() {
1163
  $currency_sign = $currency_data['code'];
1164
 
1165
  if ( !empty( $currency_sign ) )
1166
- return '<span class="wpscsmall pricefloatright pricedisplay">' . $currency_sign . ' ' . wpsc_currency_display( $curr["meta_value"] ) . '</span><br />';
1167
  }
1168
  }
1169
 
@@ -1627,4 +1718,4 @@ function wpsc_get_downloadable_files($product_id){
1627
  $attached_files = (array)get_posts( $args );
1628
  return $attached_files;
1629
  }
1630
- ?>
67
  global $wp_query,$wpsc_query;
68
  $num_paged_links = 4; //amount of links to show on either side of current page
69
 
70
+ //additional links, items per page and products order
71
+ if( get_option('permalink_structure') != '' ){
72
+ $additional_links_separator = '?';
73
+ }else{
74
+ $additional_links_separator = '&';
75
+ }
76
+ if( !empty( $_GET['items_per_page'] ) ){
77
+ $additional_links = $additional_links_separator . 'items_per_page=' . $_GET['items_per_page'];
78
+ $additional_links_separator = '&';
79
+ }
80
+ if( !empty( $_GET['product_order'] ) )
81
+ $additional_links .= $additional_links_separator . 'product_order=' . $_GET['product_order'];
82
+
83
+ $additional_links = apply_filters('wpsc_pagination_additional_links', $additional_links);
84
+ //end of additional links
85
+
86
  if(empty($totalpages)){
87
  if('wpsc-product' == $wp_query->query_vars['post_type'] && 'wpsc_product_category' != $wpsc_query->query_vars['taxonomy'])
88
  $totalpages = $wp_query->max_num_pages;
128
 
129
  // Should we show the FIRST PAGE link?
130
  if($current_page > 1)
131
+ $output .= "<a href=\"". $page_link . $additional_links . "\" title=\"First Page\"> &laquo; First </a>";
132
 
133
  // Should we show the PREVIOUS PAGE link?
134
  if($current_page > 2) {
135
  $previous_page = $current_page - 1;
136
+ $output .= " <a href=\"". $page_link .$separator. $previous_page . $additional_links . "\" title=\"Previous Page\"> &lt; Previous </a>";
137
  }
138
  $i =$current_page - $num_paged_links;
139
  $count = 1;
140
  if($i <= 0) $i =1;
141
  while($i < $current_page){
142
  if($count <= $num_paged_links){
143
+ $output .= " <a href=\"". $page_link .$separator. $i . $additional_links . "\" title=\"Page ".$i." \"> ".$i." </a>";
144
  }
145
  $i++;
146
  $count++;
155
  if($current_page < $totalpages){
156
  while(($i) > $current_page){
157
  if($count < $num_paged_links && ($count+$current_page) <= $totalpages){
158
+ $output .= " <a href=\"". $page_link .$separator. ($count+$current_page) .$additional_links . "\" title=\"Page ".($count+$current_page)." \"> ".($count+$current_page)." </a>";
159
  $i++;
160
  }else{
161
  break;
168
 
169
  if($current_page < $totalpages) {
170
  $next_page = $current_page + 1;
171
+ $output .= "<a href=\"". $page_link .$separator. $next_page . $additional_links . "\" title=\"Next Page\"> Next &gt; </a>";
172
  }
173
  // Should we show the LAST PAGE link?
174
  if($current_page < $totalpages) {
175
+ $output .= " <a href=\"". $page_link .$separator. $totalpages . $additional_links . "\" title=\"Last Page\"> Last &raquo; </a>";
176
  }
177
  // Return the output.
178
  echo $output;
179
  }
180
 
181
+ /**
182
+ * wpsc_show_stock_availability
183
+ *
184
+ * Checks to see whether stock symbols need to be shown
185
+ * @return boolean - true is the option has been checked false otherwise
186
+ */
187
+ function wpsc_show_stock_availability(){
188
+ if( get_option('list_view_quantity') == 1 )
189
+ return true;
190
+ else
191
+ return false;
192
+ }
193
 
194
  /**
195
  * wpsc product image function
277
  if ( count( $wpsc_variations->first_variations ) > 0 ) {
278
  //select the variation ID with lowest price
279
  $product_id = $wpdb->get_var('SELECT `posts`.`id` FROM ' . $wpdb->posts . ' `posts` JOIN ' . $wpdb->postmeta . ' `postmeta` ON `posts`.`id` = `postmeta`.`post_id` WHERE `posts`.`post_parent` = ' . get_the_ID() . ' AND `posts`.`post_type` = "wpsc-product" AND `posts`.`post_status` = "inherit" AND `postmeta`.`meta_key`="_wpsc_price" ORDER BY (`postmeta`.`meta_value`)+0 ASC LIMIT 1');
280
+ $from = ' from ';
281
  } else {
282
  $product_id = get_the_ID();
283
+ $from = '';
284
  }
285
 
286
  $full_price = get_post_meta( $product_id, '_wpsc_price', true );
292
 
293
  if ( $no_decimals == true )
294
  $price = array_shift( explode( ".", $price ) );
295
+
296
+ $args = array(
297
+ 'display_as_html' => false,
298
+ 'display_decimal_point' => !$no_decimals
299
+ );
300
+ $output = wpsc_currency_display( $price,$args );
301
  //if product has variations - add 'from'
302
+ $from = apply_filters('wpsc_product_variation_text',$from);
303
+ if ( count( $wpsc_variations->first_variations ) > 0 && !empty($from))
304
  $output = sprintf(__(' from %s', 'wpsc'), $output);
305
 
306
  return $output;
307
  }
308
 
309
  function wpsc_calculate_price( $product_id, $variations = null, $special = true ) {
310
+ global $wpdb;
311
+ $p_id = $product_id;
312
  if ( count( $variations ) > 0 )
313
  $product_id = wpsc_get_child_object_in_terms( $product_id, $variations, 'wpsc-variation' );
314
  else if ( !$product_id )
315
  $product_id = get_the_ID();
316
 
317
+ if( !$product_id && count( $variations ) > 0){
318
+ $product_ids = wpsc_get_child_object_in_select_terms( $p_id, $variations, 'wpsc_variation' );
319
+ $sql = "SELECT `post_id` FROM ".$wpdb->postmeta." WHERE `meta_key` = '_wpsc_stock' AND `meta_value` != '0' AND `post_id` IN (".implode(',' , $product_ids).")";
320
+ $stock_available = $wpdb->get_col($sql);
321
+ $sql = "SELECT `post_id` FROM ".$wpdb->postmeta." WHERE `meta_key` = '_wpsc_price' AND `post_id` IN (".implode(',',$stock_available).") ORDER BY `meta_value` ASC LIMIT 1";
322
+ $product_id = $wpdb->get_var($sql);
323
+ }
324
+
325
  if ( $special == true ) {
326
  $full_price = get_post_meta( $product_id, '_wpsc_price', true );
327
  $special_price = get_post_meta( $product_id, '_wpsc_special_price', true );
333
  } else {
334
  $price = get_post_meta( $product_id, '_wpsc_price', true );
335
  }
336
+
337
  return $price;
338
  }
339
 
375
  * @return boolean - true for yes, false for no
376
  */
377
  function wpsc_display_products() {
378
+ global $post;
379
+ $product_page_id = wpec_get_the_post_id_by_shortcode('[productspage]');
380
  //we have to display something, if we are not displaying categories, then we must display products
381
  $output = true;
382
  if ( wpsc_display_categories ( ) ) {
383
+ if ( get_option( 'wpsc_default_category' ) == 'list' && $post->ID == $product_page_id )
384
  $output = false;
385
 
386
  if ( isset( $_GET['range'] ) || isset( $_GET['category'] ) )
638
  }
639
  }
640
 
641
+ /**
642
+ * wpsc external link text function
643
+ * @return string - the product external link text
644
+ */
645
+ function wpsc_product_external_link_text( $id = null, $default = null ) {
646
+ if ( is_numeric( $id ) && ( $id > 0 ) )
647
+ $id = absint( $id );
648
+ else
649
+ $id = get_the_ID();
650
+
651
+ $external_link_text = __( 'Buy Now', 'wpsc' );
652
+ if ( $default != null ) {
653
+ $external_link_text = $default;
654
+ }
655
+
656
+ $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
657
+ if ( isset( $product_meta['external_link_text'] ) && !empty( $product_meta['external_link_text'] ) ) {
658
+ $external_link_text = $product_meta['external_link_text'];
659
+ }
660
+ return $external_link_text;
661
+ }
662
+
663
+ /**
664
+ * wpsc external link target function
665
+ * @return string - the product external link target
666
+ */
667
+ function wpsc_product_external_link_target( $id = null, $external_link_target = '' ) {
668
+ if ( is_numeric( $id ) && ( $id > 0 ) )
669
+ $id = absint( $id );
670
+ else
671
+ $id = get_the_ID();
672
+
673
+ $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
674
+ if ( isset( $product_meta['external_link_target'] ) && !empty( $product_meta['external_link_target'] ) ) {
675
+ $external_link_target = $product_meta['external_link_target'];
676
+ }
677
+ return $external_link_target;
678
+ }
679
+
680
  /**
681
  * wpsc product sku function
682
  * @return string - the product price
728
  }
729
  }
730
  }
731
+
732
  if ( wpsc_product_has_stock( $the_selected_product ) ) {
733
+ //exit('Stock Count is: '. $the_selected_product);
734
+ $stock = get_product_meta( $the_selected_product, "stock", true );
735
+ $stock = apply_filters( 'wpsc_product_variation_stock', $stock, $id );
736
 
 
 
737
  if ( 0 < $stock )
738
  return $stock;
739
+ }else{
740
+ $stock = get_product_meta( $the_selected_product, "stock", true );
741
+ $stock = apply_filters( 'wpsc_product_variation_stock', $stock, $id );
742
+ if ( is_numeric($stock) )
743
+ return $stock;
744
+
745
  }
746
  return '';
747
  }
759
  $id = get_the_ID();
760
 
761
  $stock = get_post_meta( $id, '_wpsc_stock', true );
762
+
763
  $stock = apply_filters( 'wpsc_product_stock', $stock, $id );
764
 
765
  if ( is_numeric( $stock ) ) {
768
  if($stock - $claimed_stock > 0)
769
  return true;
770
  }
771
+
772
  $variations = get_children( array( "post_type" => "wpsc-product", "post_parent" => $id ) );
773
  if ( count( $variations ) ) {
774
  foreach ( $variations as $variation ) {
950
  $product_id = get_the_ID();
951
  $from = '';
952
  }
953
+ $from = apply_filters('wpsc_product_variation_text',$from);
954
  $price = get_product_meta( $product_id, 'price', true );
955
  $output = $from.wpsc_currency_display( $price );
956
  return $output;
1229
  $wpsc_variations->the_variation();
1230
  }
1231
 
1232
+
1233
  function wpsc_product_has_multicurrency() {
1234
  global $wpdb, $wpsc_query;
1235
+
1236
+ $currency = get_product_meta(get_the_ID(),'currency',true);
1237
+ if ( count( $currency ) > 0 )
 
 
1238
  return true;
1239
  else
1240
  return false;
 
 
1241
  }
1242
 
1243
  function wpsc_display_product_multicurrency() {
1244
  global $wpdb, $wpsc_query;
1245
 
1246
+ $results = get_product_meta(get_the_ID(),'currency',true);
 
 
1247
  if ( count( $results ) > 0 ) {
1248
+ foreach ( (array)$results as $isocode => $curr ) {
 
 
1249
  $currency_data = $wpdb->get_row( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`='" . $isocode . "' LIMIT 1", ARRAY_A );
1250
 
1251
  if ( $currency_data['symbol'] != '' )
1254
  $currency_sign = $currency_data['code'];
1255
 
1256
  if ( !empty( $currency_sign ) )
1257
+ return '<span class="wpscsmall pricefloatright pricedisplay">' . $isocode . ' ' . wpsc_currency_display( $curr["meta_value"] ) . '</span><br />';
1258
  }
1259
  }
1260
 
1718
  $attached_files = (array)get_posts( $args );
1719
  return $attached_files;
1720
  }
1721
+ ?>
wpsc-includes/purchaselogs.class.php CHANGED
@@ -346,7 +346,7 @@ function wpsc_purchaselog_details_SKU() {
346
  if ( $meta_value != null ) {
347
  return $meta_value;
348
  } else {
349
- $meta_value = get_product_meta( $purchlogitem->purchitem->prodid, 'sku' );
350
  if ( $meta_value != null ) {
351
  return $meta_value;
352
  } else {
@@ -526,7 +526,7 @@ function wpsc_display_purchlog_buyers_email() {
526
 
527
  function wpsc_display_purchlog_buyers_address() {
528
  global $purchlogitem;
529
- return htmlentities( stripslashes( $purchlogitem->userinfo['billingaddress']['value'] ), ENT_QUOTES );
530
  }
531
 
532
  function wpsc_display_purchlog_buyers_phone() {
@@ -543,7 +543,7 @@ function wpsc_display_purchlog_shipping_name() {
543
  function wpsc_display_purchlog_shipping_address() {
544
  global $purchlogitem;
545
  // exit('<pre>'.print_r($purchlogitem->shippinginfo,true).'</pre>');
546
- return htmlentities( stripslashes( $purchlogitem->shippinginfo['shippingaddress']['value'] ), ENT_QUOTES );
547
  }
548
 
549
  function wpsc_display_purchlog_shipping_city() {
346
  if ( $meta_value != null ) {
347
  return $meta_value;
348
  } else {
349
+ $meta_value = get_product_meta( $purchlogitem->purchitem->prodid, 'sku', true );
350
  if ( $meta_value != null ) {
351
  return $meta_value;
352
  } else {
526
 
527
  function wpsc_display_purchlog_buyers_address() {
528
  global $purchlogitem;
529
+ return nl2br(trim(htmlentities( stripslashes( $purchlogitem->userinfo['billingaddress']['value'] ), ENT_QUOTES ), "\n\r"));
530
  }
531
 
532
  function wpsc_display_purchlog_buyers_phone() {
543
  function wpsc_display_purchlog_shipping_address() {
544
  global $purchlogitem;
545
  // exit('<pre>'.print_r($purchlogitem->shippinginfo,true).'</pre>');
546
+ return nl2br(trim(htmlentities( stripslashes( $purchlogitem->shippinginfo['shippingaddress']['value'] ), ENT_QUOTES ), "\n\r"));
547
  }
548
 
549
  function wpsc_display_purchlog_shipping_city() {
wpsc-includes/theme.functions.php CHANGED
@@ -229,7 +229,7 @@ function wpsc_get_template_file_url( $file = '' ) {
229
  // Save the transient and update it every 12 hours
230
  if ( !empty( $file_url ) )
231
  set_transient( WPEC_TRANSIENT_THEME_URL_PREFIX . $file, $file_url, 60 * 60 * 12 );
232
- }elseif(!file_exists($file_path)){
233
  delete_transient(WPEC_TRANSIENT_THEME_URL_PREFIX . $file);
234
  wpsc_get_template_file_url($file);
235
  }
@@ -324,15 +324,15 @@ function wpsc_get_the_category_id($slug, $type = 'name'){
324
 
325
  function wpsc_get_the_category_display($slug){
326
  global $wpdb;
 
327
  if ( !empty($slug) && is_string($slug) ) {
328
  $category_id = wpsc_get_the_category_id($slug , 'slug');
329
  $display_type = wpsc_get_categorymeta( $category_id, 'display_type' );
330
  }
331
-
332
  if(!empty($display_type))
333
  return $display_type;
334
  else
335
- return 'default';
336
  }
337
 
338
  /**
@@ -347,11 +347,8 @@ function wpsc_get_the_category_display($slug){
347
  function wpsc_single_template( $content ) {
348
 
349
  global $wpdb, $post, $wp_query, $wpsc_query;
350
-
351
  $single_theme_path = wpsc_get_template_file_path( 'wpsc-single_product.php' );
352
- //echo 'Single <pre>'.print_r($wp_query,true).'</pre>';
353
- if ( 'wpsc-product' == $post->post_type && !is_archive() && $wp_query->post_count <= 1) {
354
-
355
  remove_filter( "the_content", "wpsc_single_template" );
356
  $wpsc_temp_query = new WP_Query( array( 'post__in' => array( $post->ID ), 'post_type' => 'wpsc-product','posts_per_page'=>1 ) );
357
  list( $wp_query, $wpsc_temp_query ) = array( $wpsc_temp_query, $wp_query ); // swap the wpsc_query object
@@ -361,7 +358,6 @@ function wpsc_single_template( $content ) {
361
  ob_end_clean();
362
  list( $wp_query, $wpsc_temp_query ) = array( $wpsc_temp_query, $wp_query ); // swap the wpsc_query objects back
363
  }elseif(is_archive() && wpsc_is_viewable_taxonomy() || ($wp_query->post_count > 1 && 1 == $wp_query->is_product)){
364
- // echo 'Archive <pre>'.print_r($wp_query,true).'</pre>';
365
  remove_filter( "the_content", "wpsc_single_template" );
366
  list( $wp_query, $wpsc_query ) = array( $wpsc_query, $wp_query ); // swap the wpsc_query object
367
  if(isset($wp_query->query['pagename']))
@@ -388,7 +384,7 @@ function wpsc_single_template( $content ) {
388
 
389
  function wpsc_is_viewable_taxonomy(){
390
  global $wp_query;
391
- if('wpsc_product_category' == $wp_query->query_vars['taxonomy'] || 'product_tag' == $wp_query->query_vars['taxonomy'] )
392
  return true;
393
  else
394
  return false;
@@ -405,18 +401,22 @@ function wpsc_is_viewable_taxonomy(){
405
  function wpsc_the_category_title($title, $id){
406
  global $wp_query;
407
  $post = get_post($id);
408
- remove_filter('the_title','wpsc_the_category_title');
409
  if(isset($wp_query->query_vars['post_type']) && 'wpsc-product' == $wp_query->query_vars['post_type'] && isset($wp_query->query_vars['paged']) && $wp_query->current_post == 0 && $wp_query->posts[0]->post_title == $post->post_title && count($wp_query->posts) >1 ){
410
- remove_filter('the_title','wpsc_the_category_title');
411
  $id = wpec_get_the_post_id_by_shortcode('[productspage]');
412
  $post = get_post($id);
413
  return $post->post_title;
414
  }
415
- if('wpsc-product' == $post->post_type && $wp_query->posts[0]->post_title == $post->post_title && isset($wp_query->query_vars['term']) && isset($wp_query->query_vars['taxonomy']) && !($wp_query->is_admin)){
416
  remove_filter('the_title','wpsc_the_category_title');
417
- $category_id = wpsc_get_the_category_id($wp_query->query_vars['term'],'slug');
418
- $category = get_term($category_id, $wp_query->query_vars['taxonomy']);
 
 
 
 
419
  }
 
420
  if(!empty($category->name))
421
  return $category->name;
422
  else
@@ -432,11 +432,16 @@ function wpsc_the_category_title($title, $id){
432
  * @return $template (string)
433
  */
434
  function wpsc_the_category_template($template){
435
- if(wpsc_is_viewable_taxonomy() && false !== strpos($template,'archive')){
 
 
 
 
 
436
  return str_ireplace('archive', 'page',$template);
437
- }else{
438
  return $template;
439
- }
440
  }
441
 
442
  /**
@@ -524,13 +529,20 @@ function wpsc_enqueue_user_script_and_css() {
524
  wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
525
  wp_enqueue_script( 'jquery-rating', WPSC_CORE_JS_URL . '/jquery.rating.js', array( 'jquery' ), $version_identifier );
526
  wp_enqueue_script( 'wp-e-commerce-legacy', WPSC_CORE_JS_URL . '/user.js', array( 'jquery' ), WPSC_VERSION . WPSC_MINOR_VERSION );
527
- wp_enqueue_script( 'wpsc-thickbox', WPSC_CORE_JS_URL . '/thickbox.js', array( 'jquery' ), 'Instinct_e-commerce' );
 
 
 
 
 
 
 
 
528
 
529
  wp_enqueue_style( 'wpsc-theme-css', wpsc_get_template_file_url( 'wpsc-' . get_option( 'wpsc_selected_theme' ) . '.css' ), false, $version_identifier, 'all' );
530
  wp_enqueue_style( 'wpsc-theme-css-compatibility', WPSC_CORE_THEME_URL . 'compatibility.css', false, $version_identifier, 'all' );
531
  wp_enqueue_style( 'wpsc-product-rater', WPSC_CORE_JS_URL . '/product_rater.css', false, $version_identifier, 'all' );
532
  wp_enqueue_style( 'wp-e-commerce-dynamic', $siteurl . "/index.php?wpsc_user_dynamic_css=true&category=$category_id", false, $version_identifier, 'all' );
533
- wp_enqueue_style( 'wpsc-thickbox', WPSC_CORE_JS_URL . '/thickbox.css', false, $version_identifier, 'all' );
534
 
535
  }
536
 
@@ -612,6 +624,8 @@ function wpsc_user_dynamic_css() {
612
  if ( $single_thumbnail_width <= 0 ) {
613
  $single_thumbnail_width = 128;
614
  }
 
 
615
  ?>
616
 
617
  /*
@@ -635,9 +649,15 @@ function wpsc_user_dynamic_css() {
635
  height: <?php echo $thumbnail_height; ?>px;
636
  }
637
 
638
- div.default_product_display div.item_no_image {
639
- width: <?php echo $thumbnail_width - 2; ?>px;
640
- height: <?php echo $thumbnail_height - 2; ?>px;
 
 
 
 
 
 
641
  }
642
  div.default_product_display div.item_no_image a {
643
  width: <?php echo $thumbnail_width - 2; ?>px;
@@ -922,7 +942,9 @@ function wpsc_products_page( $content = '' ) {
922
  $display_type = get_option('product_view');
923
  if ( isset( $_SESSION['wpsc_display_type'] ) ) {
924
  $display_type = $_SESSION['wpsc_display_type'];
 
925
  }
 
926
  ob_start();
927
  wpsc_include_products_page_template($display_type);
928
  $is_single = false;
@@ -1120,9 +1142,7 @@ function wpsc_enable_page_filters( $excerpt = '' ) {
1120
  add_filter( 'the_title', 'wpsc_the_category_title',10,2 );
1121
  add_filter( 'the_content', 'wpsc_place_shopping_cart', 12 );
1122
  add_filter( 'the_content', 'wpsc_transaction_results', 12 );
1123
- add_filter( 'the_content', 'nszhpcrt_homepage_products', 12 );
1124
  add_filter( 'the_content', 'wpsc_user_log', 12 );
1125
- add_filter( 'the_content', 'nszhpcrt_category_tag', 12 );
1126
  add_filter( 'the_content', 'wpsc_show_categories', 12 );
1127
  return $excerpt;
1128
  }
@@ -1133,9 +1153,7 @@ function wpsc_disable_page_filters( $excerpt = '' ) {
1133
  remove_filter( 'the_content', 'wpsc_single_template' );
1134
  remove_filter( 'the_content', 'wpsc_place_shopping_cart' );
1135
  remove_filter( 'the_content', 'wpsc_transaction_results' );
1136
- remove_filter( 'the_content', 'nszhpcrt_homepage_products' );
1137
  remove_filter( 'the_content', 'wpsc_user_log' );
1138
- remove_filter( 'the_content', 'wpsc_category_tag' );
1139
  remove_filter( 'the_content', 'wpsc_show_categories' );
1140
  remove_filter( 'the_content', 'wpsc_substitute_buy_now_button' );
1141
  return $excerpt;
@@ -1326,7 +1344,7 @@ class WPSC_Hide_subcatsprods_in_cat {
1326
  function get_posts( &$q ) {
1327
  $this->q =& $q;
1328
 
1329
- if ( "wpsc_product_category" != $q->query_vars['taxonomy'] )
1330
  return false;
1331
 
1332
  add_action( 'posts_where', array( &$this, 'where' ) );
@@ -1335,7 +1353,7 @@ class WPSC_Hide_subcatsprods_in_cat {
1335
 
1336
  function where( $where ) {
1337
  global $wpdb;
1338
-
1339
  remove_action( 'posts_where', array( &$this, 'where' ) );
1340
 
1341
  $term_id=$wpdb->get_var($wpdb->prepare('SELECT term_id FROM '.$wpdb->terms.' WHERE slug = %s ', $this->q->query_vars['term']));
@@ -1392,4 +1410,4 @@ function wpsc_the_featured_image_fix($stuff){
1392
  }
1393
 
1394
  add_action('post_thumbnail_html','wpsc_the_featured_image_fix');
1395
- ?>
229
  // Save the transient and update it every 12 hours
230
  if ( !empty( $file_url ) )
231
  set_transient( WPEC_TRANSIENT_THEME_URL_PREFIX . $file, $file_url, 60 * 60 * 12 );
232
+ }elseif(!file_exists(get_stylesheet_directory() . '/' . $file)){
233
  delete_transient(WPEC_TRANSIENT_THEME_URL_PREFIX . $file);
234
  wpsc_get_template_file_url($file);
235
  }
324
 
325
  function wpsc_get_the_category_display($slug){
326
  global $wpdb;
327
+ $default_display_type = get_option('product_view');
328
  if ( !empty($slug) && is_string($slug) ) {
329
  $category_id = wpsc_get_the_category_id($slug , 'slug');
330
  $display_type = wpsc_get_categorymeta( $category_id, 'display_type' );
331
  }
 
332
  if(!empty($display_type))
333
  return $display_type;
334
  else
335
+ return $default_display_type;
336
  }
337
 
338
  /**
347
  function wpsc_single_template( $content ) {
348
 
349
  global $wpdb, $post, $wp_query, $wpsc_query;
 
350
  $single_theme_path = wpsc_get_template_file_path( 'wpsc-single_product.php' );
351
+ if ( 'wpsc-product' == $wp_query->post->post_type && !is_archive() && $wp_query->post_count <= 1) {
 
 
352
  remove_filter( "the_content", "wpsc_single_template" );
353
  $wpsc_temp_query = new WP_Query( array( 'post__in' => array( $post->ID ), 'post_type' => 'wpsc-product','posts_per_page'=>1 ) );
354
  list( $wp_query, $wpsc_temp_query ) = array( $wpsc_temp_query, $wp_query ); // swap the wpsc_query object
358
  ob_end_clean();
359
  list( $wp_query, $wpsc_temp_query ) = array( $wpsc_temp_query, $wp_query ); // swap the wpsc_query objects back
360
  }elseif(is_archive() && wpsc_is_viewable_taxonomy() || ($wp_query->post_count > 1 && 1 == $wp_query->is_product)){
 
361
  remove_filter( "the_content", "wpsc_single_template" );
362
  list( $wp_query, $wpsc_query ) = array( $wpsc_query, $wp_query ); // swap the wpsc_query object
363
  if(isset($wp_query->query['pagename']))
384
 
385
  function wpsc_is_viewable_taxonomy(){
386
  global $wp_query;
387
+ if(isset($wp_query->query_vars['taxonomy']) && ('wpsc_product_category' == $wp_query->query_vars['taxonomy'] || 'product_tag' == $wp_query->query_vars['taxonomy'] ))
388
  return true;
389
  else
390
  return false;
401
  function wpsc_the_category_title($title, $id){
402
  global $wp_query;
403
  $post = get_post($id);
 
404
  if(isset($wp_query->query_vars['post_type']) && 'wpsc-product' == $wp_query->query_vars['post_type'] && isset($wp_query->query_vars['paged']) && $wp_query->current_post == 0 && $wp_query->posts[0]->post_title == $post->post_title && count($wp_query->posts) >1 ){
405
+ remove_filter('the_title','wpsc_the_category_title');
406
  $id = wpec_get_the_post_id_by_shortcode('[productspage]');
407
  $post = get_post($id);
408
  return $post->post_title;
409
  }
410
+ if( wpsc_is_viewable_taxonomy() && 'wpsc-product' == $post->post_type && $wp_query->posts[0]->post_title == $post->post_title ){
411
  remove_filter('the_title','wpsc_the_category_title');
412
+ $category = get_term_by('slug',$wp_query->query_vars['term'],'wpsc_product_category');
413
+ }
414
+ if( isset($wp_query->query_vars['taxonomy']) && 'product_tag' == $wp_query->query_vars['taxonomy'] && $wp_query->posts[0]->post_title == $post->post_title ){
415
+ remove_filter('the_title','wpsc_the_category_title');
416
+ $category->name = $wp_query->query_vars['term'];
417
+
418
  }
419
+ //echo '<br />'.$category->name.'<pre>'.print_r($wp_query,1).'</pre>';
420
  if(!empty($category->name))
421
  return $category->name;
422
  else
432
  * @return $template (string)
433
  */
434
  function wpsc_the_category_template($template){
435
+ global $wp_query;
436
+ //this little bit of code makes sure we dont get an empty content section if no posts are found for a wpec category
437
+ if(wpsc_is_viewable_taxonomy() && 0 == $wp_query->post_count)
438
+ $wp_query->post_count += 1;
439
+ //this bit of code makes sure we use a nice standard page template for our products
440
+ if(wpsc_is_viewable_taxonomy() && false !== strpos($template,'archive'))
441
  return str_ireplace('archive', 'page',$template);
442
+ else
443
  return $template;
444
+
445
  }
446
 
447
  /**
529
  wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
530
  wp_enqueue_script( 'jquery-rating', WPSC_CORE_JS_URL . '/jquery.rating.js', array( 'jquery' ), $version_identifier );
531
  wp_enqueue_script( 'wp-e-commerce-legacy', WPSC_CORE_JS_URL . '/user.js', array( 'jquery' ), WPSC_VERSION . WPSC_MINOR_VERSION );
532
+ $lightbox = get_option('wpsc_lightbox', 'thickbox');
533
+ if( $lightbox == 'thickbox' ) {
534
+ wp_enqueue_script( 'wpsc-thickbox', WPSC_CORE_JS_URL . '/thickbox.js', array( 'jquery' ), 'Instinct_e-commerce' );
535
+ wp_enqueue_style( 'wpsc-thickbox', WPSC_CORE_JS_URL . '/thickbox.css', false, $version_identifier, 'all' );
536
+ } elseif( $lightbox == 'colorbox' ) {
537
+ wp_enqueue_script( 'colorbox-min', WPSC_CORE_JS_URL . '/jquery.colorbox-min.js', array( 'jquery' ), 'Instinct_e-commerce' );
538
+ wp_enqueue_script( 'wpsc_colorbox', WPSC_CORE_JS_URL . '/wpsc_colorbox.js', array( 'jquery', 'colorbox-min' ), 'Instinct_e-commerce' );
539
+ wp_enqueue_style( 'wpsc-colorbox-css', WPSC_CORE_JS_URL . '/wpsc_colorbox.css', false, $version_identifier, 'all' );
540
+ }
541
 
542
  wp_enqueue_style( 'wpsc-theme-css', wpsc_get_template_file_url( 'wpsc-' . get_option( 'wpsc_selected_theme' ) . '.css' ), false, $version_identifier, 'all' );
543
  wp_enqueue_style( 'wpsc-theme-css-compatibility', WPSC_CORE_THEME_URL . 'compatibility.css', false, $version_identifier, 'all' );
544
  wp_enqueue_style( 'wpsc-product-rater', WPSC_CORE_JS_URL . '/product_rater.css', false, $version_identifier, 'all' );
545
  wp_enqueue_style( 'wp-e-commerce-dynamic', $siteurl . "/index.php?wpsc_user_dynamic_css=true&category=$category_id", false, $version_identifier, 'all' );
 
546
 
547
  }
548
 
624
  if ( $single_thumbnail_width <= 0 ) {
625
  $single_thumbnail_width = 128;
626
  }
627
+ $category_height = get_option('category_image_height');
628
+ $category_width = get_option('category_image_width');
629
  ?>
630
 
631
  /*
649
  height: <?php echo $thumbnail_height; ?>px;
650
  }
651
 
652
+ .wpsc_category_grid_item {
653
+ display:block;
654
+ float:left;
655
+ width: <?php echo $category_width; ?>px;
656
+ height: <?php echo $category_height; ?>px;
657
+ }
658
+ .wpsc_category_grid_item span{
659
+ position:relative;
660
+ top:<?php echo ($thumbnail_height - 2)/9; ?>px;
661
  }
662
  div.default_product_display div.item_no_image a {
663
  width: <?php echo $thumbnail_width - 2; ?>px;
942
  $display_type = get_option('product_view');
943
  if ( isset( $_SESSION['wpsc_display_type'] ) ) {
944
  $display_type = $_SESSION['wpsc_display_type'];
945
+ unset($_SESSION['wpsc_display_type']);
946
  }
947
+
948
  ob_start();
949
  wpsc_include_products_page_template($display_type);
950
  $is_single = false;
1142
  add_filter( 'the_title', 'wpsc_the_category_title',10,2 );
1143
  add_filter( 'the_content', 'wpsc_place_shopping_cart', 12 );
1144
  add_filter( 'the_content', 'wpsc_transaction_results', 12 );
 
1145
  add_filter( 'the_content', 'wpsc_user_log', 12 );
 
1146
  add_filter( 'the_content', 'wpsc_show_categories', 12 );
1147
  return $excerpt;
1148
  }
1153
  remove_filter( 'the_content', 'wpsc_single_template' );
1154
  remove_filter( 'the_content', 'wpsc_place_shopping_cart' );
1155
  remove_filter( 'the_content', 'wpsc_transaction_results' );
 
1156
  remove_filter( 'the_content', 'wpsc_user_log' );
 
1157
  remove_filter( 'the_content', 'wpsc_show_categories' );
1158
  remove_filter( 'the_content', 'wpsc_substitute_buy_now_button' );
1159
  return $excerpt;
1344
  function get_posts( &$q ) {
1345
  $this->q =& $q;
1346
 
1347
+ if ( ( "wpsc_product_category" != $q->query_vars['taxonomy'] ) )
1348
  return false;
1349
 
1350
  add_action( 'posts_where', array( &$this, 'where' ) );
1353
 
1354
  function where( $where ) {
1355
  global $wpdb;
1356
+
1357
  remove_action( 'posts_where', array( &$this, 'where' ) );
1358
 
1359
  $term_id=$wpdb->get_var($wpdb->prepare('SELECT term_id FROM '.$wpdb->terms.' WHERE slug = %s ', $this->q->query_vars['term']));
1410
  }
1411
 
1412
  add_action('post_thumbnail_html','wpsc_the_featured_image_fix');
1413
+ ?>
wpsc-includes/theming.class.php CHANGED
@@ -158,7 +158,7 @@ class wpsc_theming {
158
  if ( in_array( $file, $this->templates_to_move ) ) {
159
  if ( !strstr( $file, "functions" ) && !strstr( $file, "widget" ) ) {
160
  $file_data = file_get_contents( $old . "/" . $file );
161
- file_put_contents( $path . "/" . $file, $file_data );
162
  rename( $path . "/" . $file, $path . "/" . $theme_file_prefix . $file );
163
  }
164
  }
158
  if ( in_array( $file, $this->templates_to_move ) ) {
159
  if ( !strstr( $file, "functions" ) && !strstr( $file, "widget" ) ) {
160
  $file_data = file_get_contents( $old . "/" . $file );
161
+ @file_put_contents( $path . "/" . $file, $file_data );
162
  rename( $path . "/" . $file, $path . "/" . $theme_file_prefix . $file );
163
  }
164
  }
wpsc-includes/variations.class.php CHANGED
@@ -145,7 +145,19 @@ class wpsc_variations {
145
 
146
 
147
  }
148
-
 
 
 
 
 
 
 
 
 
 
 
 
149
 
150
  /**
151
  * wpsc_get_child_objects_in_term function.
@@ -221,6 +233,7 @@ function wpsc_get_child_object_in_terms($parent_id, $terms, $taxonomies, $args =
221
  if (count($object_ids) > 0) {
222
  return $object_ids['object_id'];
223
  } else {
 
224
  return false;
225
  }
226
  }
145
 
146
 
147
  }
148
+ function wpsc_get_child_object_in_select_terms($parent_id, $terms, $taxonomy){
149
+ global $wpdb;
150
+ // echo '<pre>'.print_r($terms,1).'</pre>';
151
+
152
+ $sql = "SELECT tr.`object_id`
153
+ FROM `".$wpdb->term_relationships."` AS tr
154
+ LEFT JOIN `".$wpdb->posts."` AS posts
155
+ ON posts.`ID` = tr.`object_id`
156
+ WHERE tr.`term_taxonomy_id` IN (".implode(',',$terms).") and posts.`post_parent`=".$parent_id;
157
+ $products = $wpdb->get_col($sql);
158
+ return $products;
159
+
160
+ }
161
 
162
  /**
163
  * wpsc_get_child_objects_in_term function.
233
  if (count($object_ids) > 0) {
234
  return $object_ids['object_id'];
235
  } else {
236
+
237
  return false;
238
  }
239
  }
wpsc-includes/wpsc_query.php DELETED
@@ -1,1086 +0,0 @@
1
- <?php
2
- /**
3
- * WP eCommerce query class and product display functions
4
- *
5
- * This is the wpsc equivalent of the wp query class, needed for the wpsc templates to work
6
- * The Cart class handles adding, removing and adjusting items in the cart, and totaling up the cost of the items in the cart.
7
- * The Cart Items class handles the same, but for cart items themselves.
8
- *
9
- * This code contains modified methods from the wp_query object of WordPress, located in wp-includes/query.php, these parts are to do with the loops we use that mirror the functionality of the wordpress loop
10
- * As such, they can be used in the same way, if needed.
11
- *
12
- * @package wp-e-commerce
13
- * @since 3.7
14
- * @subpackage wpsc-cart-classes
15
- */
16
-
17
-
18
- /**
19
- * The WPSC Query class.
20
- *
21
- * @since 3.7
22
- */
23
- class WPSC_Query {
24
-
25
- var $query;
26
- var $query_vars = array();
27
- var $queried_object;
28
- var $queried_object_id;
29
- var $request;
30
-
31
- // This selected category, for the breadcrumbs
32
- var $category;
33
- var $category_id_list = array();
34
- var $category_product = array();
35
-
36
-
37
- // product loop variables.
38
- var $products;
39
- var $product_count = 0;
40
- var $total_product_count = 0;
41
- var $current_product = -1;
42
- var $in_the_loop = false;
43
- var $product;
44
-
45
- // variation groups: i.e. colour, size
46
- var $variation_groups;
47
- var $variation_group_count = 0;
48
- var $current_variation_group = -1;
49
- var $variation_group;
50
-
51
- // for getting the product price
52
- var $first_variations;
53
-
54
- //variations inside variation groups: i.e. (red, green, blue) or (S, M, L, XL)
55
- var $variations;
56
- var $variations_count = 0;
57
- var $current_variation = -1;
58
- var $variation;
59
-
60
-
61
- // Custom meta values
62
- var $custom_meta;
63
- var $custom_meta_count = 0;
64
- var $current_custom_meta = -1;
65
- var $custom_meta_values;
66
-
67
-
68
- // Breadcrumbs
69
- var $breadcrumbs;
70
- var $breadcrumb_count = 0;
71
- var $current_breadcrumb = -1;
72
- var $breadcrumb;
73
-
74
- // Pages
75
- var $pages;
76
- var $page_count = 0;
77
- var $current_page = -1;
78
- var $page;
79
-
80
- var $found_products = 0;
81
- var $max_num_pages = 0;
82
-
83
- var $is_single = false;
84
- var $is_search = false;
85
-
86
- /**
87
- * The WPSC query constructor, if no query is passed to it, it makes one from the WP_Query data
88
- *
89
- * @since 3.7
90
- *
91
- * @param string $query URL query string.
92
- * @return WPSC_Query
93
- */
94
- function WPSC_Query ($query = '') {
95
- if (empty($query)) {
96
- $query = $this->create_default_query();
97
- }
98
- $this->parse_query($query);
99
-
100
- $this->get_products();
101
- //echo("<pre>".print_r($this,true)."</pre>");
102
- }
103
-
104
-
105
- function create_default_query() {
106
- global $wp_query;
107
-
108
- // get the product_url_name or ID
109
- if(isset($wp_query->query_vars['product_url_name']) && ($wp_query->query_vars['product_url_name'] != '')) {
110
- $query['product_url_name'] = $wp_query->query_vars['product_url_name'];
111
- } else if(is_numeric($_GET['category'])) {
112
- $query['product_id'] = $_GET['product_id'];
113
- }
114
-
115
-
116
- // get the category ID
117
- if($wp_query->query_vars['category_id'] > 0) {
118
- $query['category_id'] = $wp_query->query_vars['category_id'];
119
- } else if(is_numeric($_GET['category'])) {
120
- $query['category_id'] = $_GET['category'];
121
- }
122
-
123
- // get the category ID
124
- if($wp_query->query_vars['category_id'] > 0) {
125
- $query['category_id'] = $wp_query->query_vars['category_id'];
126
- }
127
-
128
- // get the page number
129
- if($wp_query->query_vars['wpsc_page'] > 0) {
130
- $query['page'] = $wp_query->query_vars['wpsc_page'];
131
- } else if(is_numeric($_GET['page_number'])) {
132
- $query['page'] = $_GET['page_number'];
133
- }
134
-
135
- if(isset($_GET['order'])) {
136
- $query['sort_order'] = $_GET['order'];
137
- $_SESSION['wpsc_product_order'] = $_GET['order'];
138
- } else if(isset($_GET['product_order'])) {
139
- $query['sort_order'] = $_GET['product_order'];
140
- $_SESSION['wpsc_product_order'] = $_GET['order'];
141
- } else if(isset($_SESSION['wpsc_product_order'])) {
142
- $query['sort_order'] = $_SESSION['wpsc_product_order'];
143
- }
144
-
145
-
146
- if(isset($_GET['items_per_page'])) {
147
- $query['number_per_page'] = $_GET['items_per_page'];
148
- $_SESSION['wpsc_number_per_page'] = $_GET['items_per_page'];
149
- } else if(isset($_SESSION['wpsc_product_order'])) {
150
- $query['number_per_page'] = $_SESSION['wpsc_number_per_page'];
151
- }
152
-
153
- //$query['sort_order']
154
- //$query['number_per_page']
155
-
156
- return $query;
157
- }
158
-
159
- /**
160
- * Resets query flags to false.
161
- *
162
- * The query flags are what page info wp-eCommerce was able to figure out, same as the equivalent method on WordPress
163
- **/
164
- function init_query_flags() {
165
- $this->is_search = false;
166
- $this->is_feed = false;
167
- $this->is_404 = false;
168
- }
169
-
170
-
171
- /**
172
- * Initiates object properties and sets default values, same as the equivalent method on WordPress
173
- *
174
- * @since 3.7
175
- * @access public
176
- **/
177
- function init () {
178
- $this->category = null;
179
- unset($this->products);
180
- unset($this->query);
181
- $this->query_vars = array();
182
- unset($this->queried_object);
183
- unset($this->queried_object_id);
184
- $this->product_count = 0;
185
- $this->current_product = -1;
186
- $this->in_the_loop = false;
187
-
188
- $this->variation_groups = null;
189
- $this->variation_group = null;
190
-
191
- $this->variations = null;
192
- $this->variation = null;
193
-
194
- $this->custom_meta = null;
195
- $this->custom_meta_values = null;
196
-
197
- $this->breadcrumbs = null;
198
- $this->breadcrumb = null;
199
-
200
- $this->pages = null;
201
- $this->page = null;
202
-
203
- $this->init_query_flags();
204
- }
205
-
206
- /**
207
- * Fills in the query variables, which do not exist within the parameter.
208
- *
209
- * @since 3.7
210
- * @access public
211
- *
212
- * @param array $array Defined query variables.
213
- * @return array Complete query variables with undefined ones filled in empty.
214
- */
215
- function fill_query_vars($array) {
216
-
217
- /// remove the comments at the ends of lines in this array once all of these work, until then, only the ones with "// works" work
218
- $keys = array(
219
- 'product_id' // works
220
- , 'product_url_name' // works
221
- , 'product_name'
222
- , 'category_id' // works
223
- , 'category_url_name' // works
224
- , 'tag'
225
- , 'price'
226
- , 'limit_of_items'
227
- , 'sort_order'
228
- , 'number_per_page' // works
229
- , 'page'
230
- , 'custom_query'
231
- //, 'sku'
232
- );
233
-
234
- foreach ($keys as $key) {
235
- if ( !isset($array[$key]))
236
- $array[$key] = '';
237
- }
238
-
239
- return $array;
240
- }
241
-
242
- /**
243
- * Parse a query string and set query type booleans.
244
- *
245
- * @since 3.7
246
- * @access public
247
- *
248
- * @param string|array $query
249
- */
250
- function parse_query ($query) {
251
- if ( !empty($query) || !isset($this->query) ) {
252
- $this->init();
253
- if ( is_array($query) )
254
- $this->query_vars = $query;
255
- else
256
- parse_str($query, $this->query_vars);
257
- $this->query = $query;
258
- }
259
-
260
- $this->query_vars = $this->fill_query_vars($this->query_vars);
261
- $qv = &$this->query_vars;
262
-
263
-
264
- // we need a category ID
265
- if(!($qv['category_id'] > 0) && ($qv['category_url_name'] == '')) {
266
- $qv['category_id'] = get_option('wpsc_default_category');
267
- }
268
-
269
- // we need a number of items per page
270
- if(!($qv['number_per_page'] > 0) && ($qv['number_per_page'] != 'all')) {
271
- $qv['number_per_page'] = get_option('wpsc_products_per_page');
272
- }
273
-
274
-
275
-
276
-
277
-
278
-
279
- $qv['product_id'] = absint($qv['product_id']);
280
- $qv['product_url_name'] = trim($qv['product_url_name']);
281
- $qv['product_name'] = trim($qv['product_name']);
282
- $qv['category_id'] = absint($qv['category_id']);
283
- $qv['category_url_name'] = trim($qv['category_url_name']);
284
- $qv['tag'] = trim($qv['tag']);
285
- $qv['price'] = absint($qv['price']);
286
- $qv['limit_of_items'] = absint($qv['limit_of_items']);
287
- $qv['sort_order'] = trim($qv['sort_order']);
288
- $qv['number_per_page'] = absint($qv['number_per_page']);
289
- $qv['page'] = absint($qv['page']);
290
- $qv['custom_query'] = (bool)$qv['custom_query'];
291
-
292
-
293
- }
294
-
295
-
296
- function &get_products() {
297
- global $wpdb, $wp_query;
298
- do_action_ref_array('pre_get_products', array(&$this));
299
-
300
- if(($this->query_vars['category_url_name'] != '')) {
301
- $category_data = $wpdb->get_row("SELECT `id`, `image_height`, `image_width` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active`='1' AND `nice-name` = '{$this->query_vars['category_url_name']}' LIMIT 1", ARRAY_A);
302
- $this->query_vars['category_id'] = $category_data['id'];
303
- $this->category = $this->query_vars['category_id'];
304
- } else if($this->query_vars['category_id'] > 0) {
305
- $category_data = $wpdb->get_row("SELECT `image_height`, `image_width` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active`='1' AND `id` = '{$this->query_vars['category_id']}' LIMIT 1", ARRAY_A);
306
- }
307
- $this->category_id_list = array($this->query_vars['category_id']);
308
- if($this->query_vars['category_id'] > 0) {
309
- $this->category_id_list = array_merge((array)$this->category_id_list, (array)wpsc_list_subcategories($this->query_vars['category_id']));
310
- }
311
-
312
-
313
- //exit('Here:<pre>'.print_r($category_id_list, true).'</pre>');
314
- if(is_array($category_data)) {
315
- $this->category_product['image_height'] = $category_data['image_height'];
316
- $this->category_product['image_width'] = $category_data['image_width'];
317
- }
318
-
319
- if($this->query_vars['product_url_name'] != null) {
320
- $product_id = $wpdb->get_var("SELECT `product_id` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN ( 'url_name' ) AND `meta_value` IN ( '".stripslashes($this->query_vars['product_url_name'])."' ) ORDER BY `product_id` DESC LIMIT 1");
321
- } else {
322
- $product_id = absint($this->query_vars['product_id']);
323
- }
324
-
325
-
326
- if(($product_id > 0)) {
327
- $product_list = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='".(int)$product_id."' AND `active` IN('1') AND `publish` IN('1') LIMIT 1",ARRAY_A);
328
- }
329
-
330
- if(isset($_SESSION['price_range']) && isset($_GET['range'])){
331
- if (is_numeric($_GET['range']) || isset($_SESSION['price_range'])) {
332
- $price_ranges = $_SESSION['price_range'];
333
-
334
- $selected_price_point = absint($_GET['range']);
335
- $next_price_point = $selected_price_point + 1;
336
- //echo "<pre>".print_r($ranges,true)."</pre>";
337
- $product_range_sql_parts = array();
338
- $variation_sql_parts = array();
339
- $product_sql_parts = array();
340
-
341
- if(isset($price_ranges[$selected_price_point])) {
342
- $product_range_sql_parts[] = "(`price` - `special_price`) >= '".absint($price_ranges[$selected_price_point])."'";
343
- $variation_sql_parts[] = "`price` >= '".absint($price_ranges[$selected_price_point])."'";
344
-
345
- if(isset($price_ranges[$next_price_point])) {
346
- $product_range_sql_parts[] = "(`price` - `special_price`) < '".absint($price_ranges[$next_price_point])."'";
347
- $variation_sql_parts[] = "`price` < '".absint($price_ranges[$next_price_point])."'";
348
- }
349
- $variation_product_ids = (array)$wpdb->get_col("SELECT DISTINCT `product_id` FROM `".WPSC_TABLE_VARIATION_PROPERTIES."` WHERE ".implode(" AND ", $variation_sql_parts)."");
350
- if(count($variation_product_ids) > 0 ) {
351
- $product_sql_parts[] = "( (".implode(" AND ", $product_range_sql_parts).") OR `id` IN('".implode("', '", $variation_product_ids)."') )";
352
- } else {
353
- $product_sql_parts += $product_range_sql_parts;
354
- }
355
- }
356
-
357
- $product_sql_parts[] = "`active` IN ('1')";
358
- $product_sql_parts[] = "`publish` IN('1')";
359
-
360
-
361
- $range_sql="SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE ".implode(" AND ", $product_sql_parts)."";
362
- //echo $range_sql;
363
-
364
- $product_list = $wpdb->get_results($range_sql,ARRAY_A);
365
- }
366
- }
367
- //exit('Here:<pre>'.print_r($this->query_vars, true).'</pre>');
368
- if(count($product_list) > 0 && !isset($_GET['range'])) {
369
- // if is a single product
370
- $this->is_single = true;
371
- $this->products = $product_list;
372
-
373
- $this->category = $this->query_vars['category_id'];
374
-
375
- } elseif(count($product_list) > 0 && isset($_GET['range'])) {
376
-
377
- $this->is_single = false;
378
- $this->products = $product_list;
379
-
380
- $this->category = $this->query_vars['category_id'];
381
-
382
- }else{
383
- // Otherwise
384
-
385
-
386
- //if we are using pages, how many items per page and what page?
387
- if((get_option('use_pagination') == 1)) {
388
- $products_per_page = $this->query_vars['number_per_page'];
389
- if($this->query_vars['page'] > 0) {
390
- $startnum = ($this->query_vars['page']-1)*$products_per_page;
391
- } else {
392
- $startnum = 0;
393
- }
394
- } else {
395
- $startnum = 0;
396
- }
397
-
398
-
399
-
400
-
401
- // search section is done here
402
- if(function_exists('gold_shpcrt_search_sql') && ($_GET['product_search'] != '')) {
403
- $search_sql = gold_shpcrt_search_sql();
404
- if($search_sql != '') {
405
- // this cannot currently list products that are associated with no categories
406
- $rowcount = $wpdb->get_var("SELECT COUNT( DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.`id`) AS `count` FROM `".WPSC_TABLE_PRODUCT_LIST."`,`".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`publish`='1' AND `".WPSC_TABLE_PRODUCT_LIST."`.`active`='1' AND `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` AND `".WPSC_TABLE_PRODUCT_LIST."`.donation = '0' $search_sql");
407
- if (isset($_SESSION['item_per_page']))
408
- $products_per_page = $_SESSION['item_per_page'];
409
- //exit($products_per_page);
410
- if(!is_numeric($products_per_page) || ($products_per_page < 1)) { $products_per_page = $rowcount; }
411
-
412
- if($startnum >= $rowcount) {
413
- $startnum = 0;
414
- }
415
-
416
- $sql = "SELECT DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.* FROM `".WPSC_TABLE_PRODUCT_LIST."`,`".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`publish`='1' AND `".WPSC_TABLE_PRODUCT_LIST."`.`active`='1' AND `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` $no_donations_sql $search_sql ORDER BY `".WPSC_TABLE_PRODUCT_LIST."`.`special` DESC LIMIT $startnum, $products_per_page";
417
- }
418
- } else if (($wp_query->query_vars['ptag'] != null) || ( $_GET['ptag']!=null)) {
419
- // search by tags is done here
420
- if($wp_query->query_vars['ptag'] != null) {
421
- $tag = $wp_query->query_vars['ptag'];
422
- } else {
423
- $tag = $_GET['ptag'];
424
- }
425
-
426
-
427
- $results = $wpdb->get_results("SELECT * FROM `{$wpdb->terms}` WHERE slug='$tag'");
428
-
429
- $term_id = $results[0]->term_id;
430
-
431
- $results = $wpdb->get_results("SELECT * FROM `{$wpdb->term_taxonomy}` WHERE term_id = '".$term_id."' AND taxonomy='product_tag'");
432
-
433
- $taxonomy_id = $results[0]->term_taxonomy_id;
434
-
435
- $results = $wpdb->get_results("SELECT * FROM `{$wpdb->term_relationships}` WHERE term_taxonomy_id = '".$taxonomy_id."'");
436
-
437
- foreach ($results as $result) {
438
- $product_ids[] = $result->object_id;
439
- }
440
- $product_id = implode(",",$product_ids);
441
-
442
- $sql = "SELECT * FROM ".WPSC_TABLE_PRODUCT_LIST." WHERE id IN (".$product_id.") AND `publish` IN('1') AND `active` IN('1')"; //Transom - added publish & active
443
- } else {
444
- // select by category is done here
445
-
446
-
447
-
448
-
449
- if(is_numeric($this->query_vars['category_id']) && ($this->query_vars['category_id'] > 0)) {
450
-
451
- /*
452
- * The reason this is so complicated is because of the product ordering, it is done by category/product association
453
- * If you can see a way of simplifying it and speeding it up, then go for it.
454
- */
455
-
456
-
457
- $rowcount = $wpdb->get_var("SELECT COUNT( DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.`id`) AS `count` FROM `".WPSC_TABLE_PRODUCT_LIST."` LEFT JOIN `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` ON `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`publish`='1' AND `".WPSC_TABLE_PRODUCT_LIST."`.`active` = '1' AND `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` IN ('".implode("','", $this->category_id_list)."') $no_donations_sql");
458
-
459
- if(!is_numeric($products_per_page) || ($products_per_page < 1)) { $products_per_page = $rowcount; }
460
- if($startnum >= $rowcount) {
461
- $startnum = 0;
462
- }
463
-
464
- if($this->query_vars['sort_order']=='DESC') {
465
- $order = 'DESC';
466
- } else {
467
- $order = 'ASC';
468
- }
469
-
470
-
471
- // Invert this for alphabetical ordering.
472
- if (get_option('wpsc_sort_by')=='name') {
473
- if( $order == 'ASC'){
474
- $order = 'DESC';
475
- }else{
476
- $order = 'ASC';
477
- }
478
- $order_by = "`products`.`name` $order";
479
- } else if (get_option('wpsc_sort_by') == 'price') {
480
- $order_by = "`products`.`price` $order";
481
- } elseif(get_option('wpsc_sort_by') == 'dragndrop'){
482
- $order_by = "`".WPSC_TABLE_PRODUCT_ORDER."`.`order` ASC";
483
- } else {
484
-
485
- //$order = 'ASC';
486
- if( $order == 'ASC'){
487
- $product_id_order = 'DESC';
488
- }else{
489
- $product_id_order = 'ASC';
490
- }
491
- $order_by = " `category`.`name`, `order_state` DESC,`order`.`order` $order, `products`.`id` $product_id_order";
492
- //$order_by = " `order_state` DESC, `products`.`id` $product_id_order,`order`.`order` $order";
493
- }
494
-
495
- $sql = "SELECT DISTINCT `products`. * , `category`.`name` AS `category` , `cat_assoc`.`category_id` , `order`.`order` , IF( ISNULL( `order`.`order` ) , 0, 1 ) AS `order_state`
496
- FROM `".WPSC_TABLE_PRODUCT_LIST."` AS `products`
497
- LEFT JOIN `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` AS `cat_assoc`
498
- ON `products`.`id` = `cat_assoc`.`product_id`
499
- LEFT JOIN `".WPSC_TABLE_PRODUCT_CATEGORIES."` AS `category`
500
- ON `cat_assoc`.`category_id` = `category`.`id`
501
- LEFT JOIN `".WPSC_TABLE_PRODUCT_ORDER."` AS `order`
502
- ON (
503
- (`products`.`id` = `order`.`product_id`)
504
- AND
505
- (`cat_assoc`.`category_id` = `order`.`category_id`)
506
- )
507
- WHERE `products`.`publish` = '1'
508
- AND `products`.`active` = '1'
509
- AND `cat_assoc`.`category_id` IN ( '".implode("','", $this->category_id_list)."' ) $no_donations_sql
510
- ORDER BY $order_by LIMIT $startnum, $products_per_page";
511
-
512
- } else {
513
- if ($this->query_vars['sort_order']=='DESC') {
514
- $order = 'DESC';
515
- } else {
516
- $order = 'ASC';
517
- }
518
-
519
- if (get_option('wpsc_sort_by')=='name') {
520
- $order_by = "`".WPSC_TABLE_PRODUCT_LIST."`.`name` $order";
521
- } else if (get_option('wpsc_sort_by') == 'price') {
522
- $order_by = "`".WPSC_TABLE_PRODUCT_LIST."`.`price` $order";
523
- } else {
524
- if( $order == 'ASC'){
525
- $order = 'DESC';
526
- }else{
527
- $order = 'ASC';
528
- }
529
- $order_by = "`".WPSC_TABLE_PRODUCT_LIST."`.`id` $order";
530
- }
531
- $rowcount = $wpdb->get_var("SELECT COUNT( DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.`id`) AS `count` FROM `".WPSC_TABLE_PRODUCT_LIST."`,`".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`publish`='1' AND `".WPSC_TABLE_PRODUCT_LIST."`.`active`='1' AND `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` $no_donations_sql $group_sql");
532
-
533
- if(!is_numeric($products_per_page) || ($products_per_page < 1)) { $products_per_page = $rowcount; }
534
- if($startnum >= $rowcount) {
535
- $startnum = 0;
536
- }
537
-
538
- $sql = "SELECT DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.* FROM `".WPSC_TABLE_PRODUCT_LIST."`,`".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`publish`='1' AND `".WPSC_TABLE_PRODUCT_LIST."`.`active`='1' AND `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` $no_donations_sql $group_sql ORDER BY `".WPSC_TABLE_PRODUCT_LIST."`.`special`, $order_by LIMIT $startnum, $products_per_page";
539
- }
540
- }
541
-
542
-
543
-
544
- //echo "{$sql}";
545
- $this->category = $this->query_vars['category_id'];
546
- $this->products = $wpdb->get_results($sql,ARRAY_A);
547
-
548
- $this->total_product_count = $rowcount;
549
-
550
- if($rowcount > $products_per_page) {
551
- if($products_per_page > 0) {
552
- $pages = ceil($rowcount/$products_per_page);
553
- } else {
554
- $pages = 1;
555
- }
556
- }
557
- }
558
-
559
-
560
- if(get_option('permalink_structure') != '') {
561
- $separator ="?";
562
- } else {
563
- $separator ="&amp;";
564
- }
565
- $product_view_url = wpsc_category_url($this->category);
566
-
567
- if(!is_numeric($_GET['category']) && ($_GET['product_search'] != '')) {
568
- $product_view_url = add_query_arg('product_search', $_GET['product_search'], $product_view_url);
569
- //$product_view_url_not_used .= "product_search=".$_GET['product_search']."&amp;"."view_type=".$_GET['view_type']."&amp;"."item_per_page=".$_GET['item_per_page']."&amp;";
570
- }
571
-
572
- if(!is_numeric($_GET['category']) && ($_GET['item_per_page'] > 0)) {
573
- $product_view_url = add_query_arg('item_per_page', $_GET['item_per_page'], $product_view_url);
574
- }
575
-
576
- if(isset($_GET['order']) && ($_GET['order'] == 'ASC') || ($_GET['order'] == 'DESC') ) {
577
- $product_view_url = add_query_arg('order', $_GET['order'], $product_view_url);
578
- }
579
-
580
- if(isset($_GET['view_type']) && ($_GET['view_type'] == 'default') || ($_GET['view_type'] == 'grid') ) {
581
- $product_view_url = add_query_arg('view_type', $_GET['view_type'], $product_view_url);
582
- }
583
-
584
-
585
-
586
- for($i=1;$i<=$pages;$i++) {
587
- if(($this->query_vars['page'] == $i) || (($this->query_vars['page'] <= $i) && ($i <= 1))) {
588
- if($_GET['view_all'] != 'true') {
589
- $selected = true;
590
- }
591
- } else {
592
- $selected = false;
593
- }
594
-
595
- if(get_option('permalink_structure')) {
596
- //if()
597
- $page_url = wpsc_category_url($this->category, true)."page/$i/";
598
- } else {
599
- $page_url = add_query_arg('page_number', $i, $product_view_url);
600
- }
601
- $this->pages[$i-1]['number'] = $i;
602
- $this->pages[$i-1]['url'] = $page_url;
603
- $this->pages[$i-1]['selected'] = $selected;
604
- }
605
-
606
- $this->page_count = count($this->pages);
607
-
608
- //if ( !$q['suppress_filters'] )
609
- $this->products = apply_filters('the_products', $this->products);
610
-
611
- $this->product_count = count($this->products);
612
- if ($this->product_count > 0) {
613
- $this->product = $this->products[0];
614
- }
615
-
616
- // get the breadcrumbs
617
- $this->get_breadcrumbs();
618
-
619
- return $this->products;
620
- }
621
-
622
- function next_product() {
623
- $this->current_product++;
624
- unset($this->product); // make sure it is unset
625
- $this->product =& $this->products[$this->current_product];
626
- return $this->product;
627
- }
628
-
629
-
630
- function the_product() {
631
- $this->in_the_loop = true;
632
- $this->next_product();
633
- $this->get_variation_groups();
634
- $this->get_custom_meta();
635
- if ( $this->current_product == 0 ) {
636
- do_action('wpsc_loop_start');
637
- }
638
- }
639
-
640
- function have_products() {
641
- if ($this->current_product + 1 < $this->product_count) {
642
- return true;
643
- } else if ($this->current_product + 1 == $this->product_count && $this->product_count > 0) {
644
- do_action('wpsc_loop_end');
645
- $this->rewind_products();
646
- }
647
-
648
- $this->in_the_loop = false;
649
- return false;
650
- }
651
-
652
- function rewind_products() {
653
- $this->current_product = -1;
654
- if ($this->product_count > 0) {
655
- $this->product = $this->products[0];
656
- }
657
- }
658
-
659
-
660
- /*
661
- * (Variation Group and Variation) Loop Code Starts here
662
- */
663
- function get_variation_groups() {
664
- global $wpdb;
665
- $this->variation_groups = $wpdb->get_results("SELECT `v`.`id` AS `variation_id`,`v`.`name` FROM `".WPSC_TABLE_VARIATION_ASSOC."` AS `a` JOIN `".WPSC_TABLE_PRODUCT_VARIATIONS."` AS `v` ON `a`.`variation_id` = `v`.`id` WHERE `a`.`type` IN ('product') AND `a`.`associated_id` IN ('{$this->product['id']}')", ARRAY_A);
666
- $this->variation_group_count = count($this->variation_groups);
667
- $this->get_first_variations();
668
- }
669
-
670
-
671
- function next_variation_group() {
672
- $this->current_variation_group++;
673
- $this->variation_group = $this->variation_groups[$this->current_variation_group];
674
- return $this->variation_group;
675
- }
676
-
677
-
678
- function the_variation_group() {
679
- $this->variation_group = $this->next_variation_group();
680
- $this->get_variations();
681
- }
682
-
683
- function have_variation_groups() {
684
- if ($this->current_variation_group + 1 < $this->variation_group_count) {
685
- return true;
686
- } else if ($this->current_variation_group + 1 == $this->variation_group_count && $this->variation_group_count > 0) {
687
- $this->rewind_variation_groups();
688
- }
689
- return false;
690
- }
691
-
692
- function rewind_variation_groups() {
693
- $this->current_variation_group = -1;
694
- if ($this->variation_group_count > 0) {
695
- $this->variation_group = $this->variation_groups[0];
696
- }
697
- }
698
-
699
- function get_first_variations() {
700
- global $wpdb;
701
- $this->first_variations = array();
702
- $this->all_associated_variations = array();
703
- foreach((array)$this->variation_groups as $variation_group) {
704
- $variation_id = $variation_group['variation_id'];
705
- $this->all_associated_variations[$variation_id] = $wpdb->get_results("SELECT `v`.* FROM `".WPSC_TABLE_VARIATION_VALUES_ASSOC."` AS `a`JOIN `".WPSC_TABLE_VARIATION_VALUES."` AS `v` ON `a`.`value_id` = `v`.`id` WHERE `a`.`product_id` IN ('{$this->product['id']}') AND `a`.`variation_id` IN ('$variation_id') AND `a`.`visible` IN ('1') ORDER BY `v`.`id` ASC", ARRAY_A);
706
- $this->first_variations[] = $this->all_associated_variations[$variation_id][0]['id'];
707
- }
708
- }
709
-
710
-
711
- function get_variations() {
712
- global $wpdb;
713
- //$this->variations = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id` = '$value_id' ORDER BY `id` ASC",ARRAY_A);
714
- $this->variations = $this->all_associated_variations[$this->variation_group['variation_id']];
715
- $this->variation_count = count($this->variations);
716
- //echo "<pre>".print_r($this->all_associated_variations,true)."</pre>";
717
- }
718
-
719
-
720
- function next_variation() {
721
- $this->current_variation++;
722
- $this->variation = $this->variations[$this->current_variation];
723
- return $this->variation;
724
- }
725
-
726
-
727
- function the_variation() {
728
- $this->variation = $this->next_variation();
729
- }
730
-
731
- function have_variations() {
732
- if ($this->current_variation + 1 < $this->variation_count) {
733
- return true;
734
- } else if ($this->current_variation + 1 == $this->variation_count && $this->variation_count > 0) {
735
- //do_action('wpsc_loop_end');
736
- // Do some cleaning up after the loop,
737
- $this->rewind_variations();
738
- }
739
-
740
- //$this->in_the_loop = false;
741
- return false;
742
- }
743
-
744
- function rewind_variations() {
745
- $this->current_variation = -1;
746
- if ($this->variation_count > 0) {
747
- $this->variation = $this->variations[0];
748
- }
749
- }
750
-
751
-
752
-
753
-
754
- /*
755
- * Custom Meta Loop Code Starts here
756
- */
757
- function get_custom_meta() {
758
- global $wpdb;
759
- //$this->variations = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id` = '$value_id' ORDER BY `id` ASC",ARRAY_A);
760
- $this->custom_meta = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `product_id` IN('{$this->product['id']}') AND `custom` IN('1') ", ARRAY_A);
761
- $this->custom_meta_count = count($this->custom_meta);
762
- }
763
-
764
- function next_custom_meta() {
765
- $this->current_custom_meta++;
766
- $this->custom_meta_values = $this->custom_meta[$this->current_custom_meta];
767
-
768
- // echo "<pre>".print_r($this->custom_meta_values,true)."</pre>";
769
- return $this->custom_meta_values;
770
- }
771
-
772
-
773
- function the_custom_meta() {
774
- $this->custom_meta_values = $this->next_custom_meta();
775
- }
776
-
777
- function have_custom_meta() {
778
- if ($this->current_custom_meta + 1 < $this->custom_meta_count) {
779
- return true;
780
- } else if ($this->current_custom_meta + 1 == $this->custom_meta_count && $this->custom_meta_count > 0) {
781
- //do_action('wpsc_loop_end');
782
- // Do some cleaning up after the loop,
783
- $this->rewind_custom_meta();
784
- }
785
-
786
- //$this->in_the_loop = false;
787
- return false;
788
- }
789
-
790
- function rewind_custom_meta() {
791
- $this->current_custom_meta = -1;
792
- if ($this->custom_meta_count > 0) {
793
- $this->custom_meta_values = $this->custom_meta[0];
794
- }
795
- }
796
-
797
-
798
- /*
799
- * Breadcrumb Loop Code Starts here
800
- */
801
-
802
- function get_breadcrumbs() {
803
- global $wpdb;
804
- $this->breadcrumbs = array();
805
- $i = 0;
806
- if( $this->category != null) {
807
- if($this->is_single == true) {
808
- $this->breadcrumbs[$i]['name'] = htmlentities(stripslashes($this->product['name']), ENT_QUOTES, 'UTF-8');
809
- $this->breadcrumbs[$i]['url'] = '';
810
- $i++;
811
- }
812
-
813
- $category_info = $wpdb->get_row("SELECT * FROM ".WPSC_TABLE_PRODUCT_CATEGORIES." WHERE id='".(int)$this->category."'",ARRAY_A);
814
- $this->breadcrumbs[$i]['id'] = $category_info['id'];
815
- $this->breadcrumbs[$i]['name'] = $category_info['name'];
816
- if($i > 0) {
817
- $this->breadcrumbs[$i]['url'] = wpsc_category_url($category_info['id']);
818
- } else {
819
- $this->breadcrumbs[$i]['url'] = '';
820
- }
821
- $i++;
822
-
823
- while ($category_info['category_parent']!=0) {
824
- $category_info = $wpdb->get_row("SELECT * FROM ".WPSC_TABLE_PRODUCT_CATEGORIES." WHERE id='{$category_info['category_parent']}'",ARRAY_A);
825
- $this->breadcrumbs[$i]['id'] = $category_info['id'];
826
- $this->breadcrumbs[$i]['name'] = htmlentities(stripslashes($category_info['name']), ENT_QUOTES, 'UTF-8');
827
- $this->breadcrumbs[$i]['url'] = wpsc_category_url($category_info['id']);
828
- $i++;
829
- }
830
- }
831
- $this->breadcrumbs = array_reverse($this->breadcrumbs);
832
- $this->breadcrumb_count = count($this->breadcrumbs);
833
- }
834
-
835
- function next_breadcrumbs() {
836
- $this->current_breadcrumb++;
837
- $this->breadcrumb = $this->breadcrumbs[$this->current_breadcrumb];
838
-
839
- // echo "<pre>".print_r($this->breadcrumb,true)."</pre>";
840
- return $this->breadcrumb;
841
- }
842
-
843
-
844
- function the_breadcrumb() {
845
- $this->breadcrumb = $this->next_breadcrumbs();
846
- }
847
-
848
- function have_breadcrumbs() {
849
- if ($this->current_breadcrumb + 1 < $this->breadcrumb_count) {
850
- return true;
851
- } else if ($this->current_breadcrumb + 1 == $this->breadcrumb_count && $this->breadcrumb_count > 0) {
852
- //do_action('wpsc_loop_end');
853
- // Do some cleaning up after the loop,
854
- $this->rewind_breadcrumbs();
855
- }
856
-
857
- //$this->in_the_loop = false;
858
- return false;
859
- }
860
-
861
- function rewind_breadcrumbs() {
862
- $this->current_breadcrumb = -1;
863
- if ($this->breadcrumb_count > 0) {
864
- $this->breadcrumb = $this->breadcrumbs[0];
865
- }
866
- }
867
-
868
-
869
- /*
870
- * Page Loop Code Starts here
871
- */
872
-
873
-
874
- /// We get the pages in get_products
875
- //function get_pages() { };
876
-
877
- function next_pages() {
878
- $this->current_page++;
879
- $this->page = $this->pages[$this->current_page];
880
-
881
- // echo "<pre>".print_r($this->page,true)."</pre>";
882
- return $this->page;
883
- }
884
-
885
-
886
- function the_page() {
887
- $this->page = $this->next_pages();
888
- }
889
-
890
- function have_pages() {
891
- if ($this->current_page + 1 < $this->page_count) {
892
- return true;
893
- } else if ($this->current_page + 1 == $this->page_count && $this->page_count > 0) {
894
- //do_action('wpsc_loop_end');
895
- // Do some cleaning up after the loop,
896
- $this->rewind_pages();
897
- }
898
-
899
- //$this->in_the_loop = false;
900
- return false;
901
- }
902
-
903
- function rewind_pages() {
904
- $this->current_page = -1;
905
- if ($this->page_count > 0) {
906
- $this->page = $this->pages[0];
907
- }
908
- }
909
-
910
-
911
- function the_product_title() {
912
- return $this->product['name'];
913
- }
914
-
915
-
916
- function the_product_thumbnail() {
917
-
918
- global $wpdb;
919
- $image_file_name = null;
920
-
921
- if ( $this->product['thumbnail_image'] != null ) {
922
- $image_file_name = $this->product['thumbnail_image'];
923
- } else if ( $this->product['image'] != null ) {
924
- if ( $this->product['image_file'] != null ) {
925
- $image_file_name = $this->product['image_file'];
926
- } else {
927
- if ( is_numeric($this->product['image']) ) {
928
- $image_file_name = $wpdb->get_var("SELECT `image` FROM `" . WPSC_TABLE_PRODUCT_IMAGES . "` WHERE `id`= '" . $this->product['image'] . "' LIMIT 1");
929
- } else {
930
- $image_file_name = $this->product['image'];
931
- }
932
- $this->product['image_file'] = $image_file_name;
933
- }
934
- $this->product['thumbnail_image'] = $image_file_name;
935
- }
936
-
937
- if ( $image_file_name !== null ) {
938
- if ( ($this->category_product['image_height'] != null) && ($this->category_product['image_width'] != null) && (function_exists('ImagePNG')) ) {
939
- $image_path = "index.php?productid=" . $this->product['id'] . "&amp;width=" . $this->category_product['image_width']."&amp;height=" . $this->category_product['image_height'] . "";
940
- } else {
941
- $image_path = WPSC_THUMBNAIL_URL . $image_file_name;
942
- if ( is_ssl() ) {
943
- $image_path = str_replace("http://", "https://", $image_path);
944
- }
945
- }
946
- return $image_path;
947
- } else {
948
- return false;
949
- }
950
-
951
- }
952
- /**
953
- * NEW CODE SUPPLIED BY btray77 FOR AWESOME PAGINATION
954
- */
955
- ///////////////////////////////////////////////////////////////////////////////////////
956
-
957
- function is_pagination_on() {
958
- if (get_option( 'use_pagination' ) == 1){
959
- return true;
960
- }else {
961
- return false;
962
- }
963
- }
964
-
965
- function prodcuts_per_page()
966
- {
967
- return get_option( 'wpsc_products_per_page' );
968
- }
969
-
970
- function a_page_url($page=null) {
971
- //exit('<pre>'.print_r($this, true).'</pre>');
972
- $curpage = $this->query_vars['page'];
973
- if($page != ''){
974
- $this->query_vars['page'] = $page;
975
- }
976
- //global $wpsc_query;
977
-
978
- if($this->is_single === true) {
979
- $this->query_vars['page'] = $curpage;
980
- return wpsc_product_url($this->product['id']);
981
- } else {
982
- $output = wpsc_category_url($this->category);
983
- //exit('PAge <pre>'.print_r($this,true).'</pre>');
984
-
985
- if($this->query_vars['page'] > 1) {
986
- //
987
- if(get_option('permalink_structure')) {
988
- $output .= "page/{$this->query_vars['page']}/";
989
- } else {
990
- $output = add_query_arg('page_number', '', $output);
991
- }
992
- }
993
- // $this->query_vars['page'] = $urpage;
994
- // exit('Whats returned: '.$output);
995
- return $output;
996
- }
997
- }
998
- function pagination($totalpages, $per_page, $current_page, $page_link) {
999
- if ($current_page ==''){
1000
- if(isset($_GET['page_number']) && is_numeric($_GET['page_number'])){
1001
- $current_page = $_GET['page_number'];
1002
- }else{
1003
- $current_page=1;
1004
- }
1005
-
1006
- }
1007
- //exit($pagelink.'<<<<<');
1008
- if(!get_option('permalink_structure')) {
1009
- $category = '';
1010
- if(isset($_GET['category']) && is_numeric($_GET['category'])){
1011
- $category = '&category='.$_GET['category'];
1012
- }
1013
- $page_link = get_option('product_list_url').$category.'&page_number';
1014
- $separator = '=';
1015
- }else{
1016
- $page_link = get_option('product_list_url');
1017
- $separator = 'page/';
1018
- }
1019
- //exit($totalpages.'<br />'.$per_page.'<br />'.$current_page.'<br />'.$page_link);
1020
-
1021
- // If there's only one page, return now and don't bother
1022
- if($totalpages == 1) return;
1023
- // Pagination Prefix
1024
- $output = "Pages: ";
1025
- // Should we show the FIRST PAGE link?
1026
- if($current_page > 1) {
1027
- $output .= "<a href=\"". $page_link ."\" title=\"First Page\"> << First </a>";
1028
- }
1029
- // Should we show the PREVIOUS PAGE link?
1030
- if($current_page > 1 && ($current_page-1) != 1) {
1031
- $previous_page = $current_page - 1;
1032
- $output .= " <a href=\"". $page_link .$separator. $previous_page ."\" title=\"Previous Page\"> < Previous </a>";
1033
- }
1034
- $i =$current_page - 5;
1035
- $count = 0;
1036
- if($i > 0){
1037
- // exit($i.' '.$current_page);
1038
- while(($i) < $current_page){
1039
- if($i > 0){
1040
- $output .= " <a href=\"". $page_link .$separator. $i ."\" title=\"Page ".$i." \"> ".$i." </a>";
1041
- $i++;
1042
- }
1043
- }
1044
- }else{
1045
-
1046
- }
1047
- if($current_page > 0) {
1048
- // Current Page Number
1049
- $output .= "<strong>[ ". $current_page ." ]</strong>";
1050
- // Should we show the NEXT PAGE link?
1051
- }
1052
- $i = $current_page+1;
1053
- $count = 0;
1054
- if($current_page + 5 <= $totalpages){
1055
- while(($i) < $totalpages){
1056
- if($count <=4 ){
1057
- $output .= " <a href=\"". $page_link .$separator. $i ."\" title=\"Page ".$i." \"> ".$i." </a>";
1058
- $i++;
1059
- }else{
1060
- break;
1061
- }
1062
- $count ++;
1063
-
1064
- }
1065
-
1066
-
1067
- }
1068
-
1069
- if($current_page < $totalpages) {
1070
- $next_page = $current_page + 1;
1071
- $output .= "<a href=\"". $page_link .$separator. $next_page ."\" title=\"Next Page\"> Next > </a>";
1072
- }
1073
- // Should we show the LAST PAGE link?
1074
- if($current_page < $totalpages - 1) {
1075
- $output .= " <a href=\"". $page_link .$separator. $totalpages ."\" title=\"Last Page\"> Last >> </a>";
1076
- }
1077
- // Return the output.
1078
- return $output;
1079
- }
1080
-
1081
- ///////////////////////////////////////////////////////////////////////////////////////
1082
- /* END OF btray77 code for pagination */
1083
-
1084
- }
1085
-
1086
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-languages/EN_en.php CHANGED
@@ -52,7 +52,7 @@ define('TXT_WPSC_INSUFFICIENT_REMAINING', 'Sorry, but there are only [number] of
52
  define('TXT_WPSC_ZERO_QUANTITY_REQUESTED', 'Sorry, but you cannot add zero items to your cart');
53
  define('TXT_WPSC_PRODUCT_DISPLAY_SETTINGS', 'Product Settings');
54
  define('TXT_WPSC_BUTTON_SETTINGS', 'Button Settings');
55
- define('TXT_WPSC_UPDATING', 'Loading');
56
  define('TXT_WPSC_EDIT_GROUP', 'Edit Group');
57
  define('TXT_WPSC_ADD_GROUP', 'Add Group');
58
  define('TXT_SHOW_GRID_PER_ROW', 'Products Per Row');
@@ -61,7 +61,6 @@ define('TXT_WPSC_CATEGORISATION', 'Categories');
61
  define('TXT_WPSC_COUPONSINVALID', 'Coupon is not valid.');
62
  define('TXT_WPSC_NOITEMSINTHISGROUP', 'There are no products in this group.');
63
 
64
- define('TXT_WPSC_CLEAR_IP_LOCKS', 'Release downloads locked to this IP address %s');
65
  define('TXT_WPSC_EMAIL_BUYER', 'Resend Receipt to Buyer');
66
 
67
 
@@ -77,7 +76,6 @@ define('TXT_WPSC_PERSONALIZE_YOUR_PRODUCT', 'Personalize your product');
77
  define('TXT_WPSC_PERSONALIZE_YOUR_PRODUCT_DESCRIPTION', 'Complete this form to include a personalized message with your purchase.');
78
 
79
  define("TXT_WPSC_ADDITIONAL_INFO", "3. Additional Information");
80
- define('TXT_WPSC_ECOMMERCE', 'Products');
81
  define('TXT_WPSC_FLOT_ANNUAL_SALES_GRAPH','ANNUAL SALES GRAPH');
82
 
83
  define('TXT_WPSC_NO_SHIPPING_QUOTES','Sorry, online ordering is unavailable to this destination and/or weight. Please double check your destination details.');
@@ -102,7 +100,6 @@ define("TXT_WPSC_HOW_DID_YOU_FIND_US_INT", "Internet");
102
  define("TXT_WPSC_HOW_DID_YOU_FIND_US_EC", "Existing Customer");
103
 
104
 
105
- define("TXT_WPSC_ABOUT_THIS_PAGE", "About This Page");
106
  define("TXT_WPSC_LOADING", "Loading");
107
 
108
  define("TXT_WPSC_COMMA_SEPARATED", "Seperate with commas");
@@ -111,11 +108,9 @@ define("TXT_WPSC_AT_THIS_MOMENT_TRACE_ID", "Tracking ID");
111
 
112
  define("TXT_WPSC_AT_THIS_MOMENT_NO_TRANSACTION", "No transactions for this month.");
113
  define("TXT_WPSC_MAIL_RESENDED", "The folowing purchase receipt has has been resent");
114
- define("TXT_WPSC_ERROR_OCCURED_WHILE_SENDING_EMAIL", "An Error Occured While Sending Email");
115
 
116
  define("TXT_WPSC_UPDATE_BUTTON", "Update &raquo;");
117
 
118
- define("TXT_WPSC_ABOUT_THIS_PAGE", "About This Page");
119
 
120
  define("TXT_WPSC_PAGENUMBER_POSITION_TOP", "Top");
121
  define("TXT_WPSC_PAGENUMBER_POSITION_BOTTOM", "Bottom");
@@ -209,7 +204,6 @@ define('TXT_WPSC_CATEGORY_AND_TAG_CONTROL', 'Categories and Tags');
209
  define('TXT_WPSC_BASE_ZIPCODE', 'Base Zipcode/Postcode:');
210
  define('TXT_WPSC_USPS_DESC', 'If you are based in America then you need to set your own Zipcode for UPS and USPS to work. This should be the Zipcode for your Base of Operations.');
211
 
212
- define('TXT_WPSC_SHIPPING_DETAILS', 'Shipping Details');
213
  define('TXT_WPSC_SHIPPING_METHOD', 'Shipping Method');
214
  define('TXT_WPSC_SHIPPING_OPTION', 'Shipping Option');
215
  define('TXT_WPSC_CHOOSE_EXTERNAL_SHIPPING_MODULES', 'External Shipping Calculators');
@@ -247,8 +241,6 @@ define('TXT_WPSC_DEFAULT_PURCHASE_REPORT', '
247
 
248
  %total_price%');
249
 
250
- define('TXT_WPSC_CHOOSE_DOWNLOADABLE_VARIATIONS', 'Choose a downloadable file for this variation');
251
-
252
 
253
  define('TXT_WPSC_CHOOSE_DOWNLOADABLE_VARIATIONS', 'Choose a downloadable file for this variation');
254
  define('TXT_WPSC_FLASH_UPLOADER', 'You are using the Flash uploader. Problems? Try the <a class=\'wpsc_upload_switcher\' onclick=\'wpsc_upload_switcher("browser")\'>Browser uploader</a> instead.');
@@ -267,7 +259,6 @@ define('TXT_WPSC_DOWNLOADS_LEFT', 'Downloads Left');
267
 
268
 
269
  define('TXT_WPSC_FILE', 'Files');
270
- define('TXT_WPSC_PDF', 'PDF');
271
 
272
  define('TXT_WPSC_LABEL', 'Label');
273
  define('TXT_WPSC_TABLE_RATED_PRICE', 'Table Rate Price');
@@ -357,7 +348,6 @@ define('TXT_WPSC_YOUAREUSING', 'You are using the :theme: style. This is WP e-Co
357
  define('TXT_WPSC_NO_SHORTCODE', 'This item product is still waiting to be added to your catalogue. There are no shortcodes or tags available at this point.');
358
  define('TXT_WPSC_SKU', 'SKU');
359
  define('TXT_WPSC_YOUR_ORDER', 'Your Order');
360
- define('TXT_WPSC_ABOUT_THIS_PAGE', 'About This Page');
361
  define('TXT_WPSC_ORDER_PENDING_PAYMENT_REQUIRED', 'Order Pending: Payment Required');
362
  define('TXT_WPSC_SELECTALLCATEGORIES', 'Show All Products');
363
 
@@ -372,9 +362,8 @@ define('TXT_WPSC_WE_RECOMMEND', 'We Recommend');
372
  define('TXT_WPSC_SELECT_PRODUCT_GROUP', 'Select a Group to Manage');
373
  define('TXT_WPSC_EDIT_THIS_GROUP', 'Edit This Group');
374
 
375
- define('TXT_WPSC_USPS_USERID', 'USPS ID');
376
  define('TXT_WPSC_PRODUCT_ID', 'Product ID');
377
- define('TXT_WPSC_USPS_PASSWORD', 'USPS Password');
378
  define('TXT_WPSC_OPTIONS_GENERAL_TAB', 'General');
379
  define('TXT_WPSC_OPTIONS_PRESENTATION_TAB', 'Presentation');
380
  define('TXT_WPSC_OPTIONS_SHIPPING_TAB', 'Shipping');
@@ -408,9 +397,6 @@ define('TXT_WPSC_UPLOAD_IMAGE_FOR', 'Upload Image for');
408
  define('TXT_WPSC_THUMBNAILSETTINGS', 'Thumbnail Settings');
409
 
410
 
411
- define('TXT_WPSC_THANKS_UNLOCKED', 'Thanks, the downloads that were locked to this users IP number have been freed.');
412
-
413
-
414
  define('TXT_WPSC_SELECTGATEWAY', 'Select a payment gateway');
415
  define('TXT_WPSC_VARIATION_LIST', 'Select a Variation');
416
 
@@ -464,7 +450,7 @@ define('TXT_WPSC_SAVE', 'Save');
464
 
465
  define('TXT_WPSC_DISPLAY_PRODUCT_CATEGORIES', 'Display &quot;[categorisation]&quot;'); // The shortcode [categorisation] is replaced with the name of the currently select categorisation
466
 
467
- define('TXT_WPSC_PRODUCT_CATEGORIES', 'Select &quot;[categorisation]&quot;'); // The shortcode [categorisation] is replaced with the name of the currently select categorisation
468
 
469
  define('TXT_WPSC_MANAGE_CATEGORISATION', 'Manage &quot;[categorisation]&quot;'); // The shortcode [categorisation] is replaced with the name of the currently select categorisation
470
 
@@ -516,7 +502,7 @@ define('TXT_WPSC_SHOWLIVESEARCH', 'Use Live Search');
516
  define('TXT_WPSC_USPS_USERID', 'USPS ID');
517
  define('TXT_WPSC_USPS_PASSWORD', 'USPS Password');
518
 
519
- define('TXT_WPSC_SHIPPING_DETAILS', 'Shipping Details');
520
  define('TXT_WPSC_SHOWADVANCEDSEARCH', 'Show Advanced Search');
521
  define('TXT_WPSC_GOOGLEMECHANTKEY', 'Google Merchant Key');
522
  define('TXT_WPSC_GOOGLEMECHANTID', "Google Merchant ID");
@@ -534,7 +520,6 @@ define('TXT_WPSC_OPTIONS', 'Settings');
534
  define('TXT_WPSC_ADDPRODUCTS', 'Add Products');
535
  define('TXT_WPSC_SENDSMS', 'Send SMS');
536
  define('TXT_WPSC_PRODUCTS', 'Products');
537
- define('TXT_WPSC_ADDCATEGORY', 'Add Product Group');
538
  define('TXT_WPSC_CATEGORIES', 'Categories');
539
  define('TXT_WPSC_BRANDS', 'Brands');
540
  define('TXT_WPSC_VARIATIONS', 'Variations');
@@ -542,9 +527,7 @@ define('TXT_WPSC_PURCHASELOG', 'Sales');
542
  define('TXT_WPSC_ORDER_LOG', 'Orders');
543
  define('TXT_WPSC_OLDER_ORDERS', 'Older Orders');
544
  define('TXT_WPSC_ORDER', 'Order');
545
- define('TXT_WPSC_TOTAL_THIS_MONTH', 'Total Money Earnt this Month');
546
  define('TXT_WPSC_MONTHLY_REPORT', 'Six Monthly Report');
547
- define('TXT_WPSC_TOTAL_INCOME', 'Total Income');
548
  define('TXT_WPSC_ACCEPTED_PAYMENTS', '(accepted payments)'); //text has changed slightly
549
  define('TXT_WPSC_PAYMENTGATEWAYOPTIONS', 'Payment Options');
550
  define('TXT_WPSC_HELPINSTALLATION', 'Help/Upgrade');
@@ -555,12 +538,8 @@ define('TXT_WPSC_PRODUCTIMAGEWIDTH', 'product image width');
555
  define('TXT_WPSC_PRODUCTIMAGEHEIGHT', 'product image height');
556
  define('TXT_WPSC_CATEGORYIMAGEWIDTH', 'product group image width');
557
  define('TXT_WPSC_CATEGORYIMAGEHEIGHT', 'product group image height');
558
- define('TXT_WPSC_PRODUCTLISTURL', 'The location of the product list');
559
- define('TXT_WPSC_SHOPPINGCARTURL', 'The location of the shopping cart');
560
- define('TXT_WPSC_CHECKOUTURL', 'The location of the checkout page');
561
  define('TXT_WPSC_TRANSACTURL', 'The location of the transaction detail page');
562
  define('TXT_WPSC_PAYMENTGATEWAY', 'The payment gateway to use');
563
- define('TXT_WPSC_CARTLOCATION', 'Cart Location');
564
  define('TXT_WPSC_SHOWCATEGORYBRANDS', 'Display categories or brands or both');
565
  define('TXT_WPSC_CURRENCYTYPE', 'Currency type');
566
  define('TXT_WPSC_CURRENCYSIGNLOCATION', 'Currency sign location');
@@ -571,7 +550,6 @@ define('TXT_WPSC_DISPLAYSPECIALS', 'Display or hide specials on the sidebar');
571
  define('TXT_WPSC_POSTAGEAND_PACKAGING', 'Default postage and packaging');
572
  define('TXT_WPSC_PURCHLOGEMAIL', 'Email address that purchase log is sent to');
573
  define('TXT_WPSC_RETURNEMAIL', 'Email address that purchase reports are sent from');
574
- define('TXT_WPSC_TERMSANDCONDITIONS', 'Checkout terms and conditions');
575
  define('TXT_WPSC_DEFAULTBRAND', 'Default Brand');
576
 
577
 
@@ -583,13 +561,10 @@ define('TXT_WPSC_PAYPALBUSINESS', 'paypal business');
583
  define('TXT_WPSC_PAYPALURL', 'paypal url');
584
  define('TXT_WPSC_SHOWPRODUCTRATINGS', 'Show Product Ratings');
585
  define('TXT_WPSC_PRODUCTSPAGE', 'Products Page');
586
- define('TXT_WPSC_CHECKOUT', 'Verify your Order');
587
  define('TXT_WPSC_ENTERDETAILS', 'Enter Your Details');
588
  define('TXT_WPSC_TRANSACTIONRESULTS', 'Transaction Results');
589
  define('TXT_WPSC_SELECTACATEGORY', 'Select a Product Group');
590
  define('TXT_WPSC_SELECTABRAND', 'Select a Brand');
591
- define('TXT_WPSC_PRODUCTNAME', 'Product Name');
592
- define('TXT_WPSC_PRODUCTDESCRIPTION', 'Product Description');
593
  define('TXT_WPSC_ADDITIONALDESCRIPTION', 'Additional Description');
594
  define('TXT_WPSC_PRICE', 'Price');
595
  define('TXT_WPSC_TAXALREADYINCLUDED', 'Do not include tax (tax is set in <a href="'. get_option('siteurl').'/wp-admin/admin.php?page=wpsc-settings">shop config</a>)'); // this text has changed and needs updating
@@ -646,12 +621,14 @@ define('TXT_WPSC_CATEGORY_PARENT', 'Group Parent');
646
  define('TXT_WPSC_IMAGE', 'Image');
647
  define('TXT_WPSC_HEIGHT', 'Height');
648
  define('TXT_WPSC_WIDTH', 'Width');
 
649
  define('TXT_WPSC_PLEASEENTERAVALID', 'Please enter a valid');
650
  define('TXT_WPSC_PLEASEENTERAVALIDNAME', 'Please enter a valid name');
651
  define('TXT_WPSC_PLEASEENTERAVALIDSURNAME', 'Please enter a valid surname');
652
  define('TXT_WPSC_PLEASEENTERAVALIDEMAILADDRESS', 'Please enter a valid email address');
653
  define('TXT_WPSC_PLEASEENTERAVALIDADDRESS', 'Please enter a valid address');
654
  define('TXT_WPSC_PLEASEENTERAVALIDPHONENUMBER', 'Please enter a valid phone number');
 
655
  define('TXT_WPSC_TERMSANDCONDITIONS', 'You have not agreed to the terms and conditions');
656
  define('TXT_WPSC_NOTHINGINYOURSHOPPINGCART', 'There is nothing in your shopping cart');
657
 
@@ -799,11 +776,8 @@ define('TXT_WPSC_SHOWPOSTAGEANDPACKAGING', 'Show Postage and Packaging');
799
  define('TXT_WPSC_YES', 'Yes');
800
  define('TXT_WPSC_NO', 'No');
801
  define('TXT_WPSC_SHOWSPECIALS', 'Show Specials in the Sidebar');
802
- define('TXT_WPSC_SHOWPRODUCTRATINGS', 'Show Product Ratings');
803
  define('TXT_WPSC_CURRENCYSETTINGS', 'Currency Settings');
804
  define('TXT_WPSC_GSTTAXRATE', 'GST/Tax Rate');
805
- define('TXT_WPSC_CURRENCYTYPE', 'Currency Type');
806
- define('TXT_WPSC_CURRENCYSIGNLOCATION', 'Currency Sign Location');
807
  define('TXT_WPSC_DEFAULTPOSTAGEPACKAGING', 'Default Postage &amp; Packaging');
808
  define('TXT_WPSC_ADMINISTRATIONSETTINGS', 'Administration Settings');
809
  define('TXT_WPSC_MAXDOWNLOADSPERFILE', 'Max downloads per file');
@@ -1029,9 +1003,9 @@ define('TXT_WPSC_DRAG_ITEM_HERE', 'Drag any item here to add it to your cart.');
1029
  define('TXT_WPSC_SHOWCATEGORYTHUMBNAILS', 'Show Product Group Thumbnails');
1030
  define('TXT_WPSC_SHOPPING_CART', 'Shopping Cart');
1031
  define('TXT_WPSC_SHOW_SLIDING_CART', 'Use Sliding Cart');
1032
- define('TXT_WPSC_PREVIEW_FILE', 'Upload Preview');
1033
  define('TXT_WPSC_PREVIEW_FILE_NOTE', 'Note: If you do not upload a preview file and your server has sox compiled with MP3 support then a preview file will be created for you.');
1034
- define('TXT_WPSC_PURCHASE_NUMBER', 'Purchase No.');
1035
  define('TXT_WPSC_FILTER_ORDER', 'Filter Orders');
1036
  define('TXT_WPSC_SHOW_SEARCH', 'Show Search');
1037
  define('TXT_WPSC_LOG_CURRENT_MONTH', 'Display results from current month');
@@ -1129,7 +1103,7 @@ define('TXT_WPSC_OPTION_ALSO_BOUGHT', 'Display Cross Sales');
1129
  define('TXT_WPSC_MARKETING', 'Marketing');
1130
  define('TXT_WPSC_DISPLAYCOUPONS', 'Coupons');
1131
  define('TXT_WPSC_ADD_COUPON', 'Add Coupon');
1132
- define('TXT_WPSC_COUPON', 'Coupon');
1133
  define('TXT_WPSC_ADDCOUPONS', 'Add Coupon');
1134
  define('TXT_WPSC_COUPON_CODE', 'Coupon Code');
1135
  define('TXT_WPSC_DISCOUNT', 'Discount');
@@ -1164,7 +1138,7 @@ define('TXT_WPSC_DROPSHOP_DARK', 'Use dark Dropshop style');
1164
 
1165
 
1166
  define('TXT_WPSC_MANUAL_PAYMENT', 'Manual Payment');
1167
- define('TXT_WPSC_CREDIT_CARD', 'Credit Card');
1168
  define('TXT_WPSC_CREDIT_CARD_AND_MANUAL_PAYMENT', 'Manual Payment and Credit Card');
1169
  define('TXT_WPSC_PAYMENT_INSTRUCTIONS', 'Enter the manual payment instructions that you wish to display');
1170
 
52
  define('TXT_WPSC_ZERO_QUANTITY_REQUESTED', 'Sorry, but you cannot add zero items to your cart');
53
  define('TXT_WPSC_PRODUCT_DISPLAY_SETTINGS', 'Product Settings');
54
  define('TXT_WPSC_BUTTON_SETTINGS', 'Button Settings');
55
+
56
  define('TXT_WPSC_EDIT_GROUP', 'Edit Group');
57
  define('TXT_WPSC_ADD_GROUP', 'Add Group');
58
  define('TXT_SHOW_GRID_PER_ROW', 'Products Per Row');
61
  define('TXT_WPSC_COUPONSINVALID', 'Coupon is not valid.');
62
  define('TXT_WPSC_NOITEMSINTHISGROUP', 'There are no products in this group.');
63
 
 
64
  define('TXT_WPSC_EMAIL_BUYER', 'Resend Receipt to Buyer');
65
 
66
 
76
  define('TXT_WPSC_PERSONALIZE_YOUR_PRODUCT_DESCRIPTION', 'Complete this form to include a personalized message with your purchase.');
77
 
78
  define("TXT_WPSC_ADDITIONAL_INFO", "3. Additional Information");
 
79
  define('TXT_WPSC_FLOT_ANNUAL_SALES_GRAPH','ANNUAL SALES GRAPH');
80
 
81
  define('TXT_WPSC_NO_SHIPPING_QUOTES','Sorry, online ordering is unavailable to this destination and/or weight. Please double check your destination details.');
100
  define("TXT_WPSC_HOW_DID_YOU_FIND_US_EC", "Existing Customer");
101
 
102
 
 
103
  define("TXT_WPSC_LOADING", "Loading");
104
 
105
  define("TXT_WPSC_COMMA_SEPARATED", "Seperate with commas");
108
 
109
  define("TXT_WPSC_AT_THIS_MOMENT_NO_TRANSACTION", "No transactions for this month.");
110
  define("TXT_WPSC_MAIL_RESENDED", "The folowing purchase receipt has has been resent");
 
111
 
112
  define("TXT_WPSC_UPDATE_BUTTON", "Update &raquo;");
113
 
 
114
 
115
  define("TXT_WPSC_PAGENUMBER_POSITION_TOP", "Top");
116
  define("TXT_WPSC_PAGENUMBER_POSITION_BOTTOM", "Bottom");
204
  define('TXT_WPSC_BASE_ZIPCODE', 'Base Zipcode/Postcode:');
205
  define('TXT_WPSC_USPS_DESC', 'If you are based in America then you need to set your own Zipcode for UPS and USPS to work. This should be the Zipcode for your Base of Operations.');
206
 
 
207
  define('TXT_WPSC_SHIPPING_METHOD', 'Shipping Method');
208
  define('TXT_WPSC_SHIPPING_OPTION', 'Shipping Option');
209
  define('TXT_WPSC_CHOOSE_EXTERNAL_SHIPPING_MODULES', 'External Shipping Calculators');
241
 
242
  %total_price%');
243
 
 
 
244
 
245
  define('TXT_WPSC_CHOOSE_DOWNLOADABLE_VARIATIONS', 'Choose a downloadable file for this variation');
246
  define('TXT_WPSC_FLASH_UPLOADER', 'You are using the Flash uploader. Problems? Try the <a class=\'wpsc_upload_switcher\' onclick=\'wpsc_upload_switcher("browser")\'>Browser uploader</a> instead.');
259
 
260
 
261
  define('TXT_WPSC_FILE', 'Files');
 
262
 
263
  define('TXT_WPSC_LABEL', 'Label');
264
  define('TXT_WPSC_TABLE_RATED_PRICE', 'Table Rate Price');
348
  define('TXT_WPSC_NO_SHORTCODE', 'This item product is still waiting to be added to your catalogue. There are no shortcodes or tags available at this point.');
349
  define('TXT_WPSC_SKU', 'SKU');
350
  define('TXT_WPSC_YOUR_ORDER', 'Your Order');
 
351
  define('TXT_WPSC_ORDER_PENDING_PAYMENT_REQUIRED', 'Order Pending: Payment Required');
352
  define('TXT_WPSC_SELECTALLCATEGORIES', 'Show All Products');
353
 
362
  define('TXT_WPSC_SELECT_PRODUCT_GROUP', 'Select a Group to Manage');
363
  define('TXT_WPSC_EDIT_THIS_GROUP', 'Edit This Group');
364
 
365
+
366
  define('TXT_WPSC_PRODUCT_ID', 'Product ID');
 
367
  define('TXT_WPSC_OPTIONS_GENERAL_TAB', 'General');
368
  define('TXT_WPSC_OPTIONS_PRESENTATION_TAB', 'Presentation');
369
  define('TXT_WPSC_OPTIONS_SHIPPING_TAB', 'Shipping');
397
  define('TXT_WPSC_THUMBNAILSETTINGS', 'Thumbnail Settings');
398
 
399
 
 
 
 
400
  define('TXT_WPSC_SELECTGATEWAY', 'Select a payment gateway');
401
  define('TXT_WPSC_VARIATION_LIST', 'Select a Variation');
402
 
450
 
451
  define('TXT_WPSC_DISPLAY_PRODUCT_CATEGORIES', 'Display &quot;[categorisation]&quot;'); // The shortcode [categorisation] is replaced with the name of the currently select categorisation
452
 
453
+ //define('TXT_WPSC_PRODUCT_CATEGORIES', 'Select &quot;[categorisation]&quot;'); // The shortcode [categorisation] is replaced with the name of the currently select categorisation
454
 
455
  define('TXT_WPSC_MANAGE_CATEGORISATION', 'Manage &quot;[categorisation]&quot;'); // The shortcode [categorisation] is replaced with the name of the currently select categorisation
456
 
502
  define('TXT_WPSC_USPS_USERID', 'USPS ID');
503
  define('TXT_WPSC_USPS_PASSWORD', 'USPS Password');
504
 
505
+ //define('TXT_WPSC_SHIPPING_DETAILS', 'Shipping Details');
506
  define('TXT_WPSC_SHOWADVANCEDSEARCH', 'Show Advanced Search');
507
  define('TXT_WPSC_GOOGLEMECHANTKEY', 'Google Merchant Key');
508
  define('TXT_WPSC_GOOGLEMECHANTID', "Google Merchant ID");
520
  define('TXT_WPSC_ADDPRODUCTS', 'Add Products');
521
  define('TXT_WPSC_SENDSMS', 'Send SMS');
522
  define('TXT_WPSC_PRODUCTS', 'Products');
 
523
  define('TXT_WPSC_CATEGORIES', 'Categories');
524
  define('TXT_WPSC_BRANDS', 'Brands');
525
  define('TXT_WPSC_VARIATIONS', 'Variations');
527
  define('TXT_WPSC_ORDER_LOG', 'Orders');
528
  define('TXT_WPSC_OLDER_ORDERS', 'Older Orders');
529
  define('TXT_WPSC_ORDER', 'Order');
 
530
  define('TXT_WPSC_MONTHLY_REPORT', 'Six Monthly Report');
 
531
  define('TXT_WPSC_ACCEPTED_PAYMENTS', '(accepted payments)'); //text has changed slightly
532
  define('TXT_WPSC_PAYMENTGATEWAYOPTIONS', 'Payment Options');
533
  define('TXT_WPSC_HELPINSTALLATION', 'Help/Upgrade');
538
  define('TXT_WPSC_PRODUCTIMAGEHEIGHT', 'product image height');
539
  define('TXT_WPSC_CATEGORYIMAGEWIDTH', 'product group image width');
540
  define('TXT_WPSC_CATEGORYIMAGEHEIGHT', 'product group image height');
 
 
 
541
  define('TXT_WPSC_TRANSACTURL', 'The location of the transaction detail page');
542
  define('TXT_WPSC_PAYMENTGATEWAY', 'The payment gateway to use');
 
543
  define('TXT_WPSC_SHOWCATEGORYBRANDS', 'Display categories or brands or both');
544
  define('TXT_WPSC_CURRENCYTYPE', 'Currency type');
545
  define('TXT_WPSC_CURRENCYSIGNLOCATION', 'Currency sign location');
550
  define('TXT_WPSC_POSTAGEAND_PACKAGING', 'Default postage and packaging');
551
  define('TXT_WPSC_PURCHLOGEMAIL', 'Email address that purchase log is sent to');
552
  define('TXT_WPSC_RETURNEMAIL', 'Email address that purchase reports are sent from');
 
553
  define('TXT_WPSC_DEFAULTBRAND', 'Default Brand');
554
 
555
 
561
  define('TXT_WPSC_PAYPALURL', 'paypal url');
562
  define('TXT_WPSC_SHOWPRODUCTRATINGS', 'Show Product Ratings');
563
  define('TXT_WPSC_PRODUCTSPAGE', 'Products Page');
 
564
  define('TXT_WPSC_ENTERDETAILS', 'Enter Your Details');
565
  define('TXT_WPSC_TRANSACTIONRESULTS', 'Transaction Results');
566
  define('TXT_WPSC_SELECTACATEGORY', 'Select a Product Group');
567
  define('TXT_WPSC_SELECTABRAND', 'Select a Brand');
 
 
568
  define('TXT_WPSC_ADDITIONALDESCRIPTION', 'Additional Description');
569
  define('TXT_WPSC_PRICE', 'Price');
570
  define('TXT_WPSC_TAXALREADYINCLUDED', 'Do not include tax (tax is set in <a href="'. get_option('siteurl').'/wp-admin/admin.php?page=wpsc-settings">shop config</a>)'); // this text has changed and needs updating
621
  define('TXT_WPSC_IMAGE', 'Image');
622
  define('TXT_WPSC_HEIGHT', 'Height');
623
  define('TXT_WPSC_WIDTH', 'Width');
624
+ /*
625
  define('TXT_WPSC_PLEASEENTERAVALID', 'Please enter a valid');
626
  define('TXT_WPSC_PLEASEENTERAVALIDNAME', 'Please enter a valid name');
627
  define('TXT_WPSC_PLEASEENTERAVALIDSURNAME', 'Please enter a valid surname');
628
  define('TXT_WPSC_PLEASEENTERAVALIDEMAILADDRESS', 'Please enter a valid email address');
629
  define('TXT_WPSC_PLEASEENTERAVALIDADDRESS', 'Please enter a valid address');
630
  define('TXT_WPSC_PLEASEENTERAVALIDPHONENUMBER', 'Please enter a valid phone number');
631
+ */
632
  define('TXT_WPSC_TERMSANDCONDITIONS', 'You have not agreed to the terms and conditions');
633
  define('TXT_WPSC_NOTHINGINYOURSHOPPINGCART', 'There is nothing in your shopping cart');
634
 
776
  define('TXT_WPSC_YES', 'Yes');
777
  define('TXT_WPSC_NO', 'No');
778
  define('TXT_WPSC_SHOWSPECIALS', 'Show Specials in the Sidebar');
 
779
  define('TXT_WPSC_CURRENCYSETTINGS', 'Currency Settings');
780
  define('TXT_WPSC_GSTTAXRATE', 'GST/Tax Rate');
 
 
781
  define('TXT_WPSC_DEFAULTPOSTAGEPACKAGING', 'Default Postage &amp; Packaging');
782
  define('TXT_WPSC_ADMINISTRATIONSETTINGS', 'Administration Settings');
783
  define('TXT_WPSC_MAXDOWNLOADSPERFILE', 'Max downloads per file');
1003
  define('TXT_WPSC_SHOWCATEGORYTHUMBNAILS', 'Show Product Group Thumbnails');
1004
  define('TXT_WPSC_SHOPPING_CART', 'Shopping Cart');
1005
  define('TXT_WPSC_SHOW_SLIDING_CART', 'Use Sliding Cart');
1006
+ //define('TXT_WPSC_PREVIEW_FILE', 'Upload Preview');
1007
  define('TXT_WPSC_PREVIEW_FILE_NOTE', 'Note: If you do not upload a preview file and your server has sox compiled with MP3 support then a preview file will be created for you.');
1008
+ define('TXT_WPSC_PURCHASE_NUMBER', 'Purchase #');
1009
  define('TXT_WPSC_FILTER_ORDER', 'Filter Orders');
1010
  define('TXT_WPSC_SHOW_SEARCH', 'Show Search');
1011
  define('TXT_WPSC_LOG_CURRENT_MONTH', 'Display results from current month');
1103
  define('TXT_WPSC_MARKETING', 'Marketing');
1104
  define('TXT_WPSC_DISPLAYCOUPONS', 'Coupons');
1105
  define('TXT_WPSC_ADD_COUPON', 'Add Coupon');
1106
+ //define('TXT_WPSC_COUPON', 'Coupon');
1107
  define('TXT_WPSC_ADDCOUPONS', 'Add Coupon');
1108
  define('TXT_WPSC_COUPON_CODE', 'Coupon Code');
1109
  define('TXT_WPSC_DISCOUNT', 'Discount');
1138
 
1139
 
1140
  define('TXT_WPSC_MANUAL_PAYMENT', 'Manual Payment');
1141
+ //define('TXT_WPSC_CREDIT_CARD', 'Credit Card');
1142
  define('TXT_WPSC_CREDIT_CARD_AND_MANUAL_PAYMENT', 'Manual Payment and Credit Card');
1143
  define('TXT_WPSC_PAYMENT_INSTRUCTIONS', 'Enter the manual payment instructions that you wish to display');
1144
 
wpsc-merchants/GoogleCheckout-XML.php CHANGED
@@ -506,7 +506,7 @@ function nzsc_googleResponse() {
506
  $item_desc = $cart_item['item-description']['VALUE'];
507
  $item_unit_price = $cart_item['unit-price']['VALUE'];
508
  $item_quantity = $cart_item['quantity']['VALUE'];
509
- $product_info = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE id='".$product_id."' LIMIT 1", ARRAY_A) ;
510
  $product_info = $product_info[0];
511
  //mail("hanzhimeng@gmail.com","",print_r($product_info,1));
512
  if($product_info['notax'] != 1) {
506
  $item_desc = $cart_item['item-description']['VALUE'];
507
  $item_unit_price = $cart_item['unit-price']['VALUE'];
508
  $item_quantity = $cart_item['quantity']['VALUE'];
509
+ $product_info = $wpdb->get_results("SELECT * FROM `" . $wpdb->posts . "` WHERE id='".$product_id."' LIMIT 1", ARRAY_A) ;
510
  $product_info = $product_info[0];
511
  //mail("hanzhimeng@gmail.com","",print_r($product_info,1));
512
  if($product_info['notax'] != 1) {
wpsc-merchants/chronopay.php CHANGED
@@ -83,7 +83,7 @@ function gateway_chronopay($separator, $sessionid)
83
 
84
  foreach($cart as $item)
85
  {
86
- $product_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='".$item['prodid']."' LIMIT 1",ARRAY_A);
87
  $product_data = $product_data[0];
88
  $variation_count = count($product_variations);
89
 
@@ -115,7 +115,7 @@ function gateway_chronopay($separator, $sessionid)
115
 
116
  $local_currency_productprice = $item['price'];
117
 
118
- $local_currency_shipping = nzshpcrt_determine_item_shipping($item['prodid'], 1, $_SESSION['delivery_country']);
119
 
120
 
121
  $chronopay_currency_productprice = $local_currency_productprice;
@@ -150,8 +150,7 @@ function gateway_chronopay($separator, $sessionid)
150
 
151
  $i++;
152
  }
153
-
154
- $base_shipping = nzshpcrt_determine_base_shipping(0, $_SESSION['delivery_country']);
155
  if(($base_shipping > 0) && ($all_donations == false) && ($all_no_shipping == false))
156
  {
157
  $data['handling_cart'] = number_format($base_shipping,$decimal_places,'.','');
83
 
84
  foreach($cart as $item)
85
  {
86
+ $product_data = $wpdb->get_results("SELECT * FROM `" . $wpdb->posts . "` WHERE `id`='".$item['prodid']."' LIMIT 1",ARRAY_A);
87
  $product_data = $product_data[0];
88
  $variation_count = count($product_variations);
89
 
115
 
116
  $local_currency_productprice = $item['price'];
117
 
118
+ $local_currency_shipping = $item['pnp'] * $item['quantity'];
119
 
120
 
121
  $chronopay_currency_productprice = $local_currency_productprice;
150
 
151
  $i++;
152
  }
153
+ $base_shipping = $purchase_log[0]['base_shipping'];
 
154
  if(($base_shipping > 0) && ($all_donations == false) && ($all_no_shipping == false))
155
  {
156
  $data['handling_cart'] = number_format($base_shipping,$decimal_places,'.','');
wpsc-merchants/paypal-standard.merchant.php CHANGED
@@ -55,6 +55,7 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
55
  * @access public
56
  */
57
  function construct_value_array() {
 
58
  //$collected_gateway_data
59
  $paypal_vars = array();
60
  // Store settings to be sent to paypal
@@ -62,7 +63,6 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
62
  'business' => get_option('paypal_multiple_business'),
63
  'return' => add_query_arg('sessionid', $this->cart_data['session_id'], $this->cart_data['transaction_results_url']),
64
  'cancel_return' => $this->cart_data['transaction_results_url'],
65
- 'notify_url' => add_query_arg('gateway', 'wpsc_merchant_paypal_standard', $this->cart_data['notification_url']),
66
  'rm' => '2',
67
  'currency_code' => $this->cart_data['store_currency'],
68
  'lc' => $this->cart_data['store_currency'],
@@ -72,6 +72,13 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
72
  'charset' => 'utf-8'
73
  );
74
 
 
 
 
 
 
 
 
75
  //used to send shipping
76
  if((int)(bool)get_option('paypal_ship') == 1) {
77
  $paypal_vars += array(
@@ -176,25 +183,49 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
176
  } else {
177
  // Stick the cart item values together here
178
  $i = 1;
179
- foreach($this->cart_items as $cart_row) {
180
- $paypal_vars += array(
181
- "item_name_$i" => $cart_row['name'],
182
- "amount_$i" => $this->format_price($cart_row['price']),
183
- "tax_$i" => $this->format_price($cart_row['tax']),
184
- "quantity_$i" => $cart_row['quantity'],
185
- "item_number_$i" => $cart_row['product_id'],
186
- "shipping_$i" => $this->format_price($cart_row['shipping']/$cart_row['quantity']), // additional shipping for the the (first item / total of the items)
187
- "shipping2_$i" => $this->format_price($cart_row['shipping']/$cart_row['quantity']), // additional shipping beyond the first item
188
- "handling_$i" => '',
189
- );
190
- ++$i;
191
- }
192
- }
193
-
194
- //set base shipping
195
  $paypal_vars += array(
196
  "handling_cart" => $this->cart_data['base_shipping']
197
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
  // Payment Type settings to be sent to paypal
200
  if($this->cart_data['is_subscription'] == true) {
@@ -209,7 +240,6 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
209
  );
210
  }
211
 
212
-
213
  $this->collected_gateway_data = $paypal_vars;
214
  }
215
 
@@ -225,7 +255,7 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
225
  }
226
  $gateway_values = implode('&', $name_value_pairs);
227
 
228
-
229
  if(defined('WPSC_ADD_DEBUG_PAGE') and (WPSC_ADD_DEBUG_PAGE == true) ) {
230
  echo "<a href='".get_option('paypal_multiple_url')."?".$gateway_values."'>Test the URL here</a>";
231
  //echo "<pre>".print_r($this->cart_items,true)."</pre>";
@@ -246,7 +276,7 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
246
  $paypal_url = get_option('paypal_multiple_url');
247
  $received_values = array();
248
  $received_values['cmd'] = '_notify-validate';
249
- $received_values += $_POST;
250
  $options = array(
251
  'timeout' => 5,
252
  'body' => $received_values,
@@ -254,7 +284,7 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
254
  );
255
 
256
  $response = wp_remote_post($paypal_url, $options);
257
- if(strpos($response['body'], 'VERIFIED') !== false) {
258
  $this->paypal_ipn_values = $received_values;
259
  $this->session_id = $received_values['invoice'];
260
  $this->set_purchase_processed_by_sessionid(3);
@@ -275,14 +305,14 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
275
  case 'cart':
276
  case 'express_checkout':
277
  if((float)$this->paypal_ipn_values['mc_gross'] == (float)$this->cart_data['total_price']) {
278
- $this->set_transaction_details($this->paypal_ipn_values['txn_id'], 2);
279
  transaction_results($this->cart_data['session_id'],false);
280
  }
281
  break;
282
 
283
  case 'subscr_signup':
284
  case 'subscr_payment':
285
- $this->set_transaction_details($this->paypal_ipn_values['subscr_id'], 2);
286
  foreach($this->cart_items as $cart_row) {
287
  if($cart_row['is_recurring'] == true) {
288
  do_action('wpsc_activate_subscription', $cart_row['cart_item_id'], $this->paypal_ipn_values['subscr_id']);
@@ -629,4 +659,4 @@ $output .= "
629
 
630
  return $output;
631
  }
632
- ?>
55
  * @access public
56
  */
57
  function construct_value_array() {
58
+ global $wpdb;
59
  //$collected_gateway_data
60
  $paypal_vars = array();
61
  // Store settings to be sent to paypal
63
  'business' => get_option('paypal_multiple_business'),
64
  'return' => add_query_arg('sessionid', $this->cart_data['session_id'], $this->cart_data['transaction_results_url']),
65
  'cancel_return' => $this->cart_data['transaction_results_url'],
 
66
  'rm' => '2',
67
  'currency_code' => $this->cart_data['store_currency'],
68
  'lc' => $this->cart_data['store_currency'],
72
  'charset' => 'utf-8'
73
  );
74
 
75
+ if(get_option('paypal_ipn') == 1){
76
+ $notify_url = add_query_arg('gateway', 'wpsc_merchant_paypal_standard', $this->cart_data['notification_url']);
77
+ $notify_url = apply_filters('wpsc_paypal_standard_notify_url', $notify_url);
78
+ $paypal_vars += array(
79
+ 'notify_url' => $notify_url
80
+ );
81
+ }
82
  //used to send shipping
83
  if((int)(bool)get_option('paypal_ship') == 1) {
84
  $paypal_vars += array(
183
  } else {
184
  // Stick the cart item values together here
185
  $i = 1;
186
+ if( !$this->cart_data['has_discounts']){
187
+ foreach($this->cart_items as $cart_row) {
188
+ $paypal_vars += array(
189
+ "item_name_$i" => $cart_row['name'],
190
+ "amount_$i" => $this->format_price($cart_row['price']),
191
+ "tax_$i" => $this->format_price($cart_row['tax']),
192
+ "quantity_$i" => $cart_row['quantity'],
193
+ "item_number_$i" => $cart_row['product_id'],
194
+ "shipping_$i" => $this->format_price($cart_row['shipping']/$cart_row['quantity']), // additional shipping for the the (first item / total of the items)
195
+ "shipping2_$i" => $this->format_price($cart_row['shipping']/$cart_row['quantity']), // additional shipping beyond the first item
196
+ "handling_$i" => '',
197
+ );
198
+ ++$i;
199
+ }
200
+ //set base shipping
 
201
  $paypal_vars += array(
202
  "handling_cart" => $this->cart_data['base_shipping']
203
  );
204
+
205
+ }else{
206
+ $decimal_places = 2;
207
+ $currency_code = $wpdb->get_var("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1");
208
+ $local_currency_code = $currency_code;
209
+ $paypal_currency_code = get_option('paypal_curcode');
210
+
211
+ if( empty($paypal_currency_code) )
212
+ $paypal_currency_code = 'US';
213
+
214
+ $curr=new CURRENCYCONVERTER();
215
+ if($paypal_currency_code != $local_currency_code)
216
+ $paypal_currency_productprice = $curr->convert( $this->cart_data['total_price'],$paypal_currency_code,$local_currency_code);
217
+ else
218
+ $paypal_currency_productprice = $this->cart_data['total_price'];
219
+
220
+ $paypal_vars['item_name_'.$i] = "Your Shopping Cart";
221
+ $paypal_vars['amount_'.$i] = number_format(sprintf("%01.2f",$paypal_currency_productprice),$decimal_places,'.','');
222
+ $paypal_vars['quantity_'.$i] = 1;
223
+ $paypal_vars['shipping_'.$i] = 0;
224
+ $paypal_vars['shipping2_'.$i] = 0;
225
+ $paypal_vars['handling_'.$i] = 0;
226
+ }
227
+ }
228
+
229
 
230
  // Payment Type settings to be sent to paypal
231
  if($this->cart_data['is_subscription'] == true) {
240
  );
241
  }
242
 
 
243
  $this->collected_gateway_data = $paypal_vars;
244
  }
245
 
255
  }
256
  $gateway_values = implode('&', $name_value_pairs);
257
 
258
+
259
  if(defined('WPSC_ADD_DEBUG_PAGE') and (WPSC_ADD_DEBUG_PAGE == true) ) {
260
  echo "<a href='".get_option('paypal_multiple_url')."?".$gateway_values."'>Test the URL here</a>";
261
  //echo "<pre>".print_r($this->cart_items,true)."</pre>";
276
  $paypal_url = get_option('paypal_multiple_url');
277
  $received_values = array();
278
  $received_values['cmd'] = '_notify-validate';
279
+ $received_values += $_POST;
280
  $options = array(
281
  'timeout' => 5,
282
  'body' => $received_values,
284
  );
285
 
286
  $response = wp_remote_post($paypal_url, $options);
287
+ if( 'VERIFIED' == $response['body'] ) {
288
  $this->paypal_ipn_values = $received_values;
289
  $this->session_id = $received_values['invoice'];
290
  $this->set_purchase_processed_by_sessionid(3);
305
  case 'cart':
306
  case 'express_checkout':
307
  if((float)$this->paypal_ipn_values['mc_gross'] == (float)$this->cart_data['total_price']) {
308
+ $this->set_transaction_details($this->paypal_ipn_values['txn_id'], 3);
309
  transaction_results($this->cart_data['session_id'],false);
310
  }
311
  break;
312
 
313
  case 'subscr_signup':
314
  case 'subscr_payment':
315
+ $this->set_transaction_details($this->paypal_ipn_values['subscr_id'], 3);
316
  foreach($this->cart_items as $cart_row) {
317
  if($cart_row['is_recurring'] == true) {
318
  do_action('wpsc_activate_subscription', $cart_row['cart_item_id'], $this->paypal_ipn_values['subscr_id']);
659
 
660
  return $output;
661
  }
662
+ ?>
wpsc-merchants/paypal_multiple.php DELETED
@@ -1,646 +0,0 @@
1
- <?php
2
- return;
3
- exit();
4
- /*
5
- $nzshpcrt_gateways[$num]['name'] = 'PayPal Payments Standard';
6
- $nzshpcrt_gateways[$num]['internalname'] = 'paypal_multiple';
7
- $nzshpcrt_gateways[$num]['function'] = 'gateway_paypal_multiple';
8
- $nzshpcrt_gateways[$num]['form'] = "form_paypal_multiple";
9
- $nzshpcrt_gateways[$num]['submit_function'] = "submit_paypal_multiple";
10
- $nzshpcrt_gateways[$num]['payment_type'] = "paypal";
11
- $nzshpcrt_gateways[$num]['supported_currencies']['currency_list'] = array('USD', 'CAD', 'AUD', 'EUR', 'GBP', 'JPY', 'NZD', 'CHF', 'HKD', 'SGD', 'SEK', 'HUF', 'DKK', 'PLN', 'NOK', 'CZK', 'MXN');
12
- $nzshpcrt_gateways[$num]['supported_currencies']['option_name'] = 'paypal_curcode';
13
-
14
-
15
- function gateway_paypal_multiple($separator, $sessionid) {
16
- global $wpdb, $wpsc_cart;
17
- $purchase_log = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`= ".$sessionid." LIMIT 1",ARRAY_A) ;
18
-
19
- if ($purchase_log['totalprice']==0) {
20
- header("Location: ".get_option('transact_url').$separator."sessionid=".$sessionid);
21
- exit();
22
- }
23
-
24
- $cart_sql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='".$purchase_log['id']."'";
25
- $cart = $wpdb->get_results($cart_sql,ARRAY_A) ;
26
- //written by allen
27
- //exit("<pre>".print_r($cart,true)."</pre>");
28
- $member_subtype = get_product_meta($cart[0]['prodid'],'is_permenant',true);
29
- $status = get_product_meta($cart[0]['prodid'],'is_membership',true);
30
- $is_member = $status;
31
- $is_perm = $member_subtype;
32
- //end of written by allen
33
- $transact_url = get_option('transact_url');
34
- // paypal connection variables
35
- $data['business'] = get_option('paypal_multiple_business');
36
- $data['return'] = urlencode($transact_url.$separator."sessionid=".$sessionid."&gateway=paypal");
37
- $data['cancel_return'] = urlencode($transact_url);
38
- $data['notify_url'] =urlencode(get_option('siteurl')."/?ipn_request=true");
39
- $data['rm'] = '2';
40
- //data['bn'] = 'Instinct-WP-e-commerce_ShoppingCart_EC';
41
-
42
- // look up the currency codes and local price
43
-
44
- $currency_code = $wpdb->get_results("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A);
45
- $local_currency_code = $currency_code[0]['code'];
46
- $paypal_currency_code = get_option('paypal_curcode');
47
-
48
- if($paypal_currency_code == '') {
49
- $paypal_currency_code = 'US';
50
- }
51
- //exit(get_option('currency_type'). " ".$paypal_currency_code);
52
-
53
- // Stupid paypal only accepts payments in one of 5 currencies. Convert from the currency of the users shopping cart to the curency which the user has specified in their paypal preferences.
54
- $curr=new CURRENCYCONVERTER();
55
-
56
- $data['currency_code'] = $paypal_currency_code;
57
- // $data['lc'] = 'US';
58
- $data['lc'] = $paypal_currency_code;
59
- $data['bn'] = 'wp-e-commerce';
60
-
61
- $data['no_shipping'] = (int)(bool)get_option('paypal_ship');
62
- if(get_option('address_override') == 1) {
63
- $data['address_override'] = '1';
64
- }
65
- $data['no_note'] = '1';
66
-
67
- switch($paypal_currency_code) {
68
- case "JPY":
69
- $decimal_places = 0;
70
- break;
71
-
72
- case "HUF":
73
- $decimal_places = 0;
74
-
75
- default:
76
- $decimal_places = 2;
77
- break;
78
- }
79
-
80
- $i = 1;
81
-
82
- $all_donations = true;
83
- $all_no_shipping = true;
84
-
85
-
86
- $total = $wpsc_cart->calculate_total_price();
87
-
88
- $discount = $wpsc_cart->coupons_amount;
89
- //exit($discount);
90
- if(($discount > 0)) {
91
- if($paypal_currency_code != $local_currency_code) {
92
- $paypal_currency_productprice = $curr->convert( $wpsc_cart->calculate_total_price(),$paypal_currency_code,$local_currency_code);
93
- $paypal_currency_shipping = $curr->convert($local_currency_shipping,$paypal_currency_code,$local_currency_code);
94
- $base_shipping = $curr->convert($wpsc_cart->calculate_total_shipping(),$paypal_currency_code, $local_currency_code);
95
- $tax_price = $curr->convert($item['tax_charged'],$paypal_currency_code, $local_currency_code);
96
- } else {
97
- $paypal_currency_productprice = $wpsc_cart->calculate_total_price();
98
- $paypal_currency_shipping = $local_currency_shipping;
99
- $base_shipping = $wpsc_cart->calculate_total_shipping();
100
- $tax_price = $item['tax_charged'];
101
- }
102
- $data['item_name_'.$i] = "Your Shopping Cart";
103
- $data['amount_'.$i] = number_format(sprintf("%01.2f",$paypal_currency_productprice),$decimal_places,'.','');
104
- $data['quantity_'.$i] = 1;
105
- // $data['item_number_'.$i] = 0;
106
- $data['shipping_'.$i] = 0;
107
- $data['shipping2_'.$i] = 0;
108
- $data['handling_'.$i] = 0;
109
- $i++;
110
- } else {
111
- foreach((array)$cart as $item) {
112
- $product_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='".$item['prodid']."' LIMIT 1",ARRAY_A);
113
- $product_data = $product_data[0];
114
- if ((float)$item['price'] == 0 ) {
115
- continue;
116
- }
117
- $variation_count = count($product_variations);
118
- $local_currency_productprice = $item['price'];
119
- $local_currency_shipping = $item['pnp'];
120
-
121
- if($paypal_currency_code != $local_currency_code) {
122
- $paypal_currency_productprice = $curr->convert($local_currency_productprice,$paypal_currency_code,$local_currency_code);
123
- $paypal_currency_shipping = $curr->convert($local_currency_shipping,$paypal_currency_code,$local_currency_code);
124
- // exit($paypal_currency_productprice . " " . $paypal_currency_shipping.' '.$local_currency_productprice . " " . $local_currency_code);
125
- $base_shipping = $curr->convert($purchase_log['base_shipping'],$paypal_currency_code, $local_currency_code);
126
- //exit($paypal_currency_productprice.' Local>'.$local_currency_productprice.' Base shp'.$base_shipping);
127
- $tax_price = $curr->convert($item['tax_charged'],$paypal_currency_code, $local_currency_code);
128
- } else {
129
- $paypal_currency_productprice = $local_currency_productprice;
130
- $paypal_currency_shipping = $local_currency_shipping;
131
- $base_shipping = $purchase_log['base_shipping'];
132
- $tax_price = $item['tax_charged'];
133
- }
134
- //exit("<pre>".print_r(, true).'</pre>');
135
- $data['item_name_'.$i] = urlencode(stripslashes($item['name']));
136
- $data['amount_'.$i] = number_format(sprintf("%01.2f", $paypal_currency_productprice),$decimal_places,'.','');
137
- $data['tax_'.$i] = number_format(sprintf("%01.2f",$tax_price),$decimal_places,'.','');
138
- $data['quantity_'.$i] = $item['quantity'];
139
- $data['item_number_'.$i] = $product_data['id'];
140
- if($item['donation'] !=1) {
141
- $all_donations = false;
142
- $data['shipping_'.$i] = number_format($paypal_currency_shipping,$decimal_places,'.','');
143
- $data['shipping2_'.$i] = number_format($paypal_currency_shipping,$decimal_places,'.','');
144
- } else {
145
- $data['shipping_'.$i] = number_format(0,$decimal_places,'.','');
146
- $data['shipping2_'.$i] = number_format(0,$decimal_places,'.','');
147
- }
148
-
149
- if($product_data['no_shipping'] != 1) {
150
- $all_no_shipping = false;
151
- }
152
-
153
- $data['handling_'.$i] = '';
154
- $i++;
155
- }
156
- }
157
- $data['tax'] = '';
158
-
159
- //exit($base_shipping);
160
- if(($base_shipping > 0) && ($all_donations == false) && ($all_no_shipping == false)) {
161
- $data['handling_cart'] = number_format($base_shipping,$decimal_places,'.','');
162
- }
163
-
164
- $data['custom'] = '';
165
- $data['invoice'] = $sessionid;
166
-
167
- // User details
168
- if($_POST['collected_data'][get_option('paypal_form_first_name')] != '') {
169
- $data['first_name'] = urlencode($_POST['collected_data'][get_option('paypal_form_first_name')]);
170
- }
171
-
172
- if($_POST['collected_data'][get_option('paypal_form_last_name')] != '') {
173
- $data['last_name'] = urlencode($_POST['collected_data'][get_option('paypal_form_last_name')]);
174
- }
175
-
176
- if($_POST['collected_data'][get_option('paypal_form_address')] != '') {
177
- $address_rows = explode("\n\r",$_POST['collected_data'][get_option('paypal_form_address')]);
178
- $data['address1'] = urlencode(str_replace(array("\n", "\r"), '', $address_rows[0]));
179
- unset($address_rows[0]);
180
- if($address_rows != null) {
181
- $data['address2'] = implode(", ",$address_rows);
182
- } else {
183
- $data['address2'] = '';
184
- }
185
- }
186
-
187
- if($_POST['collected_data'][get_option('paypal_form_city')] != '') {
188
- $data['city'] = urlencode($_POST['collected_data'][get_option('paypal_form_city')]);
189
- }
190
-
191
-
192
- if($_POST['collected_data'][get_option('paypal_form_state')] != '') {
193
- $data['state'] = urlencode($_POST['collected_data'][get_option('paypal_form_state')]);
194
- }
195
- if($_POST['collected_data'][get_option('paypal_form_country')] != '') {
196
- if(is_array($_POST['collected_data'][get_option('paypal_form_country')])) {
197
- $country = $_POST['collected_data'][get_option('paypal_form_country')][0];
198
- $id = $_POST['collected_data'][get_option('paypal_form_country')][1];
199
- $state = wpsc_get_state_by_id($id, 'code');
200
- } else {
201
- $country = $_POST['collected_data'][get_option('paypal_form_country')];
202
- }
203
- $data['country'] = urlencode($country);
204
- if($state != ''){
205
- $data['state'] = $state;
206
- }
207
- }
208
- if(is_numeric($_POST['collected_data'][get_option('paypal_form_post_code')])) {
209
- $data['zip'] = urlencode($_POST['collected_data'][get_option('paypal_form_post_code')]);
210
- }
211
- // Change suggested by waxfeet@gmail.com, if email to be sent is not there, dont send an email address
212
- $email_data = $wpdb->get_results("SELECT `id`,`type` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type` IN ('email') AND `active` = '1'",ARRAY_A);
213
- foreach((array)$email_data as $email) {
214
- $data['email'] = $_POST['collected_data'][$email['id']];
215
- }
216
-
217
- if(($_POST['collected_data'][get_option('email_form_field')] != null) && ($data['email'] == null)) {
218
- $data['email'] = $_POST['collected_data'][get_option('email_form_field')];
219
- }
220
-
221
- $data['upload'] = '1';
222
- $data['cmd'] = "_ext-enter";
223
- $data['redirect_cmd'] = "_cart";
224
- $data = apply_filters('wpsc_paypal_standard_post_data',$data);
225
-
226
- $datacount = count($data);
227
- $num = 0;
228
- foreach($data as $key=>$value) {
229
- $amp = '&';
230
- $num++;
231
- if($num == $datacount) {
232
- $amp = '';
233
- }
234
- //$output .= $key.'='.urlencode($value).$amp;
235
- $output .= $key.'='.$value.$amp;
236
- }
237
- if(get_option('paypal_ipn') == 0) { //ensures that digital downloads still work for people without IPN, less secure, though
238
- //$wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `processed` = '2' WHERE `sessionid` = ".$sessionid." LIMIT 1");
239
- }
240
- //written by allen
241
- if ($is_member == '1') {
242
- $membership_length = get_product_meta($cart[0]['prodid'],'membership_length',true);
243
- if ($is_perm == '1'){
244
- $permsub = '&src=1';
245
- } else {
246
- $permsub = '';
247
- }
248
- $output = 'cmd=_xclick-subscriptions&business='.urlencode($data['business']).'&no_note=1&item_name='.urlencode($data['item_name_1']).'&return='.urlencode($data['return']).'&cancel_return='.urlencode($data['cancel_return']).$permsub.'&a3='.urlencode($data['amount_1']).'&p3='.urlencode($membership_length['length']).'&t3='.urlencode(strtoupper($membership_length['unit']));
249
- }
250
- if(defined('WPSC_ADD_DEBUG_PAGE') and (WPSC_ADD_DEBUG_PAGE == true) ) {
251
- echo "<a href='".get_option('paypal_multiple_url')."?".$output."'>Test the URL here</a>";
252
- echo "<pre>".print_r($data,true)."</pre>";
253
- // echo "<pre>".print_r($_POST,true)."</pre>";
254
- exit();
255
- }
256
- header("Location: ".get_option('paypal_multiple_url')."?".$output);
257
- exit();
258
- }
259
-
260
- function nzshpcrt_paypal_ipn() {
261
- global $wpdb;
262
- // needs to execute on page start
263
- // look at page 36
264
- //exit(WPSC_GATEWAY_DEBUG );
265
- if(($_GET['ipn_request'] == 'true') && (get_option('paypal_ipn') == 1)) {
266
- // read the post from PayPal system and add 'cmd'
267
- $fields = 'cmd=_notify-validate';
268
- $message = "";
269
- foreach ($_POST as $key => $value) {
270
- $value = urlencode(stripslashes($value));
271
- $fields .= "&$key=$value";
272
- }
273
-
274
-
275
- // post back to PayPal system to validate
276
- $results = '';
277
- if(function_exists('curl_init')) {
278
- $ch=curl_init();
279
- curl_setopt($ch, CURLOPT_URL, get_option('paypal_multiple_url'));
280
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
281
- curl_setopt($ch, CURLOPT_NOPROGRESS, 1);
282
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
283
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
284
- curl_setopt($ch, CURLOPT_POST, 1);
285
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
286
- curl_setopt($ch, CURLOPT_TIMEOUT, 120);
287
- curl_setopt($ch, CURLOPT_USERAGENT, "WP e-Commerce ".WPSC_PRESENTABLE_VERSION);
288
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
289
-
290
- $results = curl_exec($ch);
291
- curl_close($ch);
292
- } else {
293
- $replace_strings[0] = 'http://';
294
- $replace_strings[1] = 'https://';
295
- $replace_strings[2] = '/cgi-bin/webscr';
296
-
297
- $paypal_url = str_replace($replace_strings, "",get_option('paypal_multiple_url'));
298
- $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
299
- $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
300
- $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
301
- $fp = fsockopen($paypal_url, 80, $errno, $errstr, 30);
302
- if($fp) {
303
- fputs ($fp, $header . $fields);
304
- while (!feof($fp)) {
305
- $res = fgets ($fp, 1024);
306
- $results .= $fields;
307
- }
308
- fclose ($fp);
309
- }
310
- }
311
-
312
-
313
- // assign posted variables to local variables
314
- $sessionid = $_POST['invoice'];
315
- $transaction_id = $_POST['txn_id'];
316
- $verification_data['item_name'] = $_POST['item_name'];
317
- $verification_data['item_number'] = $_POST['item_number'];
318
- $verification_data['payment_status'] = $_POST['payment_status'];
319
- $verification_data['payment_amount'] = $_POST['mc_gross'];
320
- $verification_data['payment_currency'] = $_POST['mc_currency'];
321
- $verification_data['txn_id'] = $_POST['txn_id'];
322
- $verification_data['receiver_email'] = $_POST['receiver_email'];
323
- $verification_data['payer_email'] = $_POST['payer_email'];
324
-
325
- if(strcmp ($results, "VERIFIED") == 0){
326
- switch($verification_data['payment_status']) {
327
- case 'Processed': // I think this is mostly equivalent to Completed
328
- case 'Completed':
329
- $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `processed` = '2' WHERE `sessionid` = ".$sessionid." LIMIT 1");
330
- transaction_results($sessionid, false, $transaction_id);
331
- break;
332
-
333
- case 'Failed': // if it fails, delete it
334
- $log_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`='$sessionid' LIMIT 1");
335
- $delete_log_form_sql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='$log_id'";
336
- $cart_content = $wpdb->get_results($delete_log_form_sql,ARRAY_A);
337
- foreach((array)$cart_content as $cart_item) {
338
- $cart_item_variations = $wpdb->query("DELETE FROM `".WPSC_TABLE_CART_ITEM_VARIATIONS."` WHERE `cart_id` = '".$cart_item['id']."'", ARRAY_A);
339
- }
340
- $wpdb->query("DELETE FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='$log_id'");
341
- $wpdb->query("DELETE FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id` IN ('$log_id')");
342
- $wpdb->query("DELETE FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`='$log_id' LIMIT 1");
343
- break;
344
-
345
- case 'Pending': // need to wait for "Completed" before processing
346
- $sql = "UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `transactid` = '".$transaction_id."', `date` = '".time()."' WHERE `sessionid` = ".$sessionid." LIMIT 1";
347
- $wpdb->query($sql) ;
348
- break;
349
-
350
- default: // if nothing, do nothing, safest course of action here.
351
- break;
352
- }
353
- } else if (strcmp ($results, "INVALID") == 0) {
354
- // Its already logged, not much need to do more
355
- }
356
-
357
- /*
358
- * Detect use of sandbox mode, if sandbox mode is present, send debugging email.
359
- *//*
360
- if(stristr(get_option('paypal_multiple_url'), "sandbox") || (defined('WPSC_ADD_DEBUG_PAGE') and (WPSC_ADD_DEBUG_PAGE == true)) ) {
361
- $message = "This is a debugging message sent because it appears that you are using sandbox mode.\n\rIt is only sent if the paypal URL contains the word \"sandbox\"\n\r\n\r";
362
- $message .= "RESULTS:\n\r".print_r($results,true)."\n\r\n\r";
363
- $message .= "OUR_POST:\n\r".print_r($header . $req,true)."\n\r\n\r";
364
- $message .= "THEIR_POST:\n\r".print_r($_POST,true)."\n\r\n\r";
365
- $message .= "GET:\n\r".print_r($_GET,true)."\n\r\n\r";
366
- $message .= "SERVER:\n\r".print_r($_SERVER,true)."\n\r\n\r";
367
- //$wpdb->query("INSERT INTO `paypal_log` ( `id` , `text` , `date` ) VALUES ( '', '$message', NOW( ) );");
368
- mail(get_option('purch_log_email'), "IPN Data", $message);
369
- }
370
- exit();
371
- }
372
- }
373
-
374
-
375
- function submit_paypal_multiple(){
376
- if($_POST['paypal_multiple_business'] != null) {
377
- update_option('paypal_multiple_business', $_POST['paypal_multiple_business']);
378
- }
379
-
380
- if($_POST['paypal_multiple_url'] != null) {
381
- update_option('paypal_multiple_url', $_POST['paypal_multiple_url']);
382
- }
383
-
384
- if($_POST['paypal_curcode'] != null) {
385
- update_option('paypal_curcode', $_POST['paypal_curcode']);
386
- }
387
-
388
- if($_POST['paypal_curcode'] != null) {
389
- update_option('paypal_curcode', $_POST['paypal_curcode']);
390
- }
391
-
392
- if($_POST['paypal_ipn'] != null) {
393
- update_option('paypal_ipn', (int)$_POST['paypal_ipn']);
394
- }
395
-
396
- if($_POST['address_override'] != null) {
397
- update_option('address_override', (int)$_POST['address_override']);
398
- }
399
- if($_POST['paypal_ship'] != null) {
400
- update_option('paypal_ship', (int)$_POST['paypal_ship']);
401
- }
402
-
403
- foreach((array)$_POST['paypal_form'] as $form => $value) {
404
- update_option(('paypal_form_'.$form), $value);
405
- }
406
-
407
- return true;
408
- }
409
-
410
- function form_paypal_multiple() {
411
- global $wpdb, $wpsc_gateways;
412
- $output = "
413
- <tr>
414
- <td>Username:
415
- </td>
416
- <td>
417
- <input type='text' size='40' value='".get_option('paypal_multiple_business')."' name='paypal_multiple_business' />
418
- </td>
419
- </tr>
420
- <tr>
421
- <td>Url:
422
- </td>
423
- <td>
424
- <input type='text' size='40' value='".get_option('paypal_multiple_url')."' name='paypal_multiple_url' /> <br />
425
-
426
- </td>
427
- </tr>
428
- ";
429
-
430
-
431
- $paypal_ipn = get_option('paypal_ipn');
432
- $paypal_ipn1 = "";
433
- $paypal_ipn2 = "";
434
- switch($paypal_ipn) {
435
- case 0:
436
- $paypal_ipn2 = "checked ='checked'";
437
- break;
438
-
439
- case 1:
440
- $paypal_ipn1 = "checked ='checked'";
441
- break;
442
- }
443
- $paypal_ship = get_option('paypal_ship');
444
- $paypal_ship1 = "";
445
- $paypal_ship2 = "";
446
- switch($paypal_ship){
447
- case 1:
448
- $paypal_ship1 = "checked='checked'";
449
- break;
450
-
451
- case 0:
452
- default:
453
- $paypal_ship2 = "checked='checked'";
454
- break;
455
-
456
- }
457
- $address_override = get_option('address_override');
458
- $address_override1 = "";
459
- $address_override2 = "";
460
- switch($address_override) {
461
- case 1:
462
- $address_override1 = "checked ='checked'";
463
- break;
464
-
465
- case 0:
466
- default:
467
- $address_override2 = "checked ='checked'";
468
- break;
469
- }
470
- $output .= "
471
- <tr>
472
- <td>IPN :
473
- </td>
474
- <td>
475
- <input type='radio' value='1' name='paypal_ipn' id='paypal_ipn1' ".$paypal_ipn1." /> <label for='paypal_ipn1'>".__('Yes', 'wpsc')."</label> &nbsp;
476
- <input type='radio' value='0' name='paypal_ipn' id='paypal_ipn2' ".$paypal_ipn2." /> <label for='paypal_ipn2'>".__('No', 'wpsc')."</label>
477
- </td>
478
- </tr>
479
- <tr>
480
- <td style='padding-bottom: 0px;'>Send shipping details:
481
- </td>
482
- <td style='padding-bottom: 0px;'>
483
- <input type='radio' value='1' name='paypal_ship' id='paypal_ship1' ".$paypal_ship1." /> <label for='paypal_ship1'>".__('Yes', 'wpsc')."</label> &nbsp;
484
- <input type='radio' value='0' name='paypal_ship' id='paypal_ship2' ".$paypal_ship2." /> <label for='paypal_ship2'>".__('No', 'wpsc')."</label>
485
-
486
- </td>
487
- </tr>
488
- <tr>
489
- <td colspan='2'>
490
- <span class='wpscsmall description'>
491
- Note: If your checkout page does not have a shipping details section, or if you don't want to send PayPal shipping information. You should change Send shipping details option to No.</span>
492
- </td>
493
- </tr>
494
- <tr>
495
- <td style='padding-bottom: 0px;'>
496
- Address Override:
497
- </td>
498
- <td style='padding-bottom: 0px;'>
499
- <input type='radio' value='1' name='address_override' id='address_override1' ".$address_override1." /> <label for='address_override1'>".__('Yes', 'wpsc')."</label> &nbsp;
500
- <input type='radio' value='0' name='address_override' id='address_override2' ".$address_override2." /> <label for='address_override2'>".__('No', 'wpsc')."</label>
501
- </td>
502
- </tr>
503
- <tr>
504
- <td colspan='2'>
505
- <span class='wpscsmall description'>
506
- This setting affects your PayPal purchase log. If your customers already have a PayPal account PayPal will try to populate your PayPal Purchase Log with their PayPal address. This setting tries to replace the address in the PayPal purchase log with the Address customers enter on your Checkout page.
507
- </span>
508
- </td>
509
- </tr>\n";
510
-
511
-
512
-
513
- $store_currency_data = $wpdb->get_row("SELECT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id` IN ('".absint(get_option('currency_type'))."')", ARRAY_A);
514
- $current_currency = get_option('paypal_curcode');
515
- if(($current_currency == '') && in_array($store_currency_data['code'], $wpsc_gateways['paypal_multiple']['supported_currencies']['currency_list'])) {
516
- update_option('paypal_curcode', $store_currency_data['code']);
517
- $current_currency = $store_currency_data['code'];
518
- }
519
-
520
- // exit($current_currency.'<br />'.$store_currency_data['code']);
521
- if($current_currency != $store_currency_data['code']) {
522
- $output .= "
523
- <tr>
524
- <td colspan='2'><strong class='form_group'>".__('Currency Converter')."</td>
525
- </tr>
526
- <tr>
527
- <td colspan='2'>".sprintf(__('Your website uses <strong>%s</strong>. This currency is not supported by PayPal, please select a currency using the drop down menu below. Buyers on your site will still pay in your local currency however we will send the order through to PayPal using the currency you choose below.', 'wpsc'), $store_currency_data['currency'])."</td>
528
- </tr>\n";
529
-
530
- $output .= " <tr>\n";
531
-
532
-
533
-
534
- $output .= " <td>Select Currency:</td>\n";
535
- $output .= " <td>\n";
536
- $output .= " <select name='paypal_curcode'>\n";
537
-
538
- $paypal_currency_list = $wpsc_gateways['paypal_multiple']['supported_currencies']['currency_list'];
539
-
540
- $currency_list = $wpdb->get_results("SELECT DISTINCT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `code` IN ('".implode("','",$paypal_currency_list)."')", ARRAY_A);
541
-
542
- foreach($currency_list as $currency_item) {
543
- $selected_currency = '';
544
- if($current_currency == $currency_item['code']) {
545
- $selected_currency = "selected='selected'";
546
- }
547
- $output .= "<option ".$selected_currency." value='{$currency_item['code']}'>{$currency_item['currency']}</option>";
548
- }
549
- $output .= " </select> \n";
550
- $output .= " </td>\n";
551
- $output .= " </tr>\n";
552
- }
553
-
554
-
555
- $output .= "
556
- <tr class='update_gateway' >
557
- <td colspan='2'>
558
- <div class='submit'>
559
- <input type='submit' value='".__('Update &raquo;', 'wpsc')."' name='updateoption'/>
560
- </div>
561
- </td>
562
- </tr>
563
-
564
- <tr class='firstrowth'>
565
- <td style='border-bottom: medium none;' colspan='2'>
566
- <strong class='form_group'>Forms Sent to Gateway</strong>
567
- </td>
568
- </tr>
569
-
570
- <tr>
571
- <td>
572
- First Name Field
573
- </td>
574
- <td>
575
- <select name='paypal_form[first_name]'>
576
- ".nzshpcrt_form_field_list(get_option('paypal_form_first_name'))."
577
- </select>
578
- </td>
579
- </tr>
580
- <tr>
581
- <td>
582
- Last Name Field
583
- </td>
584
- <td>
585
- <select name='paypal_form[last_name]'>
586
- ".nzshpcrt_form_field_list(get_option('paypal_form_last_name'))."
587
- </select>
588
- </td>
589
- </tr>
590
- <tr>
591
- <td>
592
- Address Field
593
- </td>
594
- <td>
595
- <select name='paypal_form[address]'>
596
- ".nzshpcrt_form_field_list(get_option('paypal_form_address'))."
597
- </select>
598
- </td>
599
- </tr>
600
- <tr>
601
- <td>
602
- City Field
603
- </td>
604
- <td>
605
- <select name='paypal_form[city]'>
606
- ".nzshpcrt_form_field_list(get_option('paypal_form_city'))."
607
- </select>
608
- </td>
609
- </tr>
610
- <tr>
611
- <td>
612
- State Field
613
- </td>
614
- <td>
615
- <select name='paypal_form[state]'>
616
- ".nzshpcrt_form_field_list(get_option('paypal_form_state'))."
617
- </select>
618
- </td>
619
- </tr>
620
- <tr>
621
- <td>
622
- Postal code/Zip code Field
623
- </td>
624
- <td>
625
- <select name='paypal_form[post_code]'>
626
- ".nzshpcrt_form_field_list(get_option('paypal_form_post_code'))."
627
- </select>
628
- </td>
629
- </tr>
630
- <tr>
631
- <td>
632
- Country Field
633
- </td>
634
- <td>
635
- <select name='paypal_form[country]'>
636
- ".nzshpcrt_form_field_list(get_option('paypal_form_country'))."
637
- </select>
638
- </td>
639
- </tr> ";
640
-
641
- return $output;
642
- }
643
-
644
-
645
- add_action('init', 'nzshpcrt_paypal_ipn');*/
646
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-shipping/ups.php CHANGED
@@ -1,15 +1,13 @@
1
  <?php
 
 
 
2
  class ups {
3
- var $internal_name, $name;
4
  public $service_url = "";
5
- private $MessageStart = "";
6
- private $RateRequest = "";
7
- private $RatePackage = "";
8
- private $RateCustomPackage = "";
9
- private $RateRequestEnd = "";
10
  private $Services = "";
11
 
12
- function ups() {
13
  $this->internal_name = "ups";
14
  $this->name="UPS";
15
  $this->is_external=true;
@@ -19,51 +17,77 @@ class ups {
19
  $this->_includeUPSData();
20
  $this->_setServiceURL();
21
  return true;
22
- }
23
 
24
- function getId() {
25
- // return $this->usps_id;
26
- }
27
 
28
- function setId($id) {
29
- // $usps_id = $id;
30
- // return true;
31
- }
32
 
33
- private function _setServiceURL(){
34
- global $wpdb;
35
- $wpsc_ups_settings = get_option("wpsc_ups_settings");
36
- $wpsc_ups_environment = $wpsc_ups_settings["upsenvironment"];
37
- if ($wpsc_ups_environment == "1"){
38
- $this->service_url = "https://www.ups.com/ups.app/xml/Rate";
39
- }else{
40
- $this->service_url = "https://wwwcie.ups.com/ups.app/xml/Rate";
41
- }
 
42
  }
 
43
 
44
- function getName() {
45
  return $this->name;
46
- }
47
 
48
- function getInternalName() {
49
  return $this->internal_name;
50
- }
51
-
52
- private function _includeUPSData(){
53
- list($eol,$Auth,$MessageStart,$RateRequest,
54
- $RateService, $RatePackage,
55
- $RateCustomPacakge,$RateRequestEnd,
56
- $Services) = include 'ups_data.php';
57
- $this->MessageStart = $MessageStart;
58
- $this->RateRequest = $RateRequest;
59
- $this->RateService = $RateService;
60
- $this->RatePackage = $RatePackage;
61
- $this->RateCustomPackage = $RateCustomPacakge;
62
- $this->RateRequestEnd = $RateRequestEnd;
63
- $this->Services = $Services;
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
- function getForm(){
67
  if (!isset($this->Services)){
68
  $this->_includeUPSData();
69
  }
@@ -82,48 +106,117 @@ class ups {
82
  $packaging_options['2b'] = __('UPS Express Box - Medium', 'wpsc');
83
  $packaging_options['2c'] = __('UPS Express Box - Large', 'wpsc');
84
 
85
- $output = "<tr>\n\r";
86
- $output .= " <td>".__('Destination Type', 'wpsc')."</td>\n\r";
87
- $output .= " <td>\n\r";
88
 
89
  // Default is Residential
90
  $checked[0] = "checked='checked'";
91
  $checked[1] = "";
92
- if ($wpsc_ups_settings['49_residential'] == "02"){
93
  $checked[0] = "";
94
  $checked[1] = "checked='checked'";
95
  }
96
 
97
- $output .= " <label><input type='radio' {$checked[0]} value='01' name='wpsc_ups_settings[49_residential]'/>".__('Residential Address', 'wpsc')."</label><br />\n\r";
98
- $output .= " <label><input type='radio' {$checked[1]} value='02' name='wpsc_ups_settings[49_residential]'/>".__('Commercial Address', 'wpsc')."</label>\n\r";
99
- $output .= " </td>\n\r";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  $output .= "</tr>\n\r";
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
 
 
 
 
 
 
 
 
 
 
102
 
 
103
  $output .= "<tr>\n\r";
104
- $output .= " <td>".__('Packaging', 'wpsc')."</td>\n\r";
105
- $output .= " <td>\n\r";
106
- $output .= " <select name='wpsc_ups_settings[48_container]'>\n\r";
107
  foreach($packaging_options as $key => $name) {
108
  $selected = '';
109
  if($key == $wpsc_ups_settings['48_container']) {
110
  $selected = "selected='true' ";
111
  }
112
- $output .= " <option value='{$key}' {$selected}>{$name}</option>\n\r";
113
  }
114
- $output .= " </select>\n\r";
115
- $output .= " </td>\n\r";
116
  $output .= "</tr>\n\r";
117
- // Added by Greg Gullett --
118
  $selected_env = $wpsc_ups_settings['upsenvironment'];
119
- if ($selected_env == "0"){
120
  $env_test = "checked=\"checked\"";
121
  }
122
  $output .= ("
123
  <tr>
124
  <td><label for=\"ups_env_test\" >".__('Use Testing Environment', 'wpsc')."</label></td>
125
  <td>
126
- <input type=\"checkbox\" id=\"ups_env_test\" name=\"wpsc_ups_settings[upsenvironment]\" value=\"0\" ".$env_test." /><br />
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  </td>
128
  </tr>
129
  ");
@@ -151,9 +244,15 @@ class ups {
151
 
152
  $output .= (" </div>
153
  <br />
154
- *".__('All services used if no services selected','wpsc')."
155
  </td>
156
  </tr>");
 
 
 
 
 
 
157
  $output .= ("<tr>
158
  <td>".__('UPS Username', 'wpsc')." :</td>
159
  <td>
@@ -173,307 +272,514 @@ class ups {
173
  <br />
174
  ".__('Don\'t have an API login/ID ?', 'wpsc')."
175
  <a href=\"https://www.ups.com/upsdeveloperkit?loc=en_US\" target=\"_blank\">".__('Click Here','wpsc')."</a>.
 
 
176
  </td>
177
  </tr>");
 
 
178
  // End new Code
179
  return $output;
180
- }
181
 
182
- function submit_form() {
183
- /* This function is called when the user hit "submit" in the
184
- * UPS settings area under Shipping to update the setttings.
185
- */
 
186
  $wpsc_ups_services = $_POST['wpsc_ups_services'];
187
  update_option('wpsc_ups_services',$wpsc_ups_services);
188
- if ($_POST['wpsc_ups_settings'] != '') {
189
- $temp = $_POST['wpsc_ups_settings'];
190
- // base64_encode the information so it isnt stored as plaintext.
191
- // base64 is by no means secure but without knowing if the server
192
- // has mcrypt installed what can you do really?
193
- $temp['upsusername'] = base64_encode($temp['upsusername']);
194
- $temp['upspassword'] = base64_encode($temp['upspassword']);
195
- $temp['upsid'] = base64_encode($temp['upsid']);
196
-
197
- update_option('wpsc_ups_settings', $temp);
198
- }
199
- return true;
200
- }
201
-
202
- private function _buildRateRequest($args){
203
- // Vars is an array
204
- // $RateRequest, $RatePackage, $RateCustomPackage, $RateRequestEnd
205
- // Are defined in ups_data.php that is included below if not
206
- // done so by instantiating class ... shouldnt ever need to
207
- if (!isset($this->MessageStart)){
208
- $this->_includeUPSData();
209
- }
210
- // By Default we will shop. Shop when you do not have a service type
211
- // and you want to get a set of services and rates back!
212
- $RequestType = "Shop";
213
- // If service type is set we cannot shop so instead we Rate!
214
- if (isset($args["service"])){
215
- $RequestType = "Rate";
216
- }
217
- // Always start of with this, it includes the auth block//
218
- $request = sprintf($this->MessageStart,
219
- // base64_encode the information so it isnt stored as plaintext.
220
- // base64 is by no means secure but without knowing if the server
221
- // has mcrypt installed what can you do really?
222
- base64_decode($args['api_id']), // UPS API ID#
223
- base64_decode($args['username']), // UPS API Username
224
- base64_decode($args['password']) // UPS API Password
225
- );
226
- // This starts this as a request for
227
- $request .= sprintf($this->RateRequest,
228
- $RequestType, // Options :: Rate or Shop
229
- $RequestType, // Options :: Rate or Shop
230
- $args['shipr_pcode'], // The shipper Postal Code
231
- $args['shipr_ccode'], // The shipper Country Code
232
- $args['dest_pcode'], // The Destination Postal Code
233
- $args['dest_ccode'] // The Destination
234
- );
235
- // If there is a specific service being requested then
236
- // we want to pass the service into the XML
237
- if (isset($args["service"])){
238
- $request .= sprintf($this->RateService,
239
- $args['service']);
240
- }
241
- // Always include this section, it starts the Package block, required
242
- $request .= sprintf($this->RatePackage,
243
- $args['packaging']);
244
- // If the packaging type is "Your Own aka Package" then UPS needs
245
- // the dimensions of the box you are going to use to accurately rate
246
- if ($args['packaging'] == "02"){
247
- $request .= sprintf($this->RateCustomPackage,
248
- $args['units'],
249
- $args['length'],
250
- $args['width'],
251
- $args['height']
252
- );
253
  }
254
- // Okay, time to wrap it all up!
255
- $request .= sprintf($this->RateRequestEnd,
256
- $args['units'],
257
- $args['weight'],
258
- $args['subtotal']
259
- );
260
- // Return the final XML document as a string to be used by _makeRateRequest
261
- return $request;
262
  }
 
 
263
 
264
- private function _makeRateRequest($message){
265
- // Make the XML request to the server and retrieve the response
266
- $ch = curl_init();
267
 
268
- curl_setopt($ch, CURLOPT_URL,$this->service_url);
269
- curl_setopt($ch, CURLOPT_POST, 1);
270
- curl_setopt($ch, CURLOPT_POSTFIELDS,
271
- $message);
272
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
 
274
- $data = curl_exec($ch);
275
- curl_close($ch);
276
- return $data;
 
 
 
277
  }
278
 
279
- private function _parseQuote($raw){
280
- $rate_table = array();
281
- $wpsc_ups_services = get_option("wpsc_ups_services");
282
- // Initialize a DOM using the XML passed in!
283
- $objDOM = new DOMDocument();
284
- if($raw != '') {
285
- $objDOM->loadXML($raw);
286
-
287
- // Get the <ResponseStatusCode> from the UPS XML
288
- $getStatusNode = $objDOM->getElementsByTagName("ResponseStatusCode");
289
- // Get the value of the error code, 1 == No Error, 0 == Error !!!
290
- $statusCode = $getStatusNode->item(0)->nodeValue;
291
-
292
- if ($statusCode == "0"){
293
- // Usually I dont leave debug stuff in but this is handy stuff!!
294
- // it will print out the error message returned by UPS!
295
- /*$getErrorDescNode = $objDOM->getElementsByTagName("ErrorDescription");
296
- $ErrorDesc = $getErrorDescNode->item(0)->nodeValue;
297
- echo "<br />Error : ".$ErrorDesc."<br />";*/
298
- return false;
299
- }else{
300
- $RateBlocks = $objDOM->getElementsByTagName("RatedShipment");
301
- foreach($RateBlocks as $rate_block){
302
- // Get the <Service> Node from the XML chunk
303
- $getServiceNode = $rate_block->getElementsByTagName("Service");
304
- $serviceNode = $getServiceNode->item(0);
305
-
306
- // Get the <Code> Node from the <Service> chunk
307
- $getServiceCodeNode = $serviceNode->getElementsByTagName("Code");
308
- // Get the value from <Code>
309
- $serviceCode = $getServiceCodeNode->item(0)->nodeValue;
310
-
311
- // Get the <TotalCharges> Node from the XML chunk
312
- $getChargeNodes = $rate_block->getElementsByTagName("TotalCharges");
313
- $chargeNode = $getChargeNodes->item(0);
314
-
315
- // Get the <CurrencyCode> from the <TotalCharge> chunk
316
- $getCurrNode= $chargeNode->getElementsByTagName("CurrencyCode");
317
- // Get the value of <CurrencyCode>
318
- $currCode = $getCurrNode->item(0)->nodeValue;
319
-
320
- // Get the <MonetaryValue> from the <TotalCharge> chunk
321
- $getMonetaryNode= $chargeNode->getElementsByTagName("MonetaryValue");
322
- // Get the value of <MonetaryValue>
323
- $price = $getMonetaryNode->item(0)->nodeValue;
324
- // If there are any services specified in the admin area
325
- // this will check that list and pass on adding any services that
326
- // are not explicitly defined.
327
- if (!empty($wpsc_ups_services)){
328
- if (is_array($wpsc_ups_services)){
329
- if (array_search($serviceCode, $wpsc_ups_services) === false){
330
- continue;
331
- }
332
- }else if ($wpsc_ups_services != $serviceCode){
333
- continue;
334
- }
335
- }
336
- if(array_key_exists($serviceCode,$this->Services)){
337
- $rate_table[$this->Services[$serviceCode]] = array($currCode,$price);
338
- }
339
-
340
- } // End foreach rated shipment block
341
- }
342
- }
343
- // Revers sort the rate selection so it is cheapest First!
344
- asort($rate_table);
345
- return $rate_table;
346
  }
347
 
348
- private function _formatTable($services, $currency=false){
349
- /* The checkout template expects the array to be in a certain
350
- * format. This function will iterate through the provided
351
- * services array and format it for use. During the loop
352
- * we take advantage of the loop and translate the currency
353
- * if necessary based off of what UPS tells us they are giving us
354
- * for currency and what is set for the main currency in the settings
355
- * area
356
- */
357
- $converter = null;
358
- if ($currency){
359
- $converter = new CURRENCYCONVERTER();
360
- }
361
- $finalTable = array();
362
- foreach(array_keys($services) as $service){
363
- if ($currency != false && $currency != $services[$service][0]){
364
- $temp =$services[$service][1];
365
- $services[$service][1] = $converter->convert($services[$service][1],
366
- $currency,
367
- $services[$service][0]);
368
- }
369
- $finalTable[$service] = $services[$service][1];
370
  }
371
- return $finalTable;
372
  }
373
 
374
- function getQuote(){
375
- global $wpdb, $wpsc_cart;
376
- // Arguments array for various functions to use
377
- $args = array();
378
- // Final rate table
379
- $rate_table = array();
380
- // Get the ups settings from the ups account info page (Shipping tab)
381
- $wpsc_ups_settings = get_option("wpsc_ups_settings");
382
- // Get the wordpress shopping cart options
383
- $wpsc_options = get_option("wpsc_options");
384
-
385
- // API Auth settings //
386
- $args['username'] = $wpsc_ups_settings['upsusername'];
387
- $args['password'] = $wpsc_ups_settings['upspassword'];
388
- $args['api_id'] = $wpsc_ups_settings['upsid'];
389
- // do we charge insurance and insurance calulation subtotal
390
- $insurance = $wpsc_ups_settings['upsinsurance'];
391
- if ($insurance == ""){
392
- $args['subtotal'] = 0;
393
- } else {
394
- $args['subtotal'] = $wpsc_cart->subtotal;
395
  }
396
- // What kind of pickup service do you use ?
397
- $args['pickup_type'] = "01";
398
- $args['packaging'] = $wpsc_ups_settings['48_container'];
399
- // Preferred Currency to display
400
- $currency_data = $wpdb->get_row("SELECT `code`
401
- FROM `".WPSC_TABLE_CURRENCY_LIST."`
402
- WHERE `isocode`='".$wpsc_options['currency_type']."'
403
- LIMIT 1",ARRAY_A) ;
404
- if ($currency_data){
405
- $args['currency'] = $currency_data['code'];
406
- }else{
407
- $args['currency'] = "USD";
 
408
  }
409
- // Shipping billing / account address
410
- $args['shipr_ccode'] = get_option('base_country');
411
- $args['shipr_pcode'] = get_option('base_zipcode');
412
- // Physical Shipping addres being shipped from
413
- $args['shipf_ccode'] = get_option('base_country');
414
- $args['shipf_pcode'] = get_option('base_zipcode');
415
- // Get the total weight from the shopping cart
416
- $args['units'] = "LBS";
417
- $args['weight'] = wpsc_cart_weight_total();
418
- // Destination zip code
419
- $args['dest_ccode'] = $_SESSION['wpsc_delivery_country'];
420
- if ($args['dest_ccode'] == "UK"){
421
- // So, UPS is a little off the times
422
- $args['dest_ccode'] = "GB";
 
 
 
 
 
 
 
 
 
 
423
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
 
425
- // If ths zip code is provided via a form post use it!
426
- if(isset($_POST['zipcode'])) {
427
- $args['dest_pcode'] = $_POST['zipcode'];
428
- $_SESSION['wpsc_zipcode'] = $_POST['zipcode'];
429
- } else if(isset($_SESSION['wpsc_zipcode'])) {
430
- // Well, we have a zip code in the session and no new one provided
431
- $args['dest_pcode'] = $_SESSION['wpsc_zipcode'];
 
 
432
  }else{
433
- // We cannot get a quote without a zip code so might as well return!
434
- return array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
435
  }
 
 
 
 
 
436
 
437
- $shipping_cache_check['zipcode'] = $args['dest_pcode'];
438
- $shipping_cache_check['weight'] = $args['weight'];
439
- // This is where shipping breaks out of UPS if weight is higher than 150 LBS
440
- if($weight > 150){
441
- unset($_SESSION['quote_shipping_method']);
442
- $shipping_quotes[TXT_WPSC_OVER_UPS_WEIGHT] = 0;
443
- $_SESSION['wpsc_shipping_cache_check']['weight'] = $args['weight'];
444
- $_SESSION['wpsc_shipping_cache'][$this->internal_name] = $shipping_quotes;
445
- $_SESSION['quote_shipping_method'] = $this->internal_name;
446
- return array($shipping_quotes);
 
 
 
 
 
 
 
 
 
 
447
  }
448
- // We do not want to spam UPS (and slow down our process) if we already
449
- // have a shipping quote!
450
- if(($_SESSION['wpsc_shipping_cache_check'] === $shipping_cache_check)
451
- && ($_SESSION['wpsc_shipping_cache'][$this->internal_name] != null)) {
452
- $rate_table = $_SESSION['wpsc_shipping_cache'][$this->internal_name];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
453
  }else{
454
- // Build the XML request
455
- $request = $this->_buildRateRequest($args);
456
- // Now that we have the message to send ... Send it!
457
- $raw_quote = $this->_makeRateRequest($request);
458
- // Now we have the UPS response .. unfortunately its not ready
459
- // to be viewed by normal humans ...
460
- $quotes = $this->_parseQuote($raw_quote);
461
- // If we actually have rates back from UPS we can use em!
462
- if ($quotes != false){
463
- $rate_table = $this->_formatTable($quotes,$args['currency']);
464
  }
465
  }
466
- // return the final formatted array !
467
- $_SESSION['wpsc_shipping_cache_check']['zipcode'] = $args['dest_pcode'];
468
- $_SESSION['wpsc_shipping_cache_check']['weight'] = $args['weight'];
469
- $_SESSION['wpsc_shipping_cache'][$this->internal_name] = $rate_table;
470
- return $rate_table;
471
  }
 
 
 
 
 
 
 
 
472
 
473
- // Empty Function, this exists just b/c it is prototyped elsewhere
474
- function get_item_shipping(){
475
- }
476
  }
477
  $ups = new ups();
478
  $wpsc_shipping_modules[$ups->getInternalName()] = $ups;
479
- ?>
1
  <?php
2
+ /* Author : Greg Gullett and Instinct.co.nz
3
+ * SVN : UPS Trunk : Revision 15 : July 31, 2010
4
+ */
5
  class ups {
6
+ var $internal_name, $name;
7
  public $service_url = "";
 
 
 
 
 
8
  private $Services = "";
9
 
10
+ function ups() {
11
  $this->internal_name = "ups";
12
  $this->name="UPS";
13
  $this->is_external=true;
17
  $this->_includeUPSData();
18
  $this->_setServiceURL();
19
  return true;
20
+ }
21
 
22
+ function getId() {
23
+ // return $this->usps_id;
24
+ }
25
 
26
+ function setId($id) {
27
+ // $usps_id = $id;
28
+ // return true;
29
+ }
30
 
31
+ private function _setServiceURL(){
32
+ global $wpdb;
33
+ $wpsc_ups_settings = get_option("wpsc_ups_settings");
34
+ $wpsc_ups_environment = '';
35
+ if(!empty($wpsc_ups_settings))
36
+ $wpsc_ups_environment = (array_key_exists("upsenvironment",$wpsc_ups_settings)) ? $wpsc_ups_settings["upsenvironment"] : "1";
37
+ if ($wpsc_ups_environment == "1"){
38
+ $this->service_url = "https://wwwcie.ups.com/ups.app/xml/Rate";
39
+ }else{
40
+ $this->service_url = "https://www.ups.com/ups.app/xml/Rate";
41
  }
42
+ }
43
 
44
+ function getName() {
45
  return $this->name;
46
+ }
47
 
48
+ function getInternalName() {
49
  return $this->internal_name;
50
+ }
51
+
52
+ private function _includeUPSData(){
53
+ $this->drop_types = array(
54
+ "01"=>"Daily Pickup",
55
+ "03"=>"Customer Counter",
56
+ "06"=>"One Time Pickup",
57
+ "07"=>"On Call Air",
58
+ "19"=>"Letter Center",
59
+ "20"=>"Air Service Center",
60
+ "11"=>"Suggested Retail Rates (Advanced Config)"
61
+ );
62
+
63
+ $this->cust_types = array(
64
+ "01" => "Daily Pickup, with UPS Account",
65
+ "03" => "No Daily Pickup, with No or Other Account",
66
+ "04" => "Retail Outlet (Only US origin shipments)"
67
+ );
68
+
69
+ $this->Services = array(
70
+ "14" => "Next Day Air Early AM",
71
+ "01" => "Next Day Air",
72
+ "13" => "Next Day Air Saver",
73
+ "59" => "2nd Day Air AM",
74
+ "02" => "2nd Day Air",
75
+ "12" => "3 Day Select",
76
+ "03" => "Ground",
77
+ "11" => "Standard",
78
+ "07" => "Worldwide Express",
79
+ "54" => "Worldwide Express Plus",
80
+ "08" => "Worldwide Expedited",
81
+ "65" => "Saver",
82
+ "82" => "UPS Today Standard",
83
+ "83" => "UPS Today Dedicated Courier",
84
+ "84" => "UPS Today Intercity",
85
+ "85" => "UPS Today Express",
86
+ "86" => "UPS Today Express Saver"
87
+ );
88
+ }
89
 
90
+ function getForm(){
91
  if (!isset($this->Services)){
92
  $this->_includeUPSData();
93
  }
106
  $packaging_options['2b'] = __('UPS Express Box - Medium', 'wpsc');
107
  $packaging_options['2c'] = __('UPS Express Box - Large', 'wpsc');
108
 
109
+ $output = "<tr>\n\r";
110
+ $output .= " <td>".__('Destination Type', 'wpsc')."</td>\n\r";
111
+ $output .= " <td>\n\r";
112
 
113
  // Default is Residential
114
  $checked[0] = "checked='checked'";
115
  $checked[1] = "";
116
+ if ($wpsc_ups_settings['49_residential'] == "2"){
117
  $checked[0] = "";
118
  $checked[1] = "checked='checked'";
119
  }
120
 
121
+ $output .= " <label><input type='radio' {$checked[0]} value='1' name='wpsc_ups_settings[49_residential]'/>".__('Residential Address', 'wpsc')."</label><br />\n\r";
122
+ $output .= " <label><input type='radio' {$checked[1]} value='2' name='wpsc_ups_settings[49_residential]'/>".__('Commercial Address', 'wpsc')."</label>\n\r";
123
+ $output .= " </td>\n\r";
124
+ $output .= "</tr>\n\r";
125
+ $output .= "<tr>\n\r";
126
+
127
+ // Dropoff Type
128
+ $output .= " <td>".__('Dropoff Type', 'wpsc')."</td>\n\r";
129
+ $output .= " <td>\n\r";
130
+ $output .= ("<script type=\"text/javascript\">
131
+ function checkDropValue(){
132
+ var val = jQuery(\"#drop_type option:selected\").val();
133
+ if (val == \"11\"){
134
+ jQuery(\"#cust_type\").removeAttr(\"disabled\");
135
+ }else{
136
+ jQuery(\"#cust_type\").attr(\"disabled\", true);
137
+ }
138
+ }
139
+ </script>");
140
+ $output .= " <select id='drop_type' name='wpsc_ups_settings[DropoffType]' onChange='checkDropValue()' >\n\r";
141
+
142
+ $sel2_drop = "";
143
+ if (empty($wpsc_ups_settings['DropoffType'])){
144
+ $sel2_drop = "01";
145
+ }else{ $sel2_drop = $wpsc_ups_settings['DropoffType']; }
146
+
147
+ foreach(array_keys($this->drop_types) as $dkey){
148
+ $sel = "";
149
+ if ($sel2_drop == $dkey){
150
+ $sel = 'selected="selected"';
151
+ }
152
+ $output .= " <option value=\"".$dkey."\" ".$sel." >".$this->drop_types[$dkey]."</option>\n\r";
153
+ }
154
+ $output .= " </select>\n\r";
155
+ $output .= " </td>\n\r";
156
  $output .= "</tr>\n\r";
157
+ $cust = "disabled='true'";
158
+ if ($wpsc_ups_settings['DropoffType'] == "11"){
159
+ $cust = "";
160
+ }
161
+ // Customer Type
162
+ $output .= " <td>".__('Customer Type', 'wpsc')."</td>\n\r";
163
+ $output .= " <td>\n\r";
164
+ $output .= " <select id='cust_type' name='wpsc_ups_settings[CustomerType]' ".$cust." >\n\r";
165
+
166
+ $sel3_drop = "";
167
+ if (empty($wpsc_ups_settings['CustomerType'])){
168
+ $sel3_drop = "01";
169
+ }else{ $sel3_drop = $wpsc_ups_settings['CustomerType']; }
170
 
171
+ foreach(array_keys($this->cust_types) as $dkey){
172
+ $sel = "";
173
+ if ($sel3_drop == $dkey){
174
+ $sel = 'selected="selected"';
175
+ }
176
+ $output .= " <option value=\"".$dkey."\" ".$sel." >".$this->cust_types[$dkey]."</option>\n\r";
177
+ }
178
+ $output .= " </select>\n\r";
179
+ $output .= " </td>\n\r";
180
+ $output .= "</tr>\n\r";
181
 
182
+ // Packaging Config
183
  $output .= "<tr>\n\r";
184
+ $output .= " <td>".__('Packaging', 'wpsc')."</td>\n\r";
185
+ $output .= " <td>\n\r";
186
+ $output .= " <select name='wpsc_ups_settings[48_container]'>\n\r";
187
  foreach($packaging_options as $key => $name) {
188
  $selected = '';
189
  if($key == $wpsc_ups_settings['48_container']) {
190
  $selected = "selected='true' ";
191
  }
192
+ $output .= " <option value='{$key}' {$selected}>{$name}</option>\n\r";
193
  }
194
+ $output .= " </select>\n\r";
195
+ $output .= " </td>\n\r";
196
  $output .= "</tr>\n\r";
197
+
198
  $selected_env = $wpsc_ups_settings['upsenvironment'];
199
+ if ($selected_env == "1"){
200
  $env_test = "checked=\"checked\"";
201
  }
202
  $output .= ("
203
  <tr>
204
  <td><label for=\"ups_env_test\" >".__('Use Testing Environment', 'wpsc')."</label></td>
205
  <td>
206
+ <input type=\"checkbox\" id=\"ups_env_test\" name=\"wpsc_ups_settings[upsenvironment]\" value=\"1\" ".$env_test." /><br />
207
+ </td>
208
+ </tr>
209
+ ");
210
+ $selected_negotiated_rate = $wpsc_ups_settings['ups_negotiated_rates'];
211
+ $negotiated_rates = "";
212
+ if ($selected_negotiated_rate == "1"){
213
+ $negotiated_rates = "checked=\"checked\"";
214
+ }
215
+ $output .= ("
216
+ <tr>
217
+ <td><label for=\"ups_negotiated_rates\" >".__('Show UPS negotiated rates', 'wpsc')." *</label></td>
218
+ <td>
219
+ <input type=\"checkbox\" id=\"ups_negotiated_rates\" name=\"wpsc_ups_settings[ups_negotiated_rates]\" value=\"1\" ".$negotiated_rates." /><br />
220
  </td>
221
  </tr>
222
  ");
244
 
245
  $output .= (" </div>
246
  <br />
247
+ -Note: ".__('All services used if no services selected','wpsc')."
248
  </td>
249
  </tr>");
250
+ $output .= ("<tr>
251
+ <td>".__('UPS Account #', 'wpsc')." *:</td>
252
+ <td>
253
+ <input type=\"text\" name='wpsc_ups_settings[upsaccount]' value=\"".$wpsc_ups_settings['upsaccount']."\" />
254
+ </td>
255
+ </tr>");
256
  $output .= ("<tr>
257
  <td>".__('UPS Username', 'wpsc')." :</td>
258
  <td>
272
  <br />
273
  ".__('Don\'t have an API login/ID ?', 'wpsc')."
274
  <a href=\"https://www.ups.com/upsdeveloperkit?loc=en_US\" target=\"_blank\">".__('Click Here','wpsc')."</a>.
275
+ <br />
276
+ ".__('* For Negotiated rates, you must enter a UPS account number and select "Show UPS negotiated rates" ', 'wpsc')."
277
  </td>
278
  </tr>");
279
+
280
+
281
  // End new Code
282
  return $output;
283
+ }
284
 
285
+ function submit_form() {
286
+ /* This function is called when the user hit "submit" in the
287
+ * UPS settings area under Shipping to update the setttings.
288
+ */
289
+ if ($_POST['wpsc_ups_settings'] != '') {
290
  $wpsc_ups_services = $_POST['wpsc_ups_services'];
291
  update_option('wpsc_ups_services',$wpsc_ups_services);
292
+ $temp = $_POST['wpsc_ups_settings'];
293
+ // base64_encode the information so it isnt stored as plaintext.
294
+ // base64 is by no means secure but without knowing if the server
295
+ // has mcrypt installed what can you do really?
296
+ $temp['upsusername'] = base64_encode($temp['upsusername']);
297
+ $temp['upspassword'] = base64_encode($temp['upspassword']);
298
+ $temp['upsid'] = base64_encode($temp['upsid']);
299
+
300
+ update_option('wpsc_ups_settings', $temp);
301
+ }
302
+ return true;
303
+ }
304
+
305
+ function array2xml($data){
306
+ $xml = "";
307
+ if (is_array($data)){
308
+ foreach($data as $key=>$value){
309
+ //if(empty($value)){
310
+ // $xml .= "<".trim($key)." />\n";
311
+ //}else{
312
+ $xml .= "<".trim($key).">\n";
313
+ $xml .= $this->array2xml($value);
314
+ $xml .= "</".trim($key).">\n";
315
+ // }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  }
317
+ }else if(is_bool($data)){
318
+ if($data){$xml = "true\n";}
319
+ else { $xml = "false\n"; }
320
+ }else{
321
+ $xml = trim($data)."\n";
 
 
 
322
  }
323
+ return $xml;
324
+ }
325
 
 
 
 
326
 
327
+ private function _buildRateRequest($args){
328
+ // Vars is an array
329
+ // $RateRequest, $RatePackage, $RateCustomPackage, $RateRequestEnd
330
+ // Are defined in ups_data.php that is included below if not
331
+ // done so by instantiating class ... shouldnt ever need to
332
+ if (!isset($this->MessageStart)){
333
+ $this->_includeUPSData();
334
+ }
335
+ // Always start of with this, it includes the auth block//
336
+ $REQUEST = "<?xml version=\"1.0\"?>\n
337
+ <AccessRequest xml:lang=\"en-US\">\n";
338
+
339
+ $access = array(
340
+ "AccessLicenseNumber"=>base64_decode($args['api_id']), // UPS API ID#
341
+ "UserId" =>base64_decode($args['username']), // UPS API Username
342
+ "Password" =>base64_decode($args['password']) // UPS API Password
343
+ );
344
+
345
+ $REQUEST .= $this->array2xml($access);
346
+ $REQUEST .= "</AccessRequest>\n";
347
+ $REQUEST .= "<RatingServiceSelectionRequest xml:lang=\"en-US\">\n";
348
 
349
+ // By Default we will shop. Shop when you do not have a service type
350
+ // and you want to get a set of services and rates back!
351
+ $RequestType = "Shop";
352
+ // If service type is set we cannot shop so instead we Rate!
353
+ if (isset($args["service"])){
354
+ $RequestType = "Rate";
355
  }
356
 
357
+ $RatingServiceRequest = array(
358
+ "Request"=>array(
359
+ "TransactionReference"=>array(
360
+ "CustomerContext"=>"Rate Request",
361
+ "XpciVersion"=>"1.0001"
362
+ ),
363
+ "RequestAction"=>"Rate",
364
+ "RequestOption"=>$RequestType
365
+ )
366
+ );
367
+
368
+ // Set the dropoff code
369
+ $dropCode = (array_key_exists('DropoffType',$args)) ? $args['DropoffType'] : '01';
370
+ $PickupType = array("PickupType"=>array(
371
+ "Code"=>$dropCode
372
+ ));
373
+
374
+ $REQUEST .= $this->array2xml($PickupType);
375
+
376
+ if ($dropCode == "11" && $args['shipr_ccode'] == "US"){
377
+ // Set the request code
378
+ $CustCode = (array_key_exists('CustomerType',$args)) ? $args['CustomerType'] : '01';
379
+ $CustomerType = array("CustomerClassification"=>array(
380
+ "Code"=>$CustCode
381
+ ));
382
+ $REQUEST .= $this->array2xml($CustomerType);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  }
384
 
385
+ // Set up Shipment Node
386
+ $Shipment = array();
387
+
388
+ // Shipper Address (billing)
389
+ $Shipment["Shipper"]=array(
390
+ "Address"=>array(
391
+ "StateProvinceCode"=>$args['shipr_state'],
392
+ "PostalCode"=>$args['shipr_pcode'], // The shipper Postal Code
393
+ "CountryCode"=>$args['shipr_ccode']
394
+ ));
395
+
396
+ // Negotiated Rates
397
+ if (array_key_exists('negotiated_rates', $args) ){
398
+ if ($args['negotiated_rates'] == '1' && !empty($args['account_number'])){
399
+ $Shipment["Shipper"]["ShipperNumber"] = $args['account_number'];
 
 
 
 
 
 
 
400
  }
 
401
  }
402
 
403
+ // If the city is configured use it
404
+ if (array_key_exists('shipr_city', $args)){
405
+ if (!empty($args['shipr_city'])){
406
+ $Shipment["Shipper"]["Address"]["City"] = $args["shipr_city"];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
  }
408
+ }
409
+ // The physical address the shipment is from (normally the same as billing)
410
+ $Shipment["ShipFrom"]=array(
411
+ "Address"=>array(
412
+ "StateProvinceCode"=>$args['shipf_state'],
413
+ "PostalCode"=>$args['shipf_pcode'], // The shipper Postal Code
414
+ "CountryCode"=>$args['shipf_ccode']
415
+ ));
416
+
417
+ // If the city is configured use it
418
+ if (array_key_exists('shipf_city', $args)){
419
+ if (!empty($args['shipf_city'])){
420
+ $Shipment["ShipFrom"]["Address"]["City"] = $args["shipf_city"];
421
  }
422
+ }
423
+
424
+ $Shipment["ShipTo"]= array(
425
+ "Address"=>array(
426
+ "StateProvinceCode"=>$args['dest_state'], // The Destination State
427
+ "PostalCode"=>$args['dest_pcode'], // The Destination Postal Code
428
+ "CountryCode"=>$args['dest_ccode'], // The Destination Country
429
+ //"ResidentialAddress"=>"1"
430
+ ));
431
+
432
+ if ($args['residential'] == '1'){ //ResidentialAddressIndicator orig - Indicator
433
+ $Shipment["ShipTo"]["Address"]["ResidentialAddressIndicator"] = "1";
434
+ }
435
+
436
+ // If there is a specific service being requested then
437
+ // we want to pass the service into the XML
438
+ if (isset($args["service"])){
439
+ $Shipment["Service"] = array("Code" =>$args['service']);
440
+ }
441
+
442
+ // Include this only if you want negotiated rates
443
+ if (array_key_exists('negotiated_rates', $args) ){
444
+ if ($args['negotiated_rates'] == "1"){
445
+ $Shipment["RateInformation"]=array("NegotiatedRatesIndicator" => "");
446
  }
447
+ }
448
+
449
+ $Shipment["Package"] = array(
450
+ "PackagingType"=>array("Code"=>$args['packaging']),
451
+ "PackageWeight"=>array(
452
+ "UnitOfMeasurement"=>array("Code"=>$args['units']),
453
+ "Weight" => $args["weight"]
454
+ )
455
+ );
456
+
457
+ // Set the structure for the Shipment Node
458
+ $RatingServiceRequest["Shipment"] = $Shipment;
459
+
460
+ $REQUEST .= $this->array2xml($RatingServiceRequest);
461
+ $REQUEST .= "</RatingServiceSelectionRequest>";
462
+
463
+ // Return the final XML document as a string to be used by _makeRateRequest
464
+ //$file = fopen('request-enhanced.'.time().'.log', 'w');
465
+ //fwrite($file, $REQUEST."\n");
466
+ return $REQUEST;
467
+ }
468
+
469
+ private function _makeRateRequest($message){
470
+ // Make the XML request to the server and retrieve the response
471
+ $ch = curl_init();
472
+
473
+ curl_setopt($ch, CURLOPT_URL,$this->service_url);
474
+ curl_setopt($ch, CURLOPT_POST, 1);
475
+ curl_setopt($ch, CURLOPT_POSTFIELDS,
476
+ $message);
477
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
478
+
479
+ $data = curl_exec($ch);
480
+ curl_close($ch);
481
+ return $data;
482
+ }
483
+
484
+ public function futureDate($interval){
485
+ //Wed Apr 7
486
+ date_default_timezone_set('America/Los_Angeles');
487
+ $timestamp = date('c');
488
+ $hour = date("G");
489
+ if ((int)$hour >= 3){
490
+ $interval += 1;
491
+ }
492
+
493
+ $date = date("Y-m-d");
494
+ $interval = " +$interval day";
495
+ $final = date("D M j",strtotime(date("Y-m-d", strtotime($date)).$interval));
496
+ $test = explode(" ",$final);
497
+
498
+ if ($test[0] == "Sat"){
499
+ return $this->futureDate($interval+2);
500
+ }else if($test[0] == "Sun"){
501
+ return $this->futureDate($interval+1);
502
+ }
503
+ return $final;
504
+ }
505
+
506
+ private function _parseQuote($raw){
507
+ global $wpdb;
508
+
509
+ $config = get_option('wpsc_ups_settings');
510
+ $debug = (array_key_exists('upsenvironment', $config)) ? $config['upsenvironment'] : "";
511
+
512
+ $rate_table = array();
513
+ $wpsc_ups_services = get_option("wpsc_ups_services");
514
+ // Initialize a DOM using the XML passed in!
515
+ $objDOM = new DOMDocument();
516
+ if($raw != '') {
517
+ $objDOM->loadXML($raw);
518
+
519
+ // Get the <ResponseStatusCode> from the UPS XML
520
+ $getStatusNode = $objDOM->getElementsByTagName("ResponseStatusCode");
521
+ // Get the value of the error code, 1 == No Error, 0 == Error !!!
522
+ $statusCode = $getStatusNode->item(0)->nodeValue;
523
 
524
+ if ($statusCode == "0"){
525
+ // Usually I dont leave debug stuff in but this is handy stuff!!
526
+ // it will print out the error message returned by UPS!
527
+ if ($debug == "1"){
528
+ $getErrorDescNode = $objDOM->getElementsByTagName("ErrorDescription");
529
+ $ErrorDesc = $getErrorDescNode->item(0)->nodeValue;
530
+ echo "<br />Error : ".$ErrorDesc."<br />";
531
+ }
532
+ return false;
533
  }else{
534
+ $RateBlocks = $objDOM->getElementsByTagName("RatedShipment");
535
+ foreach($RateBlocks as $rate_block){
536
+ // Get the <Service> Node from the XML chunk
537
+ $getServiceNode = $rate_block->getElementsByTagName("Service");
538
+ $serviceNode = $getServiceNode->item(0);
539
+
540
+ // Get the <Code> Node from the <Service> chunk
541
+ $getServiceCodeNode = $serviceNode->getElementsByTagName("Code");
542
+ // Get the value from <Code>
543
+ $serviceCode = $getServiceCodeNode->item(0)->nodeValue;
544
+ $go = true;
545
+ $price = "";
546
+ $time = "";
547
+
548
+ //if (array_key_exists('ups_negotiated_rates', $config)){
549
+ $getNegotiatedRateNode = $rate_block->getElementsByTagName("NegotiatedRates");
550
+ if ($getNegotiatedRateNode){
551
+ $negotiatedRateNode = $getNegotiatedRateNode->item(0);
552
+ if ($negotiatedRateNode){
553
+ $getNetSummaryNode = $negotiatedRateNode->getElementsByTagName("NetSummaryCharges");
554
+ $netSummaryNode = $getNetSummaryNode->item(0);
555
+
556
+ $getGrandTotalNode = $netSummaryNode->getElementsByTagName("GrandTotal");
557
+ $grandTotalNode = $getGrandTotalNode->item(0);
558
+
559
+ $getMonetaryNode = $grandTotalNode->getElementsByTagName("MonetaryValue");
560
+ $monetaryNode = $getMonetaryNode->item(0)->nodeValue;
561
+ if (!empty($monetaryNode)){
562
+ $go = false;
563
+ $price = $monetaryNode;
564
+ }
565
+ }
566
+ }
567
+
568
+ // Get the <TotalCharges> Node from the XML chunk
569
+ $getChargeNodes = $rate_block->getElementsByTagName("TotalCharges");
570
+ $chargeNode = $getChargeNodes->item(0);
571
+ /*
572
+ $getDeliveryNode = $rate_block->getElementsByTagName("GuaranteedDaysToDelivery");
573
+ $deliveryDays = $getDeliveryNode->item(0)->nodeValue;
574
+ if ($deliveryDays){
575
+ $time = $this->futureDate($deliveryDays);
576
+ }else{
577
+ $time = $this->futureDate(6);
578
+ }
579
+ */
580
+ // Get the <CurrencyCode> from the <TotalCharge> chunk
581
+ $getCurrNode= $chargeNode->getElementsByTagName("CurrencyCode");
582
+ // Get the value of <CurrencyCode>
583
+ $currCode = $getCurrNode->item(0)->nodeValue;
584
+
585
+ if ($go == true){
586
+ // Get the <MonetaryValue> from the <TotalCharge> chunk
587
+ $getMonetaryNode= $chargeNode->getElementsByTagName("MonetaryValue");
588
+ // Get the value of <MonetaryValue>
589
+ $price = $getMonetaryNode->item(0)->nodeValue;
590
+ }
591
+ // If there are any services specified in the admin area
592
+ // this will check that list and pass on adding any services that
593
+ // are not explicitly defined.
594
+ if (!empty($wpsc_ups_services)){
595
+ if (is_array($wpsc_ups_services)){
596
+ if (array_search($serviceCode, $wpsc_ups_services) === false){
597
+ continue;
598
+ }
599
+ }else if ($wpsc_ups_services != $serviceCode){
600
+ continue;
601
+ }
602
+ }
603
+ if(array_key_exists($serviceCode,$this->Services)){
604
+ $rate_table[$this->Services[$serviceCode]] = array($currCode,$price);
605
+ }
606
+
607
+ } // End foreach rated shipment block
608
  }
609
+ }
610
+ // Revers sort the rate selection so it is cheapest First!
611
+ asort($rate_table);
612
+ return $rate_table;
613
+ }
614
 
615
+ private function _formatTable($services, $currency=false){
616
+ /* The checkout template expects the array to be in a certain
617
+ * format. This function will iterate through the provided
618
+ * services array and format it for use. During the loop
619
+ * we take advantage of the loop and translate the currency
620
+ * if necessary based off of what UPS tells us they are giving us
621
+ * for currency and what is set for the main currency in the settings
622
+ * area
623
+ */
624
+ $converter = null;
625
+ if ($currency){
626
+ $converter = new CURRENCYCONVERTER();
627
+ }
628
+ $finalTable = array();
629
+ foreach(array_keys($services) as $service){
630
+ if ($currency != false && $currency != $services[$service][0]){
631
+ $temp =$services[$service][1];
632
+ $services[$service][1] = $converter->convert($services[$service][1],
633
+ $currency,
634
+ $services[$service][0]);
635
  }
636
+ $finalTable[$service] = $services[$service][1];
637
+ }
638
+ return $finalTable;
639
+ }
640
+
641
+ function getQuote(){
642
+ global $wpdb;
643
+
644
+ // Arguments array for various functions to use
645
+ $args = array();
646
+ // Final rate table
647
+ $rate_table = array();
648
+ // Get the ups settings from the ups account info page (Shipping tab)
649
+ $wpsc_ups_settings = get_option("wpsc_ups_settings");
650
+ // Get the wordpress shopping cart options
651
+ $wpsc_options = get_option("wpsc_options");
652
+
653
+ // API Auth settings //
654
+ $args['username'] = (array_key_exists('upsaccount',$wpsc_ups_settings)) ? $wpsc_ups_settings['upsusername'] : "";
655
+ $args['password'] = (array_key_exists('upspassword',$wpsc_ups_settings)) ? $wpsc_ups_settings['upspassword'] : "";
656
+ $args['api_id'] = (array_key_exists('upsid',$wpsc_ups_settings)) ? $wpsc_ups_settings['upsid'] : "";
657
+ $args['account_number'] = (array_key_exists('upsaccount',$wpsc_ups_settings)) ? $wpsc_ups_settings['upsaccount'] : "";
658
+ $args['negotiated_rates'] = (array_key_exists('ups_negotiated_rates',$wpsc_ups_settings)) ?
659
+ $wpsc_ups_settings['ups_negotiated_rates'] : "";
660
+ $args['residential'] = $wpsc_ups_settings['49_residential'];
661
+
662
+ // What kind of pickup service do you use ?
663
+ $args['DropoffType'] = $wpsc_ups_settings['DropoffType'];
664
+ $args['packaging'] = $wpsc_ups_settings['48_container'];
665
+ // Preferred Currency to display
666
+ $currency_data = $wpdb->get_row("SELECT `code`
667
+ FROM `".WPSC_TABLE_CURRENCY_LIST."`
668
+ WHERE `isocode`='".get_option("currency_type")."'
669
+ LIMIT 1", ARRAY_A) ;
670
+ if ($currency_data){
671
+ $args['currency'] = $currency_data['code'];
672
+ }else{
673
+ $args['currency'] = "USD";
674
+ }
675
+ // Shipping billing / account address
676
+ $origin_region_data = $wpdb->get_results("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`
677
+ WHERE `".WPSC_TABLE_REGION_TAX."`.`id` = '".get_option('base_region')."' ",ARRAY_A);
678
+ $args['shipr_state']= (is_array($origin_region_data)) ? $origin_region_data[0]['code'] : "";
679
+ $args['shipr_city'] = get_option('base_city');
680
+ $args['shipr_ccode'] = get_option('base_country');
681
+ $args['shipr_pcode'] = get_option('base_zipcode');
682
+ // Physical Shipping address being shipped from
683
+ $args['shipf_state'] = $args['shipr_state'];
684
+ $args['shipf_city'] = $args['shipr_city'];
685
+ $args['shipf_ccode'] = $args['shipr_ccode'];
686
+ $args['shipf_pcode'] = $args['shipr_pcode'];
687
+ // Get the total weight from the shopping cart
688
+ $args['units'] = "LBS";
689
+ $args['weight'] = wpsc_cart_weight_total();
690
+ // Destination zip code
691
+ $args['dest_ccode'] = $_SESSION['wpsc_delivery_country'];
692
+ if ($args['dest_ccode'] == "UK"){
693
+ // So, UPS is a little off the times
694
+ $args['dest_ccode'] = "GB";
695
+ }
696
+
697
+ // If ths zip code is provided via a form post use it!
698
+ if(isset($_POST['zipcode']) && ($_POST['zipcode'] != "Your Zipcode" && $_POST['zipcode'] != "YOURZIPCODE")) {
699
+ $args['dest_pcode'] = $_POST['zipcode'];
700
+ $_SESSION['wpsc_zipcode'] = $_POST['zipcode'];
701
+ } else if(isset($_SESSION['wpsc_zipcode']) && ($_POST['zipcode'] != "Your Zipcode" && $_POST['zipcode'] != "YOURZIPCODE")) {
702
+ // Well, we have a zip code in the session and no new one provided
703
+ $args['dest_pcode'] = $_SESSION['wpsc_zipcode'];
704
+ }else{
705
+ // We cannot get a quote without a zip code so might as well return!
706
+ return array();
707
+ }
708
+
709
+ // If the region code is provided via a form post use it!
710
+ if(isset($_POST['region']) && !empty($_POST['region'])) {
711
+ $query ="SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`
712
+ WHERE `".WPSC_TABLE_REGION_TAX."`.`id` = '".$_POST['region']."'";
713
+ $dest_region_data = $wpdb->get_results($query, ARRAY_A);
714
+ $args['dest_state'] = (is_array($dest_region_data)) ? $dest_region_data[0]['code'] : "";
715
+ $_SESSION['wpsc_state'] = $args['dest_state'];
716
+ } else if(isset($_SESSION['wpsc_state'])) {
717
+ // Well, we have a zip code in the session and no new one provided
718
+ $args['dest_state'] = $_SESSION['wpsc_state'];
719
+ } else{
720
+ $args['dest_state'] = "";
721
+ }
722
+
723
+ $shipping_cache_check['state'] = $args['dest_state'];
724
+ $shipping_cache_check['zipcode'] = $args['dest_pcode'];
725
+ $shipping_cache_check['weight'] = $args['weight'];
726
+
727
+ // This is where shipping breaks out of UPS if weight is higher than 150 LBS
728
+ if($weight > 150){
729
+ unset($_SESSION['quote_shipping_method']);
730
+ $shipping_quotes[TXT_WPSC_OVER_UPS_WEIGHT] = 0;
731
+ $_SESSION['wpsc_shipping_cache_check']['weight'] = $args['weight'];
732
+ $_SESSION['wpsc_shipping_cache'][$this->internal_name] = $shipping_quotes;
733
+ $_SESSION['quote_shipping_method'] = $this->internal_name;
734
+ return array($shipping_quotes);
735
+ }
736
+
737
+ // We do not want to spam UPS (and slow down our process) if we already
738
+ // have a shipping quote!
739
+ if(($_SESSION['wpsc_shipping_cache_check'] === $shipping_cache_check)
740
+ && ($_SESSION['wpsc_shipping_cache'][$this->internal_name] != null)) {
741
+
742
+ $rate_table = $_SESSION['wpsc_shipping_cache'][$this->internal_name];
743
+ return $rate_table;
744
+ }else{
745
+ // Build the XML request
746
+ $request = $this->_buildRateRequest($args);
747
+ //$file = fopen('logs/ups.request.'.time().'.log', 'w');
748
+ //fwrite($file, $request."\n");
749
+ // Now that we have the message to send ... Send it!
750
+ $raw_quote = $this->_makeRateRequest($request);
751
+ // Now we have the UPS response .. unfortunately its not ready
752
+ // to be viewed by normal humans ...
753
+ $quotes = $this->_parseQuote($raw_quote);
754
+ // $file = fopen('logs/ups.response.'.time().'.log', 'w');
755
+ // fwrite($file, $raw_quote."\n");
756
+ // If we actually have rates back from UPS we can use em!
757
+ if ($quotes != false){
758
+ $rate_table = $this->_formatTable($quotes,$args['currency']);
759
  }else{
760
+ if ($wpsc_ups_settings['upsenvironment'] == '1' && 'true' == WP_DEBUG){
761
+ echo "<strong>:: GetQuote ::DEBUG OUTPUT::</strong><br />";
762
+ echo "Arguments sent to UPS";
763
+ print_r($args);
764
+ echo "Response from UPS";
765
+ echo $raw_quote;
766
+ echo "</strong>:: GetQuote ::End DEBUG OUTPUT::";
 
 
 
767
  }
768
  }
 
 
 
 
 
769
  }
770
+
771
+ $_SESSION['wpsc_shipping_cache_check']['state'] = $args['dest_state'];
772
+ $_SESSION['wpsc_shipping_cache_check']['zipcode'] = $args['dest_pcode'];
773
+ $_SESSION['wpsc_shipping_cache_check']['weight'] = $args['weight'];
774
+ $_SESSION['wpsc_shipping_cache'][$this->internal_name] = $rate_table;
775
+ // return the final formatted array !
776
+ return $rate_table;
777
+ }
778
 
779
+ // Empty Function, this exists just b/c it is prototyped elsewhere
780
+ function get_item_shipping(){
781
+ }
782
  }
783
  $ups = new ups();
784
  $wpsc_shipping_modules[$ups->getInternalName()] = $ups;
785
+ ?>
wpsc-shipping/ups_data.php DELETED
@@ -1,110 +0,0 @@
1
- <?php
2
- $eol = "\n";
3
- /*############################################################################*\
4
- | * XML chunk that must be appended to ALL outgoing requests to the UPS server*|
5
- | * Fields are *|
6
- | * - AccessLicenseNumber aka $wpsc_ups_settings['upsemail'] *|
7
- | * - UserId aka $wpsc_ups_settings['upsid'] *|
8
- | * - Password aka $wpsc_ups_settings['upspassword'] *|
9
- \*############################################################################*/
10
- $Auth = $eol."<AccessRequest xml:lang='en-US'>".$eol."
11
- <AccessLicenseNumber>".$eol."
12
- %s".$eol."
13
- </AccessLicenseNumber>".$eol."
14
- <UserId>".$eol."
15
- %s".$eol."
16
- </UserId>".$eol."
17
- <Password>".$eol."
18
- %s".$eol."
19
- </Password>".$eol."
20
- </AccessRequest>".$eol;
21
- /*############################################################################*\
22
- | * Start the XML Message and Include the AUTH PART !!! ($auth) | * *|
23
- \*############################################################################*/
24
-
25
- $MessageStart = "<?xml version=\"1.0\"?>".$Auth;
26
-
27
- /*############################################################################*\
28
- | * XML request body *|
29
- \*############################################################################*/
30
- $RateRequest = ("<RatingServiceSelectionRequest xml:lang=\"en-US\">".$eol."
31
- <Request>".$eol."
32
- <TransactionReference>".$eol."
33
- <CustomerContext>Rate Request</CustomerContext>".$eol."
34
- <XpciVersion>1.0</XpciVersion>".$eol."
35
- </TransactionReference>".$eol."
36
- <RequestAction>%s</RequestAction>".$eol."
37
- <RequestOption>%s</RequestOption>".$eol."
38
- </Request>".$eol."
39
- <Shipment>".$eol."
40
- <Shipper>".$eol."
41
- <Address>".$eol."
42
- <PostalCode>%s</PostalCode>".$eol."
43
- <CountryCode>%s</CountryCode>".$eol."
44
- </Address>".$eol."
45
- </Shipper>".$eol."
46
- <ShipTo>".$eol."
47
- <Address>".$eol."
48
- <PostalCode>%s</PostalCode>".$eol."
49
- <CountryCode>%s</CountryCode>".$eol."
50
- </Address>".$eol."
51
- </ShipTo>".$eol);
52
- $RateService = ("<Service>".$eol."
53
- <Code>%s</Code>".$eol."
54
- </Service>".$eol);
55
- $RatePackage = ("<Package>".$eol."
56
- <PackagingType>".$eol."
57
- <Code>%s</Code>".$eol."
58
- </PackagingType>".$eol);
59
-
60
- $RateCustomPackage = ("<dimensions>".$eol."
61
- <UnitOfMeasurement>".$eol."
62
- <Code>%s</Code>".$eol."
63
- </UnitOfMeasurement>".$eol."
64
- <Length>%s</Length>".$eol."
65
- <Width>%s</Width>".$eol."
66
- <Height>%s</Height>".$eol."
67
- </dimensions>");
68
-
69
- $RateRequestEnd = ("<PackageWeight>".$eol."
70
- <UnitOfMeasurement>".$eol."
71
- <Code>%s</Code>".$eol."
72
- </UnitOfMeasurement>".$eol."
73
- <Weight>%s</Weight>".$eol."
74
- </PackageWeight>".$eol."
75
- <PackageServiceOptions>".$eol."
76
- <InsuredValue>".$eol."
77
- <MonetaryValue>%s</MonetaryValue>".$eol."
78
- </InsuredValue>".$eol."
79
- </PackageServiceOptions>".$eol."
80
-
81
- </Package>".$eol."
82
- </Shipment>".$eol."
83
- </RatingServiceSelectionRequest>".$eol);
84
- /*############################################################################*\
85
- | * Array of countries (and US-domestic) to list the services available *|
86
- \*############################################################################*/
87
- $Services = array(
88
- "14" => "Next Day Air Early AM",
89
- "01" => "Next Day Air",
90
- "13" => "Next Day Air Saver",
91
- "59" => "2nd Day Air AM",
92
- "02" => "2nd Day Air",
93
- "12" => "3 Day Select",
94
- "03" => "Ground",
95
- "11" => "Standard",
96
- "07" => "Worldwide Express",
97
- "54" => "Worldwide Express Plus",
98
- "08" => "Worldwide Expedited",
99
- "65" => "Saver",
100
- "82" => "UPS Today Standard",
101
- "83" => "UPS Today Dedicated Courier",
102
- "84" => "UPS Today Intercity",
103
- "85" => "UPS Today Express",
104
- "86" => "UPS Today Express Saver"
105
- );
106
-
107
- return array($eol, $Auth, $MessageStart, $RateRequest, $RateService,
108
- $RatePackage, $RateCustomPackage, $RateRequestEnd,
109
- $Services);
110
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-taxes/controllers/taxes_controller.class.php CHANGED
@@ -50,7 +50,7 @@ class wpec_taxes_controller {
50
  //check if tax is enabled
51
  if ( $this->wpec_taxes->wpec_taxes_get_enabled() ) {
52
  //get base country code
53
- $wpec_base_country = get_option( 'base_country' );
54
 
55
  //run tax logic and calculate tax
56
  if ( $this->wpec_taxes_run_logic() ) {
@@ -73,12 +73,12 @@ class wpec_taxes_controller {
73
  $returnable = array( 'total' => $total_tax );
74
  } else {
75
  //check if there are any rates setup for the base_country
76
- if ( $this->wpec_taxes_rate_exists( $wpec_base_country ) ) {
77
  //calculate subtotal for the items
78
  $taxable_total = $wpsc_cart->calculate_subtotal();
79
 
80
  //get the rate for the country and region if set
81
- $tax_rate = $this->wpec_taxes->wpec_taxes_get_rate( $wpec_base_country, $region );
82
 
83
  //is the region configured to apply tax on shipping? if so add shipping price to the taxable total
84
  if ( $tax_rate['shipping'] ) {
@@ -86,7 +86,7 @@ class wpec_taxes_controller {
86
  }// if
87
  //calculate tax
88
  $returnable = array( 'total' => $this->wpec_taxes_calculate_tax( $taxable_total, $tax_rate['rate'] ), 'rate' => $tax_rate['rate'] );
89
- }// if
90
  }// if
91
  }// if
92
  } //if
@@ -94,6 +94,23 @@ class wpec_taxes_controller {
94
  return $returnable;
95
  } // wpec_taxes_calculate_total
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  /**
98
  * @description: wpec_taxes_run_logic - runs the tax logic as defined in the taxes settings page.
99
  * returns true or false depending on whether taxes can be calculated.
@@ -104,30 +121,8 @@ class wpec_taxes_controller {
104
  function wpec_taxes_run_logic() {
105
  //initalize variables
106
  global $wpsc_cart;
107
- $wpec_base_country = get_option( 'base_country' );
108
 
109
- //check the tax logic. Is the tax applied to the billing country or shipping country or to both?
110
- switch ( $this->wpec_taxes->wpec_taxes_get_logic() ) {
111
- case 'billing_shipping':
112
- if ( ($wpsc_cart->selected_country == $wpec_base_country) && ($wpsc_cart->delivery_country == $wpec_base_country) ) {
113
- $returnable = true;
114
- }
115
- break;
116
- case 'billing':
117
- if ( $wpsc_cart->selected_country == $wpec_base_country ) {
118
- $returnable = true;
119
- }
120
- break;
121
- case 'shipping':
122
- if ( $wpsc_cart->delivery_country == $wpec_base_country ) {
123
- $returnable = true;
124
- }
125
- break;
126
- default:
127
- $returnable = false;
128
- }// switch
129
-
130
- return $returnable;
131
  } // wpec_taxes_run_logic
132
 
133
  /**
@@ -263,7 +258,7 @@ class wpec_taxes_controller {
263
  $returnable = false;
264
 
265
  if ( $this->wpec_taxes_run_logic() ) {
266
- $wpec_base_country = get_option( 'base_country' );
267
  $region = $this->wpec_taxes_retrieve_region();
268
 
269
  //get the tax percentage rate
@@ -293,7 +288,7 @@ class wpec_taxes_controller {
293
 
294
  if ( $this->wpec_taxes_isincluded() ) {
295
  //get the base country
296
- $wpec_base_country = get_option( 'base_country' );
297
 
298
  //get the region
299
  $region = $this->wpec_taxes_retrieve_region();
50
  //check if tax is enabled
51
  if ( $this->wpec_taxes->wpec_taxes_get_enabled() ) {
52
  //get base country code
53
+ $wpec_selected_country = $this->wpec_taxes_retrieve_selected_country();
54
 
55
  //run tax logic and calculate tax
56
  if ( $this->wpec_taxes_run_logic() ) {
73
  $returnable = array( 'total' => $total_tax );
74
  } else {
75
  //check if there are any rates setup for the base_country
76
+ // if ( $this->wpec_taxes_rate_exists( $wpec_base_country ) ) {
77
  //calculate subtotal for the items
78
  $taxable_total = $wpsc_cart->calculate_subtotal();
79
 
80
  //get the rate for the country and region if set
81
+ $tax_rate = $this->wpec_taxes->wpec_taxes_get_rate( $wpec_selected_country, $region );
82
 
83
  //is the region configured to apply tax on shipping? if so add shipping price to the taxable total
84
  if ( $tax_rate['shipping'] ) {
86
  }// if
87
  //calculate tax
88
  $returnable = array( 'total' => $this->wpec_taxes_calculate_tax( $taxable_total, $tax_rate['rate'] ), 'rate' => $tax_rate['rate'] );
89
+ // }// if
90
  }// if
91
  }// if
92
  } //if
94
  return $returnable;
95
  } // wpec_taxes_calculate_total
96
 
97
+
98
+ function wpec_taxes_retrieve_selected_country(){
99
+ global $wpsc_cart;
100
+ switch ( $this->wpec_taxes->wpec_taxes_get_logic() ) {
101
+ case 'billing_shipping':
102
+ return $wpsc_cart->selected_country;
103
+ break;
104
+ case 'billing':
105
+ return $wpsc_cart->selected_country;
106
+ break;
107
+ case 'shipping':
108
+ return $wpsc_cart->delivery_country;
109
+ break;
110
+ default:
111
+ $returnable = false;
112
+ }// switch
113
+ }
114
  /**
115
  * @description: wpec_taxes_run_logic - runs the tax logic as defined in the taxes settings page.
116
  * returns true or false depending on whether taxes can be calculated.
121
  function wpec_taxes_run_logic() {
122
  //initalize variables
123
  global $wpsc_cart;
124
+ return true;
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  } // wpec_taxes_run_logic
127
 
128
  /**
258
  $returnable = false;
259
 
260
  if ( $this->wpec_taxes_run_logic() ) {
261
+ $wpec_base_country = $this->wpec_taxes_retrieve_selected_country();
262
  $region = $this->wpec_taxes_retrieve_region();
263
 
264
  //get the tax percentage rate
288
 
289
  if ( $this->wpec_taxes_isincluded() ) {
290
  //get the base country
291
+ $wpec_base_country = wpec_taxes_retrieve_selected_country();
292
 
293
  //get the region
294
  $region = $this->wpec_taxes_retrieve_region();
wpsc-theme/functions/wpsc-transaction_results_functions.php CHANGED
@@ -10,6 +10,8 @@
10
  */
11
  function wpsc_transaction_theme() {
12
  global $wpdb, $user_ID, $nzshpcrt_gateways, $sessionid, $cart_log_id, $errorcode;
 
 
13
 
14
  if ( isset( $_GET['sessionid'] ) )
15
  $sessionid = $_GET['sessionid'];
@@ -17,55 +19,67 @@ function wpsc_transaction_theme() {
17
  if ( !isset( $_GET['sessionid'] ) && isset( $_GET['ms'] ) )
18
  $sessionid = $_GET['ms'];
19
 
20
- if ( isset( $_GET['gateway'] ) && $_GET['gateway'] == 'google' ) {
21
  wpsc_google_checkout_submit();
22
  unset( $_SESSION['wpsc_sessionid'] );
23
- } elseif ( isset( $_GET['gateway'] ) && $_GET['gateway'] == 'noca' ) {
24
- wpsc_submit_checkout();
25
  }
 
 
26
 
27
- if ( $_SESSION['wpsc_previous_selected_gateway'] == 'paypal_certified' )
28
  $sessionid = $_SESSION['paypalexpresssessionid'];
29
 
30
- //exit("test!");
31
- $errorcode = '';
32
- $transactid = '';
33
-
34
- if ( isset( $_REQUEST['eway'] ) && $_REQUEST['eway'] == '1' )
35
  $sessionid = $_GET['result'];
36
- elseif ( isset( $_REQUEST['eway'] ) && $_REQUEST['eway'] == '0' )
37
  echo $_SESSION['eway_message'];
38
- elseif ( isset( $_REQUEST['payflow'] ) && $_REQUEST['payflow'] == '1' ){
39
  echo $_SESSION['payflow_message'];
40
  $_SESSION['payflow_message'] = '';
41
  }
42
-
43
- if (($_SESSION['wpsc_previous_selected_gateway'] == 'paypal_certified' || $_SESSION['wpsc_previous_selected_gateway'] == 'wpsc_merchant_paypal_express') && ($_SESSION['reshash']['ACK'] != 'Completed') && ( $_SESSION['reshash']['ACK'] != 'Success')) {
44
- echo $_SESSION['paypalExpressMessage'];
45
- } else {
46
- if ( $_SESSION['wpsc_previous_selected_gateway'] == 'dps' ) {
 
 
 
 
 
47
  $sessionid = decrypt_dps_response();
48
- //exit($sessionid);
49
- if ( $sessionid != '' )
50
- return transaction_results( $sessionid, true );
51
- else
52
- _e( 'Sorry your transaction was not accepted.<br /><a href=' . get_option( "shopping_cart_url" ) . '>Click here to go back to checkout page.</a>' );
53
-
54
- } else {
55
- //exit('<pre>sess - '.print_r($_SESSION, true).'</pre>');
56
- return transaction_results( $sessionid, true );
57
- }
58
- $cart_log_id = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1" );
59
  }
 
 
 
 
 
 
 
 
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
62
  function transaction_results( $sessionid, $echo_to_screen = true, $transaction_id = null ) {
63
- global $wpdb, $wpsc_cart, $echo_to_screen, $purchase_log, $order_url, $message_html, $cart, $errorcode,$wpsc_purchlog_statuses;
 
 
 
64
  $is_transaction = false;
65
- $curgateway = $wpdb->get_var( "SELECT gateway FROM " . WPSC_TABLE_PURCHASE_LOGS . " WHERE sessionid='$sessionid'" );
66
  $errorcode = 0;
 
67
  $order_status = $purchase_log['processed'];
68
-
69
  if( !is_bool( $echo_to_screen ) )
70
  $echo_to_screen = true;
71
 
@@ -73,26 +87,24 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
73
 
74
  if ( $echo_to_screen )
75
  echo apply_filters( 'wpsc_pre_transaction_results', '' );
 
 
 
76
 
77
- $purchase_log = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1", ARRAY_A );
78
- foreach($wpsc_purchlog_statuses as $status)
79
- if($status['order'] == $purchase_log['processed'] && isset($status['is_transaction']) && 1 == $status['is_transaction'] )
80
- $is_transaction = true;
81
-
82
-
83
-
84
- if ( ($purchase_log['gateway'] == "wpsc_merchant_testmode") && ($purchase_log['processed'] < 3) ) {
85
  $message = stripslashes( __('Thank you, your purchase is pending, you will be sent an email once the order clears. All prices include tax and postage and packaging where applicable. You ordered these items:%product_list%%total_shipping%%total_price%', 'wpsc') );
86
  $message_html = __('Thank you, your purchase is pending, you will be sent an email once the order clears. All prices include tax and postage and packaging where applicable. You ordered these items:%product_list%%total_shipping%%total_price%', 'wpsc');
87
  } else {
 
 
88
  $message = stripslashes( get_option( 'wpsc_email_receipt' ) );
89
  $message_html = $message;
90
  }
91
- $order_url = site_url( "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php&amp;purchcaseid=" . $purchase_log['id'] );
92
-
93
  // Checks for PayPal IPN
94
- if ( (!isset( $_GET['ipn_request'] ) || $_GET['ipn_request'] != 'true') &&
95
- ((get_option( 'paypal_ipn' ) == 1) && ($purchase_log['gateway'] == 'wpsc_merchant_paypal_standard')) ) {
96
 
97
  if ( $purchase_log == null ) {
98
 
@@ -107,30 +119,29 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
107
  return;
108
  }
109
  }
110
- $cart = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`='{$purchase_log['id']}'", ARRAY_A );
111
-
112
- if ( $purchase_log['shipping_country'] != '' ) {
113
  $billing_country = $purchase_log['billing_country'];
114
  $shipping_country = $purchase_log['shipping_country'];
115
  } else {
116
  $country = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $purchase_log['id'] . " AND `form_id` = '" . get_option( 'country_form_field' ) . "' LIMIT 1" );
 
117
  $billing_country = $country;
118
  $shipping_country = $country;
119
  }
120
 
121
- $email_form_field = $wpdb->get_results( "SELECT `id`,`type` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `order` ASC LIMIT 1", ARRAY_A );
122
- $email = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $purchase_log['id'] . " AND `form_id` = '" . $email_form_field[0]['id'] . "' LIMIT 1" );
123
- $stock_adjusted = false;
124
  $previous_download_ids = array( 0 );
125
  $product_list = $product_list_html = '';
 
 
126
 
127
  if ( ($cart != null) && ($errorcode == 0) ) {
128
-
 
129
  foreach ( $cart as $row ) {
130
- $link = "";
131
- if ( $purchase_log['email_sent'] != 1 ) {
132
  $wpdb->query( "UPDATE `" . WPSC_TABLE_DOWNLOAD_STATUS . "` SET `active`='1' WHERE `cartid` = '{$row['id']}' AND `purchid` = '{$purchase_log['id']}'" );
133
- }
134
 
135
  do_action( 'wpsc_transaction_result_cart_item', array( "purchase_id" => $purchase_log['id'], "cart_item" => $row, "purchase_log" => $purchase_log ) );
136
 
@@ -142,19 +153,16 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
142
  AND `purchid`='" . $purchase_log['id'] . "'
143
  AND `cartid` = '" . $row['id'] . "'", ARRAY_A );
144
 
145
- $link = array( );
146
-
147
  if ( count( $download_data ) > 0 ) {
148
  foreach ( $download_data as $single_download ) {
149
  $file_data = get_post( $single_download['product_id'] );
150
-
151
- if ( $single_download['uniqueid'] == null ) {// if the uniqueid is not equal to null, its "valid", regardless of what it is
152
  $link[] = array( "url" => site_url( "?downloadid=" . $single_download['id'] ), "name" => $file_data->post_title );
153
- } else {
154
  $link[] = array( "url" => site_url( "?downloadid=" . $single_download['uniqueid'] ), "name" => $file_data->post_title );
155
- }
156
  }
157
- //$order_status= 4;
158
  } else {
159
  $order_status = $purchase_log['processed'];
160
  }
@@ -162,7 +170,7 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
162
  }
163
 
164
  do_action( 'wpsc_confirm_checkout', $purchase_log['id'] );
165
- $total_shipping = '';
166
  $total = '';
167
  $shipping = $row['pnp'] * $row['quantity'];
168
  $total_shipping += $shipping;
@@ -173,10 +181,9 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
173
 
174
  $shipping_price = wpsc_currency_display( $shipping, array( 'display_as_html' => false ) );
175
 
176
- if ( isset( $purchase['gateway'] ) && $purchase['gateway'] != 'wpsc_merchant_testmode' ) {
177
- if ( $gateway['internalname'] == $purch_data[0]['gateway'] ) {
178
  $gateway_name = $gateway['name'];
179
- }
180
  } else {
181
  $gateway_name = "Manual Payment";
182
  }
@@ -197,11 +204,7 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
197
  $product_list .= $additional_content;
198
  $product_list_html .= $additional_content;
199
  } else {
200
-
201
- $plural = '';
202
- if ( $row['quantity'] > 1 ) {
203
- $plural = "s";
204
- }
205
  $product_list.= " - " . $row['quantity'] . " " . $row['name'] . " " . $message_price . "\n\r";
206
  if ( $shipping > 0 )
207
  $product_list .= " - " . __( 'Shipping', 'wpsc' ) . ":" . $shipping_price . "\n\r";
@@ -212,14 +215,13 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
212
  $report = get_option( 'wpsc_email_admin' );
213
  $report_product_list = '';
214
  $report_product_list.= " - " . $row['name'] . " " . $message_price . "\n\r";
215
- }
216
 
217
  // Decrement the stock here
218
- if ( $is_transaction ) {
219
  wpsc_decrement_claimed_stock( $purchase_log['id'] );
220
- }
221
 
222
- if ( $purchase_log['discount_data'] != '' ) {
223
  $coupon_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE coupon_code='" . $wpdb->escape( $purchase_log['discount_data'] ) . "' LIMIT 1", ARRAY_A );
224
  if ( $coupon_data['use-once'] == 1 ) {
225
  $wpdb->query( "UPDATE `" . WPSC_TABLE_COUPON_CODES . "` SET `active`='0', `is-used`='1' WHERE `id`='" . $coupon_data['id'] . "' LIMIT 1" );
@@ -229,10 +231,8 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
229
  $total_shipping += $purchase_log['base_shipping'];
230
 
231
  $total = $purchase_log['totalprice'];
232
- // echo $total;
233
- // $message.= "\n\r";
234
- $product_list.= "Your Purchase No.: " . $purchase_log['id'] . "\n\r";
235
- $product_list_html.= "Your Purchase No.: " . $purchase_log['id'] . "<BR/>\n\r";
236
  if ( $purchase_log['discount_value'] > 0 ) {
237
  $discount_email.= __( 'Discount', 'wpsc' ) . "\n\r: ";
238
  $discount_email .=$purchase_log['discount_data'] . ' : ' . wpsc_currency_display( $purchase_log['discount_value'], array( 'display_as_html' => false ) ) . "\n\r";
@@ -257,7 +257,7 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
257
  $message_html.= "\n\r" . __( 'Your Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
258
  $report.= "\n\r" . __( 'Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
259
  } else {
260
- $report_id = "Purchase No.: " . $purchase_log['id'] . "\n\r";
261
  }
262
 
263
  $message = str_replace( '%product_list%', $product_list, $message );
@@ -278,12 +278,12 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
278
  $message_html = str_replace( '%shop_name%', get_option( 'blogname' ), $message_html );
279
  $message_html = str_replace( '%find_us%', $purchase_log['find_us'], $message_html );
280
 
281
- if ( ($email != '') && ($purchase_log['email_sent'] != 1) ) {
282
 
283
  add_filter( 'wp_mail_from', 'wpsc_replace_reply_address', 0 );
284
  add_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name', 0 );
285
 
286
- if ( $purchase_log['processed'] < 3 ) {
287
  $payment_instructions = strip_tags( stripslashes( get_option( 'payment_instructions' ) ) );
288
  $message = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . "\n\r" . $message;
289
  wp_mail( $email, __( 'Order Pending: Payment Required', 'wpsc' ), $message );
@@ -298,23 +298,32 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
298
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = '" . $purchase_log['id'] . "'";
299
  $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
300
 
 
 
301
  if ( $form_data != null ) {
302
  foreach ( $form_data as $form_field ) {
303
  $form_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `id` = '" . $form_field['form_id'] . "' LIMIT 1", ARRAY_A );
304
-
305
  switch ( $form_data['type'] ) {
306
  case "country":
307
- $report_user .= $form_data['name'] . ": " . wpsc_get_country( $form_field['value'] ) . "\n";
308
- $report_user .= __( 'State', 'wpsc' ) . ": " . wpsc_get_region( $purchase_log['billing_region'] ) . "\n";
 
 
 
 
309
  break;
310
 
311
  case "delivery_country":
312
- $report_user .= $form_data['name'] . ": " . wpsc_get_country( $form_field['value'] ) . "\n";
313
- $report_user .= __( 'Delivery State', 'wpsc' ) . ": " . wpsc_get_region( $purchase_log['shipping_region'] ) . "\n";
314
  break;
315
-
316
  default:
 
 
 
317
  $report_user .= wp_kses( $form_data['name'], array( ) ) . ": " . $form_field['value'] . "\n";
 
318
  break;
319
  }
320
  }
@@ -323,28 +332,14 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
323
  $report_user .= "\n\r";
324
  $report = $report_user . $report_id . $report;
325
 
326
- if ( $stock_adjusted == true ) {
327
- $wpdb->query( "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `stock_adjusted` = '1' WHERE `sessionid` = " . $sessionid . " LIMIT 1" );
328
- }
329
-
330
- if ( (get_option( 'purch_log_email' ) != null) && ($purchase_log['email_sent'] != 1) ) {
331
-
332
  wp_mail( get_option( 'purch_log_email' ), __( 'Purchase Report', 'wpsc' ), $report );
333
- }
334
- $wpsc_cart->submit_stock_claims( $purchase_log['id'] );
335
 
336
- /// Empty the cart
 
337
  $wpsc_cart->empty_cart();
338
  }
339
-
340
- if ( ($purchase_log['email_sent'] != 1) and ($sessionid != '') ) {
341
- if ( preg_match( "/^[\w\s._,-]+$/", $transaction_id ) ) {
342
- $transact_id_sql = "`transactid` = '" . $transaction_id . "',";
343
- }
344
- // $update_sql = "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET $transact_id_sql `email_sent` = '1', `processed` = '$order_status' WHERE `sessionid` = " . $sessionid . " LIMIT 1";
345
- // $wpdb->query( $update_sql );
346
- }
347
  }
348
  }
349
 
350
- ?>
10
  */
11
  function wpsc_transaction_theme() {
12
  global $wpdb, $user_ID, $nzshpcrt_gateways, $sessionid, $cart_log_id, $errorcode;
13
+ $errorcode = '';
14
+ $transactid = '';
15
 
16
  if ( isset( $_GET['sessionid'] ) )
17
  $sessionid = $_GET['sessionid'];
19
  if ( !isset( $_GET['sessionid'] ) && isset( $_GET['ms'] ) )
20
  $sessionid = $_GET['ms'];
21
 
22
+ if ( isset( $_GET['gateway'] ) && 'google' == $_GET['gateway'] ) {
23
  wpsc_google_checkout_submit();
24
  unset( $_SESSION['wpsc_sessionid'] );
 
 
25
  }
26
+ if ( isset( $_GET['gateway'] ) && 'noca' == $_GET['gateway'] )
27
+ wpsc_submit_checkout();
28
 
29
+ if ( 'paypal_certified' == $_SESSION['wpsc_previous_selected_gateway'] )
30
  $sessionid = $_SESSION['paypalexpresssessionid'];
31
 
32
+ if ( isset( $_REQUEST['eway'] ) && '1' == $_REQUEST['eway'] )
 
 
 
 
33
  $sessionid = $_GET['result'];
34
+ elseif ( isset( $_REQUEST['eway'] ) && '0' == $_REQUEST['eway'] )
35
  echo $_SESSION['eway_message'];
36
+ elseif ( isset( $_REQUEST['payflow'] ) && '1' == $_REQUEST['payflow'] ){
37
  echo $_SESSION['payflow_message'];
38
  $_SESSION['payflow_message'] = '';
39
  }
40
+
41
+ // Replaces the ugly if else for gateways
42
+ switch($_SESSION['wpsc_previous_selected_gateway']){
43
+ case 'paypal_certified':
44
+ case 'wpsc_merchant_paypal_express':
45
+ if(($_SESSION['reshash']['ACK'] != 'Completed') && ( $_SESSION['reshash']['ACK'] != 'Success')) {
46
+ echo $_SESSION['paypalExpressMessage'];
47
+ }
48
+ break;
49
+ case 'dps':
50
  $sessionid = decrypt_dps_response();
51
+ break;
 
 
 
 
 
 
 
 
 
 
52
  }
53
+
54
+ if ( $sessionid != '' )
55
+ return transaction_results( $sessionid, true );
56
+ else
57
+ _e( 'Sorry your transaction was not accepted.<br /><a href=' . get_option( "shopping_cart_url" ) . '>Click here to go back to checkout page.</a>' );
58
+
59
+ $cart_log_id = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1" );
60
+
61
  }
62
 
63
+
64
+ /**
65
+ * transaction_results function main function for creating the purchase reports, transaction results page, and email receipts
66
+ * @access public
67
+ *
68
+ * @since 3.7
69
+ * @param $sessionid (string) unique session id
70
+ * @param echo_to_screen (boolean) whether to output the results or return them (potentially redundant)
71
+ * @param $transaction_id (int) the transaction id
72
+ */
73
  function transaction_results( $sessionid, $echo_to_screen = true, $transaction_id = null ) {
74
+ // Do we seriously need this many globals?
75
+ global $wpdb, $wpsc_cart, $echo_to_screen, $purchase_log, $order_url;
76
+ global $message_html, $cart, $errorcode,$wpsc_purchlog_statuses, $wpsc_gateways;
77
+
78
  $is_transaction = false;
 
79
  $errorcode = 0;
80
+ $purchase_log = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1", ARRAY_A );
81
  $order_status = $purchase_log['processed'];
82
+ $curgateway = $purchase_log['gateway'];
83
  if( !is_bool( $echo_to_screen ) )
84
  $echo_to_screen = true;
85
 
87
 
88
  if ( $echo_to_screen )
89
  echo apply_filters( 'wpsc_pre_transaction_results', '' );
90
+
91
+ // New code to check whether transaction is processed, true if accepted false if pending or incomplete
92
+ $is_transaction = wpsc_check_purchase_processed($purchase_log['processed']);
93
 
94
+ if ( (( "wpsc_merchant_testmode" == $purchase_log['gateway'] ) && (!$is_transaction) ) || !$is_transaction) {
 
 
 
 
 
 
 
95
  $message = stripslashes( __('Thank you, your purchase is pending, you will be sent an email once the order clears. All prices include tax and postage and packaging where applicable. You ordered these items:%product_list%%total_shipping%%total_price%', 'wpsc') );
96
  $message_html = __('Thank you, your purchase is pending, you will be sent an email once the order clears. All prices include tax and postage and packaging where applicable. You ordered these items:%product_list%%total_shipping%%total_price%', 'wpsc');
97
  } else {
98
+ if( $is_transaction )
99
+ _e('The Transaction was successful', 'wpsc')."<br />";
100
  $message = stripslashes( get_option( 'wpsc_email_receipt' ) );
101
  $message_html = $message;
102
  }
103
+
104
+ $order_url = site_url( "/wp-admin/admin.php?page=wpsc-sales-logs&purchaselog_id=" . $purchase_log['id'] );
105
  // Checks for PayPal IPN
106
+ if ( (!isset( $_GET['ipn_request'] ) || 'true' != $_GET['ipn_request'])
107
+ && ((get_option( 'paypal_ipn' ) == 1) && ('wpsc_merchant_paypal_standard' == $purchase_log['gateway'] )) ) {
108
 
109
  if ( $purchase_log == null ) {
110
 
119
  return;
120
  }
121
  }
122
+ if ( !empty($purchase_log['shipping_country']) ) {
 
 
123
  $billing_country = $purchase_log['billing_country'];
124
  $shipping_country = $purchase_log['shipping_country'];
125
  } else {
126
  $country = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $purchase_log['id'] . " AND `form_id` = '" . get_option( 'country_form_field' ) . "' LIMIT 1" );
127
+
128
  $billing_country = $country;
129
  $shipping_country = $country;
130
  }
131
 
132
+ $email = wpsc_get_buyers_email($purchase_log['id']);
 
 
133
  $previous_download_ids = array( 0 );
134
  $product_list = $product_list_html = '';
135
+
136
+ $cart = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`='{$purchase_log['id']}'", ARRAY_A );
137
 
138
  if ( ($cart != null) && ($errorcode == 0) ) {
139
+ $link = array( );
140
+ $total_shipping = '';
141
  foreach ( $cart as $row ) {
142
+
143
+ if ( $purchase_log['email_sent'] != 1 )
144
  $wpdb->query( "UPDATE `" . WPSC_TABLE_DOWNLOAD_STATUS . "` SET `active`='1' WHERE `cartid` = '{$row['id']}' AND `purchid` = '{$purchase_log['id']}'" );
 
145
 
146
  do_action( 'wpsc_transaction_result_cart_item', array( "purchase_id" => $purchase_log['id'], "cart_item" => $row, "purchase_log" => $purchase_log ) );
147
 
153
  AND `purchid`='" . $purchase_log['id'] . "'
154
  AND `cartid` = '" . $row['id'] . "'", ARRAY_A );
155
 
 
 
156
  if ( count( $download_data ) > 0 ) {
157
  foreach ( $download_data as $single_download ) {
158
  $file_data = get_post( $single_download['product_id'] );
159
+ // if the uniqueid is not equal to null, its "valid", regardless of what it is
160
+ if ( $single_download['uniqueid'] == null )
161
  $link[] = array( "url" => site_url( "?downloadid=" . $single_download['id'] ), "name" => $file_data->post_title );
162
+ else
163
  $link[] = array( "url" => site_url( "?downloadid=" . $single_download['uniqueid'] ), "name" => $file_data->post_title );
164
+
165
  }
 
166
  } else {
167
  $order_status = $purchase_log['processed'];
168
  }
170
  }
171
 
172
  do_action( 'wpsc_confirm_checkout', $purchase_log['id'] );
173
+
174
  $total = '';
175
  $shipping = $row['pnp'] * $row['quantity'];
176
  $total_shipping += $shipping;
181
 
182
  $shipping_price = wpsc_currency_display( $shipping, array( 'display_as_html' => false ) );
183
 
184
+ if ( isset( $purchase['gateway'] ) && 'wpsc_merchant_testmode' != $purchase['gateway'] ) {
185
+ if ( $gateway['internalname'] == $purch_data[0]['gateway'] )
186
  $gateway_name = $gateway['name'];
 
187
  } else {
188
  $gateway_name = "Manual Payment";
189
  }
204
  $product_list .= $additional_content;
205
  $product_list_html .= $additional_content;
206
  } else {
207
+
 
 
 
 
208
  $product_list.= " - " . $row['quantity'] . " " . $row['name'] . " " . $message_price . "\n\r";
209
  if ( $shipping > 0 )
210
  $product_list .= " - " . __( 'Shipping', 'wpsc' ) . ":" . $shipping_price . "\n\r";
215
  $report = get_option( 'wpsc_email_admin' );
216
  $report_product_list = '';
217
  $report_product_list.= " - " . $row['name'] . " " . $message_price . "\n\r";
218
+ } // closes foreach cart as row
219
 
220
  // Decrement the stock here
221
+ if ( $is_transaction )
222
  wpsc_decrement_claimed_stock( $purchase_log['id'] );
 
223
 
224
+ if ( !empty($purchase_log['discount_data'])) {
225
  $coupon_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE coupon_code='" . $wpdb->escape( $purchase_log['discount_data'] ) . "' LIMIT 1", ARRAY_A );
226
  if ( $coupon_data['use-once'] == 1 ) {
227
  $wpdb->query( "UPDATE `" . WPSC_TABLE_COUPON_CODES . "` SET `active`='0', `is-used`='1' WHERE `id`='" . $coupon_data['id'] . "' LIMIT 1" );
231
  $total_shipping += $purchase_log['base_shipping'];
232
 
233
  $total = $purchase_log['totalprice'];
234
+ $product_list.= "Your Purchase # " . $purchase_log['id'] . "\n\r";
235
+ $product_list_html.= "Your Purchase # " . $purchase_log['id'] . "<br />\n\r";
 
 
236
  if ( $purchase_log['discount_value'] > 0 ) {
237
  $discount_email.= __( 'Discount', 'wpsc' ) . "\n\r: ";
238
  $discount_email .=$purchase_log['discount_data'] . ' : ' . wpsc_currency_display( $purchase_log['discount_value'], array( 'display_as_html' => false ) ) . "\n\r";
257
  $message_html.= "\n\r" . __( 'Your Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
258
  $report.= "\n\r" . __( 'Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
259
  } else {
260
+ $report_id = "Purchase # " . $purchase_log['id'] . "\n\r";
261
  }
262
 
263
  $message = str_replace( '%product_list%', $product_list, $message );
278
  $message_html = str_replace( '%shop_name%', get_option( 'blogname' ), $message_html );
279
  $message_html = str_replace( '%find_us%', $purchase_log['find_us'], $message_html );
280
 
281
+ if ( !empty($email) && ($purchase_log['email_sent'] != 1) ) {
282
 
283
  add_filter( 'wp_mail_from', 'wpsc_replace_reply_address', 0 );
284
  add_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name', 0 );
285
 
286
+ if ( !$is_transaction ) {
287
  $payment_instructions = strip_tags( stripslashes( get_option( 'payment_instructions' ) ) );
288
  $message = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . "\n\r" . $message;
289
  wp_mail( $email, __( 'Order Pending: Payment Required', 'wpsc' ), $message );
298
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = '" . $purchase_log['id'] . "'";
299
  $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
300
 
301
+ //echo('<pre> form data'.print_r($form_data,true).'</pre>');
302
+
303
  if ( $form_data != null ) {
304
  foreach ( $form_data as $form_field ) {
305
  $form_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `id` = '" . $form_field['form_id'] . "' LIMIT 1", ARRAY_A );
306
+
307
  switch ( $form_data['type'] ) {
308
  case "country":
309
+ $country_code = $form_field['value'];
310
+ $report_user .= $form_data['name'] . ": " . wpsc_get_country( $country_code ) . "\n";
311
+ //check if country has a state then display if it does.
312
+ $country_data = wpsc_country_has_state($country_code);
313
+ if(($country_data['has_regions'] == 1))
314
+ $report_user .= __( 'Billing State', 'wpsc' ) . ": " . wpsc_get_region( $purchase_log['billing_region'] ) . "\n";
315
  break;
316
 
317
  case "delivery_country":
318
+ $report_user .= $form_data['name'] . ": " . wpsc_get_country( $form_field['value'] ) . "\n";
 
319
  break;
320
+
321
  default:
322
+ if ($form_data['name'] == 'State' && is_numeric($form_field['value'])){
323
+ $report_user .= __( 'Delivery State', 'wpsc' ) . ": " . wpsc_get_state_by_id( $form_field['value'], 'name' ) . "\n";
324
+ }else{
325
  $report_user .= wp_kses( $form_data['name'], array( ) ) . ": " . $form_field['value'] . "\n";
326
+ }
327
  break;
328
  }
329
  }
332
  $report_user .= "\n\r";
333
  $report = $report_user . $report_id . $report;
334
 
335
+ if ( (get_option( 'purch_log_email' ) != null) && ($purchase_log['email_sent'] != 1) )
 
 
 
 
 
336
  wp_mail( get_option( 'purch_log_email' ), __( 'Purchase Report', 'wpsc' ), $report );
 
 
337
 
338
+ /// Adjust stock and empty the cart
339
+ $wpsc_cart->submit_stock_claims( $purchase_log['id'] );
340
  $wpsc_cart->empty_cart();
341
  }
 
 
 
 
 
 
 
 
342
  }
343
  }
344
 
345
+ ?>
wpsc-theme/functions/wpsc-user_log_functions.php CHANGED
@@ -37,7 +37,7 @@ function validate_form_data() {
37
 
38
  $any_bad_inputs = false;
39
  $changes_saved = false;
40
-
41
  $_SESSION['collected_data'] = null;
42
 
43
  if ( $_POST['collected_data'] != null ) {
@@ -145,13 +145,15 @@ function wpsc_display_form_fields() {
145
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' ORDER BY `order`;";
146
  $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
147
  foreach ( $form_data as $form_field ) {
148
-
149
  if ( !empty( $form_field['unique_name'] ) ) {
150
  $ff_tag = $form_field['unique_name'];
151
  } else {
152
  $ff_tag = htmlentities( stripslashes( strtolower( str_replace( ' ', '-', $form_field['name'] ) ) ) );
153
  }
154
- $meta_data[$form_field['id']] = htmlentities( stripslashes( $meta_data[$form_field['id']] ), ENT_QUOTES );
 
 
 
155
  if ( $form_field['type'] == 'heading' ) {
156
  echo "
157
  <tr>
@@ -161,35 +163,55 @@ function wpsc_display_form_fields() {
161
  </td>
162
  </tr>\n\r";
163
  } else {
164
- if ( $form_field['type'] == "country" ) {
165
- continue;
 
 
 
 
 
 
 
166
  }
167
-
168
- echo "
169
- <tr>
170
- <td align='left'>\n\r";
171
- echo apply_filters( 'wpsc_account_form_field_' . $ff_tag, $form_field['name'] );
172
- if ( $form_field['mandatory'] == 1 ) {
173
- if ( !(($form_field['type'] == 'country') || ($form_field['type'] == 'delivery_country')) ) {
174
- echo "*";
175
  }
176
  }
177
- echo "
178
- </td>\n\r
179
- <td align='left'>\n\r";
 
 
 
 
 
 
 
 
 
180
  switch ( $form_field['type'] ) {
181
- case "text":
182
  case "city":
183
  case "delivery_city":
184
- echo "<input type='text' value='" . $meta_data[$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
185
  break;
186
-
187
  case "address":
188
  case "delivery_address":
189
  case "textarea":
190
  echo "<textarea name='collected_data[" . $form_field['id'] . "]'>" . $meta_data[$form_field['id']] . "</textarea>";
191
  break;
192
-
 
 
 
 
 
 
193
 
194
  case "region":
195
  case "delivery_region":
@@ -198,16 +220,37 @@ function wpsc_display_form_fields() {
198
 
199
 
200
  case "country":
 
 
 
 
 
 
 
 
 
 
 
201
  break;
202
 
 
203
  case "delivery_country":
204
- echo "<select name='collected_data[" . $form_field['id'] . "]' >" . nzshpcrt_country_list( $meta_data[$form_field['id']] ) . "</select>";
205
- break;
206
 
 
 
 
 
 
 
 
 
 
 
 
207
  case "email":
208
  echo "<input type='text' value='" . $meta_data[$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
209
  break;
210
-
211
  default:
212
  echo "<input type='text' value='" . $meta_data[$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
213
  break;
@@ -215,6 +258,7 @@ function wpsc_display_form_fields() {
215
  echo "
216
  </td>
217
  </tr>\n\r";
 
218
  }
219
  }
220
  /* Returns an empty array at this point, empty in regards to fields, does show the internalname though. Needs to be reconsidered, even if it did work, need to check
@@ -591,7 +635,7 @@ function wpsc_user_details() {
591
  }
592
  //}
593
  echo " <tr><td>" . __( 'Payment Method', 'wpsc' ) . ":</td><td>" . $gateway_name . "</td></tr>";
594
- echo " <tr><td>" . __( 'Purchase No.', 'wpsc' ) . ":</td><td>" . $purchase['id'] . "</td></tr>";
595
  if ( $purchase['transactid'] != '' ) {
596
  echo " <tr><td>" . __( 'Transaction Id', 'wpsc' ) . ":</td><td>" . $purchase['transactid'] . "</td></tr>";
597
  }
37
 
38
  $any_bad_inputs = false;
39
  $changes_saved = false;
40
+ //exit('<pre>'.print_r($_POST['collected_data'],1).'</pre>');
41
  $_SESSION['collected_data'] = null;
42
 
43
  if ( $_POST['collected_data'] != null ) {
145
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' ORDER BY `order`;";
146
  $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
147
  foreach ( $form_data as $form_field ) {
 
148
  if ( !empty( $form_field['unique_name'] ) ) {
149
  $ff_tag = $form_field['unique_name'];
150
  } else {
151
  $ff_tag = htmlentities( stripslashes( strtolower( str_replace( ' ', '-', $form_field['name'] ) ) ) );
152
  }
153
+
154
+ if(!empty($meta_data[$form_field['id']]) && !is_array($meta_data[$form_field['id']]))
155
+ $meta_data[$form_field['id']] = htmlentities( stripslashes( $meta_data[$form_field['id']] ), ENT_QUOTES );
156
+
157
  if ( $form_field['type'] == 'heading' ) {
158
  echo "
159
  <tr>
163
  </td>
164
  </tr>\n\r";
165
  } else {
166
+ $continue = true;
167
+ if( $form_field['unique_name'] == 'billingstate'){
168
+ $selected_country_id = wpsc_get_country_form_id_by_type('country');
169
+ if(is_array($meta_data[$selected_country_id]) && isset($meta_data[$selected_country_id][1])){
170
+ $continue = false;
171
+ }else{
172
+ $continue = true;
173
+ }
174
+
175
  }
176
+
177
+ if( $form_field['unique_name'] == 'shippingstate'){
178
+ $delivery_country_id = wpsc_get_country_form_id_by_type('delivery_country');
179
+ if(is_array($meta_data[$delivery_country_id]) && isset($meta_data[$delivery_country_id][1])){
180
+ $continue = false;
181
+ }else{
182
+ $continue = true;
 
183
  }
184
  }
185
+
186
+ if($continue){
187
+ echo "
188
+ <tr>
189
+ <td align='left'>\n\r";
190
+ echo apply_filters( 'wpsc_account_form_field_' . $ff_tag, $form_field['name'] );
191
+ if ( $form_field['mandatory'] == 1 )
192
+ echo " *";
193
+ echo "
194
+ </td>\n\r
195
+ <td align='left'>\n\r";
196
+ }
197
  switch ( $form_field['type'] ) {
 
198
  case "city":
199
  case "delivery_city":
200
+ echo "<input type='text' value='" . $meta_data[$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
201
  break;
202
+
203
  case "address":
204
  case "delivery_address":
205
  case "textarea":
206
  echo "<textarea name='collected_data[" . $form_field['id'] . "]'>" . $meta_data[$form_field['id']] . "</textarea>";
207
  break;
208
+
209
+ case "text":
210
+ if($continue){
211
+ echo "<input type='text' value='" . $meta_data[$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
212
+
213
+ }
214
+ break;
215
 
216
  case "region":
217
  case "delivery_region":
220
 
221
 
222
  case "country":
223
+ if (is_array($meta_data[$form_field['id']]))
224
+ $country_code = ($meta_data[$form_field['id']][0]);
225
+ else
226
+ $country_code = ($meta_data[$form_field['id']]);
227
+ //echo '<pre>'.print_r($country_code,1).'</pre>';
228
+ echo "<select name='collected_data[" . $form_field['id'] . "][0]' >" . nzshpcrt_country_list( $country_code ) . "</select>";
229
+ if( isset($meta_data[$form_field['id']][1]) )
230
+ echo "<br /><select name='collected_data[" . $form_field['id'] . "][1]'>" . nzshpcrt_region_list( $country_code, $meta_data[$form_field['id']][1] ) . "</select>";
231
+
232
+
233
+
234
  break;
235
 
236
+ ///don't forget this
237
  case "delivery_country":
 
 
238
 
239
+ if (is_array($meta_data[$form_field['id']]))
240
+ $country_code = ($meta_data[$form_field['id']][0]);
241
+ else
242
+ $country_code = ($meta_data[$form_field['id']]);
243
+ //echo '<pre>'.print_r($country_code,1).'</pre>';
244
+ echo "<select name='collected_data[" . $form_field['id'] . "][0]' >" . nzshpcrt_country_list( $country_code ) . "</select>";
245
+ if( isset($meta_data[$form_field['id']][1]) )
246
+ echo "<br /><select name='collected_data[" . $form_field['id'] . "][1]'>" . nzshpcrt_region_list( $country_code, $meta_data[$form_field['id']][1] ) . "</select>";
247
+
248
+ break;
249
+
250
  case "email":
251
  echo "<input type='text' value='" . $meta_data[$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
252
  break;
253
+
254
  default:
255
  echo "<input type='text' value='" . $meta_data[$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
256
  break;
258
  echo "
259
  </td>
260
  </tr>\n\r";
261
+
262
  }
263
  }
264
  /* Returns an empty array at this point, empty in regards to fields, does show the internalname though. Needs to be reconsidered, even if it did work, need to check
635
  }
636
  //}
637
  echo " <tr><td>" . __( 'Payment Method', 'wpsc' ) . ":</td><td>" . $gateway_name . "</td></tr>";
638
+ echo " <tr><td>" . __( 'Purchase #', 'wpsc' ) . ":</td><td>" . $purchase['id'] . "</td></tr>";
639
  if ( $purchase['transactid'] != '' ) {
640
  echo " <tr><td>" . __( 'Transaction Id', 'wpsc' ) . ":</td><td>" . $purchase['transactid'] . "</td></tr>";
641
  }
wpsc-theme/wpsc-category_widget.php CHANGED
@@ -49,7 +49,6 @@
49
 
50
  </a>
51
 
52
- <?php wpsc_print_product_list(); ?>
53
  <?php wpsc_print_subcategory( '<ul>', '</ul>' ); ?>
54
 
55
  </li>
49
 
50
  </a>
51
 
 
52
  <?php wpsc_print_subcategory( '<ul>', '</ul>' ); ?>
53
 
54
  </li>
wpsc-theme/wpsc-default.css CHANGED
@@ -58,6 +58,18 @@ Author URI: http://instinct.co.nz
58
  margin-top:20px;
59
  }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  #default_products_page_container .wpsc_page_numbers_top a:link, #default_products_page_container .wpsc_page_numbers_top a:visited, #default_products_page_container .wpsc_page_numbers_bottom a:link, #default_products_page_container .wpsc_page_numbers_bottom a:visited {
62
  padding:5px 8px;
63
  background-color:#006699;
@@ -107,9 +119,9 @@ Author URI: http://instinct.co.nz
107
  }
108
 
109
  .default_product_display .imagecol {
110
- margin:0px 10px 0px 0px;
111
  float:left;
112
- width:150px;
113
  position:relative;
114
  }
115
 
@@ -124,7 +136,7 @@ Author URI: http://instinct.co.nz
124
 
125
  .default_product_display .productcol {
126
  float:left;
127
- width:100%;
128
  position:relative;
129
  }
130
 
@@ -594,8 +606,8 @@ table.list_productdisplay p.soldout {
594
  }
595
 
596
  .single_product_display .imagecol {
597
- margin-right:10px;
598
- width:150px;
599
  float:left;
600
  position:relative;
601
  }
@@ -748,14 +760,10 @@ table.list_productdisplay p.soldout {
748
  }
749
 
750
  .single_product_display .wpcart_gallery img, #content .single_product_display .wpcart_gallery img {
751
- margin-left:6px;
752
  border:1px solid #ccc;
753
  }
754
 
755
- .single_product_display .wpcart_gallery a:first-child img, #content .single_product_display .wpcart_gallery a:first-child img {
756
- margin-left:0px;
757
- }
758
-
759
  .single_product_display .FB_like iframe {
760
  border:none;
761
  width:300px;
@@ -1021,11 +1029,6 @@ span.rating_saved{
1021
  #checkout_page_container {
1022
  width:650px;
1023
  position:relative;
1024
- *border:1px solid #ccc;
1025
- border:1px solid #ccc\9;
1026
- -moz-box-shadow:1px 1px 8px rgba(0,0,0,0.3);
1027
- -webkit-box-shadow:1px 1px 8px rgba(0,0,0,0.3);
1028
- padding:10px;
1029
  clear:both;
1030
  }
1031
 
@@ -1035,14 +1038,141 @@ span.rating_saved{
1035
  margin:0;
1036
  }
1037
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1038
  #checkout_page_container p.validation-error {
1039
  clear:both;
1040
  color:red;
1041
  }
1042
 
1043
- #checkout_page_container h3 {
1044
- color:#006699;
1045
- font-size:22px;
 
 
 
 
 
1046
  }
1047
 
1048
  #checkout_page_container img.product_image {
@@ -1051,69 +1181,38 @@ span.rating_saved{
1051
  }
1052
 
1053
  #checkout_page_container table.checkout_cart {
1054
- border:1px solid #ccc;
1055
- }
1056
-
1057
- #checkout_page_container table.checkout_cart tr.header td, #content #checkout_page_container table.checkout_cart tr.header td {
1058
- padding:0;
1059
- margin:0;
1060
- }
1061
-
1062
- #checkout_page_container table.checkout_cart tr.header td, #content #checkout_page_container table.checkout_cart tr.header td {
1063
- font-size:11px;
1064
- margin:0;
1065
- padding:0;
1066
  }
1067
 
1068
  #checkout_page_container table.checkout_cart tr, #content #checkout_page_container table.checkout_cart tr {
1069
  margin:0;
1070
- padding:0;
1071
  }
1072
 
1073
  #checkout_page_container table.checkout_cart tr.alt, #content #checkout_page_container table.checkout_cart tr.alt {
1074
  background-color:#f8f8f8;
1075
  }
1076
 
1077
-
1078
- #checkout_page_container table.checkout_cart tr td, #content #checkout_page_container table.checkout_cart tr td {
1079
- margin:0;
1080
- padding:5px;
1081
- vertical-align:middle;
1082
  }
1083
 
1084
- #checkout_page_container table.checkout_cart td.firstcol {
1085
- vertical-align:middle;
1086
- text-align:center;
1087
  }
1088
 
1089
- #checkout_page_container input[type=submit], #content #checkout_page_container input[type=submit] {
1090
- background-color:#006699;
1091
- background:-webkit-gradient(
1092
- linear,
1093
- left bottom,
1094
- left top,
1095
- color-stop(0.76, rgb(73,166,192)),
1096
- color-stop(1, rgb(125,195,215))
1097
- );
1098
- background:-moz-linear-gradient(
1099
- center bottom,
1100
- rgb(73,166,192) 76%,
1101
- rgb(125,195,215) 100%
1102
- );
1103
- color:#ffffff;
1104
- font-size:10px;
1105
- border-radius:3px;
1106
- -moz-border-radius:3px;
1107
- -webkit-border-radius:3px;
1108
- border:1px solid #29bade;
1109
- padding:3px;
1110
- *padding:1px;
1111
- cursor:pointer;
1112
- line-height:1.2em;
1113
  }
1114
 
1115
- #checkout_page_container input[type=submit]:hover, #content #checkout_page_container input[type=submit]:hover {
1116
- background:#369;
 
1117
  }
1118
 
1119
  #checkout_page_container .coupon {
@@ -1131,11 +1230,6 @@ span.rating_saved{
1131
  line-height:1.2em;
1132
  }
1133
 
1134
- #checkout_page_container .wpsc_cost_before {
1135
- clear:both;
1136
- float:right;
1137
- }
1138
-
1139
  #checkout_page_container .col1 {
1140
  float:left;
1141
  width:320px;
@@ -1148,4 +1242,9 @@ span.rating_saved{
1148
 
1149
  #checkout_page_container input.intra-field-label, #checkout_page_container textarea.intra-field-label{
1150
  color:#bbb;
 
 
 
 
 
1151
  }
58
  margin-top:20px;
59
  }
60
 
61
+ .wpsc_category_grid_item {
62
+ text-align: center;
63
+ background: #EFEFEF;
64
+ border: 1px solid #CCC;
65
+ margin:10px;
66
+ text-decoration: none;
67
+ }
68
+
69
+ .wpsc_category_grid_item .item_no_image {
70
+ color:#000;
71
+ }
72
+
73
  #default_products_page_container .wpsc_page_numbers_top a:link, #default_products_page_container .wpsc_page_numbers_top a:visited, #default_products_page_container .wpsc_page_numbers_bottom a:link, #default_products_page_container .wpsc_page_numbers_bottom a:visited {
74
  padding:5px 8px;
75
  background-color:#006699;
119
  }
120
 
121
  .default_product_display .imagecol {
122
+ margin:0px 5px 0px 0px;
123
  float:left;
124
+ width:160px;
125
  position:relative;
126
  }
127
 
136
 
137
  .default_product_display .productcol {
138
  float:left;
139
+ width:70%;
140
  position:relative;
141
  }
142
 
606
  }
607
 
608
  .single_product_display .imagecol {
609
+ margin-right:5px;
610
+ width:160px;
611
  float:left;
612
  position:relative;
613
  }
760
  }
761
 
762
  .single_product_display .wpcart_gallery img, #content .single_product_display .wpcart_gallery img {
763
+ margin-right:6px;
764
  border:1px solid #ccc;
765
  }
766
 
 
 
 
 
767
  .single_product_display .FB_like iframe {
768
  border:none;
769
  width:300px;
1029
  #checkout_page_container {
1030
  width:650px;
1031
  position:relative;
 
 
 
 
 
1032
  clear:both;
1033
  }
1034
 
1038
  margin:0;
1039
  }
1040
 
1041
+ #checkout_page_container table.checkout_cart tr.header th{
1042
+ text-align: center;
1043
+ color: #000;
1044
+ font-weight: bold;
1045
+ font-size: 16px;
1046
+ background-color: #f5f5f5;
1047
+ }
1048
+
1049
+ #checkout_page_container table.checkout_cart tr.wpsc_total_before_shipping td {
1050
+ background-color: #f5f5f5;
1051
+ border-top:4px solid #000;
1052
+ border-bottom: 0px;
1053
+ font-weight: bold;
1054
+ }
1055
+
1056
+ #checkout_page_container table.checkout_cart tr.wpsc_coupon_row td.coupon_code form{
1057
+ text-align: right;
1058
+ padding-right: 18px;
1059
+ }
1060
+
1061
+ #checkout_page_container table.checkout_cart tr.wpsc_coupon_row td.coupon_code {
1062
+ padding-left: 0px;
1063
+ }
1064
+
1065
+ #checkout_page_container table.checkout_cart tr td, #content #checkout_page_container table.checkout_cart tr td {
1066
+ margin:0;
1067
+ padding:5px;
1068
+ vertical-align:middle;
1069
+ }
1070
+
1071
+ #checkout_page_container table.checkout_cart tr.wpsc_coupon_row td form input#coupon_num {
1072
+ width: 293px;
1073
+ padding: 0px;
1074
+ margin: 0px 20px 0px 0px;
1075
+ }
1076
+
1077
+ #checkout_page_container table.checkout_cart tr.wpsc_total_before_shipping td.wpsc_total_amount_before_shipping{
1078
+ text-align: right;
1079
+ }
1080
+
1081
+ #content #checkout_page_container p{
1082
+ margin-bottom: 0px;
1083
+ }
1084
+
1085
+ #checkout_page_container h3,
1086
+ #checkout_page_container h2,
1087
+ #checkout_page_container label.wpsc_email_address,
1088
+ #checkout_page_container h4 {
1089
+ margin: 0px 0px 10px 0px;
1090
+ font-size: 1.17em;
1091
+ color:#000;
1092
+ }
1093
+
1094
+ .wpsc_checkout_table input.text{
1095
+ width:255px;
1096
+ }
1097
+
1098
+ #content img#wpsc_checkout_gravatar{
1099
+ float:left;
1100
+ margin:0px 10px 10px 0px;
1101
+ }
1102
+
1103
+ #checkout_page_container .wpsc_shipping_header {
1104
+ background-color: #f5f5f5;
1105
+ }
1106
+
1107
+ #checkout_page_container .total_price.total_shipping,
1108
+ #checkout_page_container .total_price {
1109
+ background-color: #f5f5f5;
1110
+ }
1111
+
1112
+ #checkout_page_container .total_price td.wpsc_totals{
1113
+ border-bottom: 4px solid #000;
1114
+ font-weight: bold;
1115
+ }
1116
+
1117
+ #checkout_page_container .wpsc_make_purchase{
1118
+ bottom: 20px;
1119
+ float: right;
1120
+ position: relative;
1121
+ }
1122
+
1123
+ #checkout_page_container .total_price.total_shipping td{
1124
+ border:none;
1125
+ font-weight: normal;
1126
+ }
1127
+
1128
+ #checkout_page_container .total_price.total_shipping td:first-child,
1129
+ #checkout_page_container .total_price td:first-child {
1130
+ padding-left: 50px;
1131
+ }
1132
+
1133
+ #checkout_page_container .wpsc_shipping_quote_name,
1134
+ #checkout_page_container .wpsc_shipping_quote_price,
1135
+ #checkout_page_container .wpsc_shipping_quote_radio {
1136
+ border-bottom: solid 1px #e1e1e1;
1137
+ }
1138
+
1139
+ #checkout_page_container .wpsc_shipping_quote_name label,
1140
+ #checkout_page_container .wpsc_shipping_quote_price label,
1141
+ #checkout_page_container .wpsc_shipping_quote_radio label {
1142
+ color:#000;
1143
+ }
1144
+
1145
+ #content #checkout_page_container table.productcart tr td{
1146
+ border-top:none;
1147
+ padding-left: 0px;
1148
+ }
1149
+
1150
+ #content #checkout_page_container table.productcart {
1151
+ border: none;
1152
+ }
1153
+
1154
+ #checkout_page_container table.checkout_cart tr td {
1155
+ border-top:0px;
1156
+ border-bottom: 1px solid #e1e1e1;
1157
+ }
1158
+
1159
+ #checkout_page_container table.checkout_cart tr.wpsc_coupon_row tr {
1160
+ border-bottom: 0px;
1161
+ }
1162
+
1163
  #checkout_page_container p.validation-error {
1164
  clear:both;
1165
  color:red;
1166
  }
1167
 
1168
+ #content table.wpsc_checkout_table,
1169
+ #content table.wpsc_checkout_table tr td {
1170
+ border: none;
1171
+ padding:0px;
1172
+ }
1173
+
1174
+ .wpsc-shopping-cart .asterix {
1175
+ color:red;
1176
  }
1177
 
1178
  #checkout_page_container img.product_image {
1181
  }
1182
 
1183
  #checkout_page_container table.checkout_cart {
1184
+ border:none;
 
 
 
 
 
 
 
 
 
 
 
1185
  }
1186
 
1187
  #checkout_page_container table.checkout_cart tr, #content #checkout_page_container table.checkout_cart tr {
1188
  margin:0;
1189
+ padding:0;
1190
  }
1191
 
1192
  #checkout_page_container table.checkout_cart tr.alt, #content #checkout_page_container table.checkout_cart tr.alt {
1193
  background-color:#f8f8f8;
1194
  }
1195
 
1196
+ #content #checkout_page_container table.checkout_cart tr.wpsc_coupon_row td{
1197
+ padding-top:15px;
1198
+ padding-bottom: 15px;
1199
+ padding-left: 0px;
 
1200
  }
1201
 
1202
+ #content #checkout_page_container table.checkout_cart tr.product_row td.wpsc_product_image img {
1203
+ height: 31px;
1204
+ width: 31px;
1205
  }
1206
 
1207
+ #content #checkout_page_container table.checkout_cart tr.product_row td, #content #checkout_page_container table.checkout_cart tr.product_row {
1208
+ padding:2px 0px 1px 0px;
1209
+ margin:0px;
1210
+ line-height: 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1211
  }
1212
 
1213
+ #checkout_page_container table.checkout_cart td.firstcol {
1214
+ vertical-align:middle;
1215
+ text-align:center;
1216
  }
1217
 
1218
  #checkout_page_container .coupon {
1230
  line-height:1.2em;
1231
  }
1232
 
 
 
 
 
 
1233
  #checkout_page_container .col1 {
1234
  float:left;
1235
  width:320px;
1242
 
1243
  #checkout_page_container input.intra-field-label, #checkout_page_container textarea.intra-field-label{
1244
  color:#bbb;
1245
+ }
1246
+
1247
+ #content #checkout_page_container table.checkout_cart tr.product_row td.wpsc_product_name {
1248
+ width: 200px;
1249
+ padding-left: 20px;
1250
  }
wpsc-theme/wpsc-list_view.php CHANGED
@@ -8,11 +8,11 @@ global $wpsc_query, $wpdb;
8
  <?php do_action('wpsc_top_of_products_page'); // Plugin hook for adding things to the top of the products page, like the live search ?>
9
 
10
  <?php if(wpsc_display_categories()): ?>
11
- <?php if(get_option('wpsc_category_grid_view') == 1) :?>
12
  <div class="wpsc_categories wpsc_category_grid group">
13
  <?php wpsc_start_category_query(array('category_group'=> 1, 'show_thumbnails'=> 1)); ?>
14
  <a href="<?php wpsc_print_category_url();?>" class="wpsc_category_grid_item" title="<?php wpsc_print_category_name();?>">
15
- <?php wpsc_print_category_image(45, 45); ?>
16
  </a>
17
  <?php wpsc_print_subcategory("", ""); ?>
18
  <?php wpsc_end_category_query(); ?>
@@ -21,7 +21,7 @@ global $wpsc_query, $wpdb;
21
  <ul class="wpsc_categories">
22
  <?php wpsc_start_category_query(array('category_group'=> 1, 'show_thumbnails'=> get_option('show_category_thumbnails'))); ?>
23
  <li>
24
- <?php wpsc_print_category_image(32, 32); ?>
25
 
26
  <a href="<?php wpsc_print_category_url();?>" class="wpsc_category_link"><?php wpsc_print_category_name();?></a>
27
  <?php if(get_option('wpsc_category_description')) :?>
@@ -68,17 +68,21 @@ global $wpsc_query, $wpdb;
68
  <td width="40%">
69
  <h2 class="prodtitle"><a class="wpsc_product_title" href="<?php echo wpsc_the_product_permalink(); ?>"><?php echo wpsc_the_product_title(); ?></a></h2>
70
  </td>
71
-
72
- <td class="stock">
73
  <?php if(wpsc_product_has_stock()) : ?>
74
- <img src="<?php echo WPSC_CORE_THEME_URL; ?>wpsc-images/yes_stock.gif" alt="Yes" title="Yes" />
75
- <?php else: ?>
76
- <img src="<?php echo WPSC_CORE_THEME_URL; ?>wpsc-images/no_stock.gif" title='No' alt="No" />
77
- <?php endif; ?>
78
- </td>
 
79
 
80
  <td>
81
- <?php if(wpsc_product_on_special()) : ?>
 
 
 
82
  <p class="oldprice"><?php echo wpsc_product_normal_price(); ?></p>
83
  <?php endif; ?>
84
  <p id="product_price_<?php echo wpsc_the_product_id(); ?>" class="pricedisplay currentprice"><?php echo wpsc_the_product_price(); ?></p>
@@ -107,8 +111,8 @@ global $wpsc_query, $wpdb;
107
  <?php if(wpsc_product_has_stock()) : ?>
108
  <div class="wpsc_buy_button_container">
109
  <?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
110
- <?php $action = wpsc_product_external_link(wpsc_the_product_id()); ?>
111
- <input class="wpsc_buy_button" type="button" value="<?php _e('Buy Now', 'wpsc'); ?>' onclick='gotoexternallink("<?php echo $action; ?>")">
112
  <?php else: ?>
113
  <input type="submit" value="<?php _e('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button" />
114
  <?php endif; ?>
8
  <?php do_action('wpsc_top_of_products_page'); // Plugin hook for adding things to the top of the products page, like the live search ?>
9
 
10
  <?php if(wpsc_display_categories()): ?>
11
+ <?php if(wpsc_category_grid_view()) :?>
12
  <div class="wpsc_categories wpsc_category_grid group">
13
  <?php wpsc_start_category_query(array('category_group'=> 1, 'show_thumbnails'=> 1)); ?>
14
  <a href="<?php wpsc_print_category_url();?>" class="wpsc_category_grid_item" title="<?php wpsc_print_category_name();?>">
15
+ <?php wpsc_print_category_image(get_option('category_image_width'), get_option('category_image_height')); ?>
16
  </a>
17
  <?php wpsc_print_subcategory("", ""); ?>
18
  <?php wpsc_end_category_query(); ?>
21
  <ul class="wpsc_categories">
22
  <?php wpsc_start_category_query(array('category_group'=> 1, 'show_thumbnails'=> get_option('show_category_thumbnails'))); ?>
23
  <li>
24
+ <?php wpsc_print_category_image(get_option('category_image_width'), get_option('category_image_height')); ?>
25
 
26
  <a href="<?php wpsc_print_category_url();?>" class="wpsc_category_link"><?php wpsc_print_category_name();?></a>
27
  <?php if(get_option('wpsc_category_description')) :?>
68
  <td width="40%">
69
  <h2 class="prodtitle"><a class="wpsc_product_title" href="<?php echo wpsc_the_product_permalink(); ?>"><?php echo wpsc_the_product_title(); ?></a></h2>
70
  </td>
71
+ <?php if(wpsc_show_stock_availability()): ?>
72
+ <td class="stock">
73
  <?php if(wpsc_product_has_stock()) : ?>
74
+ <div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="in_stock"><?php _e('Product in stock', 'wpsc'); ?></div>
75
+ <?php else: ?>
76
+ <div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="out_of_stock"><?php _e('Product not in stock', 'wpsc'); ?></div>
77
+ <?php endif; ?>
78
+ </td>
79
+ <?php endif; ?>
80
 
81
  <td>
82
+ <?php do_action('wpsc_product_before_description', wpsc_the_product_id(), $wpsc_query->product); ?>
83
+ </td>
84
+ <td>
85
+ <?php if(wpsc_product_on_special()) : ?>
86
  <p class="oldprice"><?php echo wpsc_product_normal_price(); ?></p>
87
  <?php endif; ?>
88
  <p id="product_price_<?php echo wpsc_the_product_id(); ?>" class="pricedisplay currentprice"><?php echo wpsc_the_product_price(); ?></p>
111
  <?php if(wpsc_product_has_stock()) : ?>
112
  <div class="wpsc_buy_button_container">
113
  <?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
114
+ <?php $action = wpsc_product_external_link( wpsc_the_product_id() ); ?>
115
+ <input class="wpsc_buy_button" type="button" value="<?php echo wpsc_product_external_link_text( wpsc_the_product_id(), __( 'Buy Now', 'wpsc' ) ); ?>" onclick="return gotoexternallink('<?php echo $action; ?>', '<?php echo wpsc_product_external_link_target( wpsc_the_product_id() ); ?>')">
116
  <?php else: ?>
117
  <input type="submit" value="<?php _e('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button" />
118
  <?php endif; ?>
wpsc-theme/wpsc-products_page.php CHANGED
@@ -14,7 +14,7 @@ global $wpsc_query, $wpdb, $wp_query;
14
  <div class="wpsc_categories wpsc_category_grid group">
15
  <?php wpsc_start_category_query(array('category_group'=> get_option('wpsc_default_category'), 'show_thumbnails'=> 1)); ?>
16
  <a href="<?php wpsc_print_category_url();?>" class="wpsc_category_grid_item" title="<?php wpsc_print_category_name(); ?>">
17
- <?php wpsc_print_category_image(45, 45); ?>
18
  </a>
19
  <?php wpsc_print_subcategory("", ""); ?>
20
  <?php wpsc_end_category_query(); ?>
@@ -24,7 +24,7 @@ global $wpsc_query, $wpdb, $wp_query;
24
  <ul class="wpsc_categories">
25
  <?php wpsc_start_category_query(array('category_group'=>get_option('wpsc_default_category'), 'show_thumbnails'=> get_option('show_category_thumbnails'))); ?>
26
  <li>
27
- <?php wpsc_print_category_image(32, 32); ?>
28
 
29
  <a href="<?php wpsc_print_category_url();?>" class="wpsc_category_link" title="<?php wpsc_print_category_name(); ?>"><?php wpsc_print_category_name(); ?></a>
30
  <?php if(wpsc_show_category_description()) :?>
@@ -69,51 +69,27 @@ global $wpsc_query, $wpdb, $wp_query;
69
  <?php endif; ?>
70
 
71
  <div class="default_product_display product_view_<?php echo wpsc_the_product_id(); ?> <?php echo wpsc_category_class(); ?> group">
72
- <div class="productcol">
73
- <?php if(wpsc_show_thumbnails()) :?>
74
- <div class="imagecol" id="imagecol_<?php echo wpsc_the_product_id(); ?>">
75
- <?php if(wpsc_the_product_thumbnail()) :
76
- ?>
77
- <a rel="<?php echo str_replace(array(" ", '"',"'", '&quot;','&#039;'), array("_", "", "", "",''), wpsc_the_product_title()); ?>" class="<?php echo wpsc_the_product_image_link_classes(); ?>" href="<?php echo wpsc_the_product_image(); ?>">
78
- <img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(); ?>"/>
79
-
80
- </a>
81
- <?php else: ?>
82
- <a href="<?php echo wpsc_the_product_permalink(); ?>">
83
- <img class="no-image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="No Image" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo WPSC_CORE_THEME_URL; ?>wpsc-images/noimage.png" width="<?php echo get_option('product_image_width'); ?>" height="<?php echo get_option('product_image_height'); ?>" />
84
- </a>
85
- <?php endif; ?>
86
- <?php
87
- if(gold_cart_display_gallery()) :
88
- echo gold_shpcrt_display_gallery(wpsc_the_product_id(), true);
89
- endif;
90
- ?>
91
- </div><!--close imagecol-->
92
- <style>
93
- #imagecol_<?php echo wpsc_the_product_id(); ?> {
94
- width: <?php echo get_option('product_image_width')+8; ?>px;
95
- <?php
96
- $args = array(
97
- 'post_type' => 'attachment',
98
- 'post_parent' => wpsc_the_product_id(),
99
- 'post_mime_type' => 'image',
100
- 'numberposts' => -1
101
- );
102
- $attachments = get_posts($args);
103
- if( gold_cart_display_gallery() )
104
- $height = ( ceil ( count($attachments) * (get_option( 'wpsc_gallery_image_width' )+6) / (get_option('product_image_width')+6) ) * ( get_option( 'wpsc_gallery_image_width' ) + 3 ) ) + get_option('product_image_width') ;
105
- else
106
- $height = get_option('product_image_width');
107
- ?>
108
- height: <?php echo $height; ?>px;
109
- float:left;
110
- }
111
- #default_products_page_container .imagecol img, #list_view_products_page_container img, #grid_view_products_page_container img{
112
- max-width:<?php echo get_option('product_image_width'); ?>px;
113
- max-height:<?php echo get_option('product_image_height'); ?>px;
114
- }
115
- </style>
116
  <?php endif; ?>
 
 
 
 
 
 
 
 
117
  <h2 class="prodtitle">
118
  <?php if(get_option('hide_name_link') == 1) : ?>
119
  <?php echo wpsc_the_product_title(); ?>
@@ -184,10 +160,12 @@ global $wpsc_query, $wpdb, $wp_query;
184
  <?php endif ;?>
185
 
186
  <div class="wpsc_product_price">
187
- <?php if(wpsc_product_has_stock()) : ?>
188
- <div class="in_stock"><?php _e('Product in stock', 'wpsc'); ?></div>
189
- <?php else: ?>
190
- <div class="out_of_stock"><?php _e('Product not in stock', 'wpsc'); ?></div>
 
 
191
  <?php endif; ?>
192
  <?php if(wpsc_product_is_donation()) : ?>
193
  <label for="donation_price_<?php echo wpsc_the_product_id(); ?>"><?php _e('Donation', 'wpsc'); ?>:</label>
@@ -201,6 +179,12 @@ global $wpsc_query, $wpdb, $wp_query;
201
  <?php if(wpsc_product_on_special()) : ?>
202
  <p class="pricedisplay product_<?php echo wpsc_the_product_id(); ?>"><?php _e('You save', 'wpsc'); ?>:<span class="yousave" id="yousave_<?php echo wpsc_the_product_id(); ?>"><?php echo wpsc_currency_display(wpsc_you_save('type=amount'), array('html' => false)); ?>! (<?php echo wpsc_you_save(); ?>%)</span></p>
203
  <?php endif; ?>
 
 
 
 
 
 
204
  <?php if(wpsc_show_pnp()) : ?>
205
  <p class="pricedisplay"><?php _e('Shipping', 'wpsc'); ?>:<span class="pp_price"><?php echo wpsc_product_postage_and_packaging(); ?></span></p>
206
  <?php endif; ?>
@@ -219,8 +203,8 @@ global $wpsc_query, $wpdb, $wp_query;
219
  <?php _e('Updating cart...', 'wpsc'); ?>
220
  </div><!--close wpsc_loading_animation-->
221
  <?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
222
- <?php $action = wpsc_product_external_link(wpsc_the_product_id()); ?>
223
- <input class="wpsc_buy_button" type="submit" value="<?php _e('Buy Now', 'wpsc'); ?>" onclick="gotoexternallink("<?php echo $action; ?>")">
224
  <?php else: ?>
225
  <input type="submit" value="<?php _e('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
226
  <?php endif; ?>
14
  <div class="wpsc_categories wpsc_category_grid group">
15
  <?php wpsc_start_category_query(array('category_group'=> get_option('wpsc_default_category'), 'show_thumbnails'=> 1)); ?>
16
  <a href="<?php wpsc_print_category_url();?>" class="wpsc_category_grid_item" title="<?php wpsc_print_category_name(); ?>">
17
+ <?php wpsc_print_category_image(get_option('category_image_width'),get_option('category_image_height')); ?>
18
  </a>
19
  <?php wpsc_print_subcategory("", ""); ?>
20
  <?php wpsc_end_category_query(); ?>
24
  <ul class="wpsc_categories">
25
  <?php wpsc_start_category_query(array('category_group'=>get_option('wpsc_default_category'), 'show_thumbnails'=> get_option('show_category_thumbnails'))); ?>
26
  <li>
27
+ <?php wpsc_print_category_image(get_option('category_image_width'), get_option('category_image_height')); ?>
28
 
29
  <a href="<?php wpsc_print_category_url();?>" class="wpsc_category_link" title="<?php wpsc_print_category_name(); ?>"><?php wpsc_print_category_name(); ?></a>
30
  <?php if(wpsc_show_category_description()) :?>
69
  <?php endif; ?>
70
 
71
  <div class="default_product_display product_view_<?php echo wpsc_the_product_id(); ?> <?php echo wpsc_category_class(); ?> group">
72
+ <?php if(wpsc_show_thumbnails()) :?>
73
+ <div class="imagecol" id="imagecol_<?php echo wpsc_the_product_id(); ?>">
74
+ <?php if(wpsc_the_product_thumbnail()) :
75
+ ?>
76
+ <a rel="product_<?php echo wpsc_the_product_id(); ?>" class="<?php echo wpsc_the_product_image_link_classes(); ?>" href="<?php echo wpsc_the_product_image(); ?>">
77
+ <img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(); ?>"/>
78
+
79
+ </a>
80
+ <?php else: ?>
81
+ <a href="<?php echo wpsc_the_product_permalink(); ?>">
82
+ <img class="no-image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="No Image" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo WPSC_CORE_THEME_URL; ?>wpsc-images/noimage.png" width="<?php echo get_option('product_image_width'); ?>" height="<?php echo get_option('product_image_height'); ?>" />
83
+ </a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  <?php endif; ?>
85
+ <?php
86
+ if(gold_cart_display_gallery()) :
87
+ echo gold_shpcrt_display_gallery(wpsc_the_product_id(), true);
88
+ endif;
89
+ ?>
90
+ </div><!--close imagecol-->
91
+ <?php endif; ?>
92
+ <div class="productcol">
93
  <h2 class="prodtitle">
94
  <?php if(get_option('hide_name_link') == 1) : ?>
95
  <?php echo wpsc_the_product_title(); ?>
160
  <?php endif ;?>
161
 
162
  <div class="wpsc_product_price">
163
+ <?php if( wpsc_show_stock_availability() ): ?>
164
+ <?php if(wpsc_product_has_stock()) : ?>
165
+ <div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="in_stock"><?php _e('Product in stock', 'wpsc'); ?></div>
166
+ <?php else: ?>
167
+ <div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="out_of_stock"><?php _e('Product not in stock', 'wpsc'); ?></div>
168
+ <?php endif; ?>
169
  <?php endif; ?>
170
  <?php if(wpsc_product_is_donation()) : ?>
171
  <label for="donation_price_<?php echo wpsc_the_product_id(); ?>"><?php _e('Donation', 'wpsc'); ?>:</label>
179
  <?php if(wpsc_product_on_special()) : ?>
180
  <p class="pricedisplay product_<?php echo wpsc_the_product_id(); ?>"><?php _e('You save', 'wpsc'); ?>:<span class="yousave" id="yousave_<?php echo wpsc_the_product_id(); ?>"><?php echo wpsc_currency_display(wpsc_you_save('type=amount'), array('html' => false)); ?>! (<?php echo wpsc_you_save(); ?>%)</span></p>
181
  <?php endif; ?>
182
+
183
+ <!-- multi currency code -->
184
+ <?php if(wpsc_product_has_multicurrency()) : ?>
185
+ <?php echo wpsc_display_product_multicurrency(); ?>
186
+ <?php endif; ?>
187
+
188
  <?php if(wpsc_show_pnp()) : ?>
189
  <p class="pricedisplay"><?php _e('Shipping', 'wpsc'); ?>:<span class="pp_price"><?php echo wpsc_product_postage_and_packaging(); ?></span></p>
190
  <?php endif; ?>
203
  <?php _e('Updating cart...', 'wpsc'); ?>
204
  </div><!--close wpsc_loading_animation-->
205
  <?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
206
+ <?php $action = wpsc_product_external_link( wpsc_the_product_id() ); ?>
207
+ <input class="wpsc_buy_button" type="submit" value="<?php echo wpsc_product_external_link_text( wpsc_the_product_id(), __( 'Buy Now', 'wpsc' ) ); ?>" onclick="return gotoexternallink('<?php echo $action; ?>', '<?php echo wpsc_product_external_link_target( wpsc_the_product_id() ); ?>')">
208
  <?php else: ?>
209
  <input type="submit" value="<?php _e('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
210
  <?php endif; ?>
wpsc-theme/wpsc-shopping_cart_page.php CHANGED
@@ -15,15 +15,14 @@ endif;
15
  <h3><?php _e('Please review your order', 'wpsc'); ?></h3>
16
  <table class="checkout_cart">
17
  <tr class="header">
18
- <td>&nbsp;</td>
19
- <td><?php _e('ITEM', 'wpsc'); ?></td>
20
- <td><?php _e('QUANTITY', 'wpsc'); ?></td>
21
  <?php if(wpsc_uses_shipping()): ?>
22
- <!-- <td><?php //_e('Shipping', 'wpsc'); ?>:</td> -->
23
  <?php endif; ?>
24
- <td><?php _e('PRICE', 'wpsc'); ?></td>
25
- <td><?php _e('TOTAL', 'wpsc'); ?></td>
26
- <td>&nbsp;</td>
27
  </tr>
28
  <?php while (wpsc_have_cart_items()) : wpsc_the_cart_item(); ?>
29
  <?php
@@ -86,22 +85,26 @@ endif;
86
  if(wpsc_uses_coupons()): ?>
87
 
88
  <?php if(wpsc_coupons_error()): ?>
89
- <tr class="wpsc_coupon_error_row"><td><?php _e('Coupon is not valid.', 'wpsc'); ?></td></tr>
90
  <?php endif; ?>
91
  <tr class="wpsc_coupon_row">
92
- <td colspan="2"><?php _e('Enter your coupon number'); ?> :</td>
93
- <td colspan="3" align='left'>
94
  <form method="post" action="<?php echo get_option('shopping_cart_url'); ?>">
95
  <input type="text" name="coupon_num" id="coupon_num" value="<?php echo $wpsc_cart->coupons_name; ?>" />
96
  <input type="submit" value="<?php _e('Update', 'wpsc') ?>" />
97
  </form>
98
  </td>
99
  </tr>
 
 
 
 
100
  <?php endif; ?>
101
  </table>
102
  <!-- cart contents table close -->
103
  <?php if(wpsc_uses_shipping()): ?>
104
- <p class="wpsc_cost_before"><?php _e('Cost before shipping = ','wpsc'); ?> <?php echo wpsc_cart_total_widget(false,false,false);?></p>
105
  <?php endif; ?>
106
  <?php //this HTML dispalys the calculate your order HTML ?>
107
 
@@ -160,7 +163,7 @@ endif;
160
  <?php if (wpsc_have_morethanone_shipping_quote()) :?>
161
  <?php while (wpsc_have_shipping_methods()) : wpsc_the_shipping_method(); ?>
162
  <?php if (!wpsc_have_shipping_quotes()) { continue; } // Don't display shipping method if it doesn't have at least one quote ?>
163
- <tr class='wpsc_shipping_header'><td class='shipping_header' colspan='5'><?php echo wpsc_shipping_method_name().__('- Choose a Shipping Rate', 'wpsc'); ?> </td></tr>
164
  <?php while (wpsc_have_shipping_quotes()) : wpsc_the_shipping_quote(); ?>
165
  <tr class='<?php echo wpsc_shipping_quote_html_id(); ?>'>
166
  <td class='wpsc_shipping_quote_name wpsc_shipping_quote_name_<?php echo wpsc_shipping_quote_html_id(); ?>' colspan='3'>
@@ -210,6 +213,17 @@ endif;
210
  <?php endif; ?>
211
  <?php do_action('wpsc_before_form_of_shopping_cart'); ?>
212
 
 
 
 
 
 
 
 
 
 
 
 
213
  <form class='wpsc_checkout_forms' action='' method='post' enctype="multipart/form-data">
214
 
215
  <?php
@@ -263,12 +277,13 @@ endif;
263
  </tr>
264
  </table>
265
  </fieldset>
 
266
  <?php endif; // closes user login form
267
 
268
  if(!empty($_SESSION['wpsc_checkout_misc_error_messages'])): ?>
269
  <div class='login_error'>
270
  <?php foreach((array)$_SESSION['wpsc_checkout_misc_error_messages'] as $user_error ){?>
271
- <?php echo $user_error; ?><br />
272
  <?php } ?>
273
  </div>
274
  <?php
@@ -338,9 +353,10 @@ endif;
338
  <div class='wpsc_email_address'>
339
  <p class='<?php echo wpsc_checkout_form_element_id(); ?>'>
340
  <label class='wpsc_email_address' for='<?php echo wpsc_checkout_form_element_id(); ?>'>
341
- <?php echo wpsc_checkout_form_name();?>
342
  </label>
343
- <p>
 
344
  <?php echo wpsc_checkout_form_field();?>
345
  <?php if(wpsc_the_checkout_item_error() != ''): ?>
346
  <p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></p>
@@ -367,13 +383,13 @@ endif;
367
 
368
  <?php if (wpsc_show_find_us()) : ?>
369
  <tr>
370
- <td><?php _e('How did you find us' , 'wpsc'); ?> :</td>
371
  <td>
372
  <select name='how_find_us'>
373
- <option value='Word of Mouth'>Word of mouth</option>
374
- <option value='Advertisement'>Advertising</option>
375
- <option value='Internet'>Internet</option>
376
- <option value='Customer'>Existing Customer</option>
377
  </select>
378
  </td>
379
  </tr>
@@ -430,7 +446,7 @@ endif;
430
  <?php if(wpsc_uses_shipping()) : ?>
431
  <tr>
432
  <td class='wpsc_total_price_and_shipping'colspan='2'>
433
- <h4><?php _e('Total Price with Shipping','wpsc'); ?></h4>
434
  </td>
435
  </tr>
436
 
@@ -459,7 +475,7 @@ endif;
459
 
460
  <tr class='total_price'>
461
  <td class='wpsc_totals'>
462
- <?php _e('Total Price', 'wpsc'); ?>
463
  </td>
464
  <td class='wpsc_totals'>
465
  <span id='checkout_total' class="pricedisplay checkout-total"><?php echo wpsc_cart_total(); ?></span>
15
  <h3><?php _e('Please review your order', 'wpsc'); ?></h3>
16
  <table class="checkout_cart">
17
  <tr class="header">
18
+ <th colspan="2" ><?php _e('Product', 'wpsc'); ?></th>
19
+ <th><?php _e('Quantity', 'wpsc'); ?></th>
 
20
  <?php if(wpsc_uses_shipping()): ?>
21
+ <!-- <th><?php //_e('Shipping', 'wpsc'); ?>:</th> -->
22
  <?php endif; ?>
23
+ <th><?php _e('Price', 'wpsc'); ?></th>
24
+ <th><?php _e('Total', 'wpsc'); ?></th>
25
+ <th>&nbsp;</th>
26
  </tr>
27
  <?php while (wpsc_have_cart_items()) : wpsc_the_cart_item(); ?>
28
  <?php
85
  if(wpsc_uses_coupons()): ?>
86
 
87
  <?php if(wpsc_coupons_error()): ?>
88
+ <tr class="wpsc_coupon_row wpsc_coupon_error_row"><td><?php _e('Coupon is not valid.', 'wpsc'); ?></td></tr>
89
  <?php endif; ?>
90
  <tr class="wpsc_coupon_row">
91
+ <td colspan="2"><?php _e('Enter coupon code'); ?> :</td>
92
+ <td colspan="4" class="coupon_code">
93
  <form method="post" action="<?php echo get_option('shopping_cart_url'); ?>">
94
  <input type="text" name="coupon_num" id="coupon_num" value="<?php echo $wpsc_cart->coupons_name; ?>" />
95
  <input type="submit" value="<?php _e('Update', 'wpsc') ?>" />
96
  </form>
97
  </td>
98
  </tr>
99
+ <tr class="wpsc_total_before_shipping">
100
+ <td colspan="3"><?php _e('Cost before shipping:','wpsc'); ?></td>
101
+ <td colspan="3" class="wpsc_total_amount_before_shipping"><?php echo wpsc_cart_total_widget(false,false,false);?></td>
102
+ </tr>
103
  <?php endif; ?>
104
  </table>
105
  <!-- cart contents table close -->
106
  <?php if(wpsc_uses_shipping()): ?>
107
+ <p class="wpsc_cost_before"></p>
108
  <?php endif; ?>
109
  <?php //this HTML dispalys the calculate your order HTML ?>
110
 
163
  <?php if (wpsc_have_morethanone_shipping_quote()) :?>
164
  <?php while (wpsc_have_shipping_methods()) : wpsc_the_shipping_method(); ?>
165
  <?php if (!wpsc_have_shipping_quotes()) { continue; } // Don't display shipping method if it doesn't have at least one quote ?>
166
+ <tr class='wpsc_shipping_header'><td class='shipping_header' colspan='5'><?php echo wpsc_shipping_method_name().__(' - Choose a Shipping Rate', 'wpsc'); ?> </td></tr>
167
  <?php while (wpsc_have_shipping_quotes()) : wpsc_the_shipping_quote(); ?>
168
  <tr class='<?php echo wpsc_shipping_quote_html_id(); ?>'>
169
  <td class='wpsc_shipping_quote_name wpsc_shipping_quote_name_<?php echo wpsc_shipping_quote_html_id(); ?>' colspan='3'>
213
  <?php endif; ?>
214
  <?php do_action('wpsc_before_form_of_shopping_cart'); ?>
215
 
216
+ <?php if ( wpsc_show_user_login_form() && !is_user_logged_in() ): ?>
217
+ <h2><?php _e( 'Already Registered?' ); ?></h2>
218
+ <p><?php _e( 'Enter your login details below.' );?></p>
219
+ <fieldset class='wpsc_registration_form'>
220
+ <?php
221
+ $args = array( 'remember' => false );
222
+ wp_login_form( $args );
223
+ ?>
224
+ </fieldset>
225
+ <?php endif; ?>
226
+
227
  <form class='wpsc_checkout_forms' action='' method='post' enctype="multipart/form-data">
228
 
229
  <?php
277
  </tr>
278
  </table>
279
  </fieldset>
280
+
281
  <?php endif; // closes user login form
282
 
283
  if(!empty($_SESSION['wpsc_checkout_misc_error_messages'])): ?>
284
  <div class='login_error'>
285
  <?php foreach((array)$_SESSION['wpsc_checkout_misc_error_messages'] as $user_error ){?>
286
+ <p class='validation-error'><?php echo $user_error; ?></p>
287
  <?php } ?>
288
  </div>
289
  <?php
353
  <div class='wpsc_email_address'>
354
  <p class='<?php echo wpsc_checkout_form_element_id(); ?>'>
355
  <label class='wpsc_email_address' for='<?php echo wpsc_checkout_form_element_id(); ?>'>
356
+ <?php _e('Enter your email address'); ?>
357
  </label>
358
+ <p class="wpsc_email_address_p">
359
+ <img src="https://secure.gravatar.com/avatar/empty?s=60&d=mm" id="wpsc_checkout_gravatar" />
360
  <?php echo wpsc_checkout_form_field();?>
361
  <?php if(wpsc_the_checkout_item_error() != ''): ?>
362
  <p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></p>
383
 
384
  <?php if (wpsc_show_find_us()) : ?>
385
  <tr>
386
+ <td><label for='how_find_us'><?php _e('How did you find us' , 'wpsc'); ?></label></td>
387
  <td>
388
  <select name='how_find_us'>
389
+ <option value='Word of Mouth'><?php _e('Word of mouth' , 'wpsc'); ?></option>
390
+ <option value='Advertisement'><?php _e('Advertising' , 'wpsc'); ?></option>
391
+ <option value='Internet'><?php _e('Internet' , 'wpsc'); ?></option>
392
+ <option value='Customer'><?php _e('Existing Customer' , 'wpsc'); ?></option>
393
  </select>
394
  </td>
395
  </tr>
446
  <?php if(wpsc_uses_shipping()) : ?>
447
  <tr>
448
  <td class='wpsc_total_price_and_shipping'colspan='2'>
449
+ <h4><?php _e('Review and purchase','wpsc'); ?></h4>
450
  </td>
451
  </tr>
452
 
475
 
476
  <tr class='total_price'>
477
  <td class='wpsc_totals'>
478
+ <?php _e('Total Price', 'wpsc'); ?>:
479
  </td>
480
  <td class='wpsc_totals'>
481
  <span id='checkout_total' class="pricedisplay checkout-total"><?php echo wpsc_cart_total(); ?></span>
wpsc-theme/wpsc-single_product.php CHANGED
@@ -29,7 +29,7 @@
29
  while ( wpsc_have_products() ) : wpsc_the_product(); ?>
30
  <div class="imagecol">
31
  <?php if ( wpsc_the_product_thumbnail() ) : ?>
32
- <a rel="<?php echo str_replace(array(" ", '"',"'", '&quot;','&#039;'), array("_", "", "", "",''), wpsc_the_product_title()); ?>" class="<?php echo wpsc_the_product_image_link_classes(); ?>" href="<?php echo wpsc_the_product_image(); ?>">
33
  <img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(get_option('product_image_width'),get_option('product_image_height'),'','single'); ?>"/>
34
  </a>
35
  <?php
@@ -143,9 +143,9 @@
143
  <?php endif ;?>
144
  <div class="wpsc_product_price">
145
  <?php if(wpsc_product_has_stock()) : ?>
146
- <div class="in_stock"><?php _e('Product in stock', 'wpsc'); ?></div>
147
  <?php else: ?>
148
- <div class="out_of_stock"><?php _e('Product not in stock', 'wpsc'); ?></div>
149
  <?php endif; ?>
150
  <?php if(wpsc_product_is_donation()) : ?>
151
  <label for="donation_price_<?php echo wpsc_the_product_id(); ?>"><?php _e('Donation', 'wpsc'); ?>:</label>
@@ -158,6 +158,10 @@
158
  <?php if(wpsc_product_on_special()) : ?>
159
  <p class="pricedisplay product_<?php echo wpsc_the_product_id(); ?>"><?php _e('You save', 'wpsc'); ?>:<span class="yousave" id="yousave_<?php echo wpsc_the_product_id(); ?>"><?php echo wpsc_currency_display(wpsc_you_save('type=amount'), array('html' => false)); ?>! (<?php echo wpsc_you_save(); ?>%)</span></p>
160
  <?php endif; ?>
 
 
 
 
161
  <?php if(wpsc_show_pnp()) : ?>
162
  <p class="pricedisplay"><?php _e('Shipping', 'wpsc'); ?>:<span class="pp_price"><?php echo wpsc_product_postage_and_packaging(); ?></span></p>
163
  <?php endif; ?>
@@ -184,8 +188,8 @@
184
  <?php if(wpsc_product_has_stock()) : ?>
185
  <div class="wpsc_buy_button_container">
186
  <?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
187
- <?php $action = wpsc_product_external_link(wpsc_the_product_id()); ?>
188
- <input class="wpsc_buy_button" type="submit" value="<?php _e('Buy Now', 'wpsc'); ?>" onclick="gotoexternallink("<?php echo $action; ?>")">
189
  <?php else: ?>
190
  <input type="submit" value="<?php _e('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
191
  <?php endif; ?>
29
  while ( wpsc_have_products() ) : wpsc_the_product(); ?>
30
  <div class="imagecol">
31
  <?php if ( wpsc_the_product_thumbnail() ) : ?>
32
+ <a rel="product_<?php echo wpsc_the_product_id(); ?>" class="<?php echo wpsc_the_product_image_link_classes(); ?>" href="<?php echo wpsc_the_product_image(); ?>">
33
  <img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(get_option('product_image_width'),get_option('product_image_height'),'','single'); ?>"/>
34
  </a>
35
  <?php
143
  <?php endif ;?>
144
  <div class="wpsc_product_price">
145
  <?php if(wpsc_product_has_stock()) : ?>
146
+ <div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="in_stock"><?php _e('Product in stock', 'wpsc'); ?></div>
147
  <?php else: ?>
148
+ <div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="out_of_stock"><?php _e('Product not in stock', 'wpsc'); ?></div>
149
  <?php endif; ?>
150
  <?php if(wpsc_product_is_donation()) : ?>
151
  <label for="donation_price_<?php echo wpsc_the_product_id(); ?>"><?php _e('Donation', 'wpsc'); ?>:</label>
158
  <?php if(wpsc_product_on_special()) : ?>
159
  <p class="pricedisplay product_<?php echo wpsc_the_product_id(); ?>"><?php _e('You save', 'wpsc'); ?>:<span class="yousave" id="yousave_<?php echo wpsc_the_product_id(); ?>"><?php echo wpsc_currency_display(wpsc_you_save('type=amount'), array('html' => false)); ?>! (<?php echo wpsc_you_save(); ?>%)</span></p>
160
  <?php endif; ?>
161
+ <!-- multi currency code -->
162
+ <?php if(wpsc_product_has_multicurrency()) : ?>
163
+ <?php echo wpsc_display_product_multicurrency(); ?>
164
+ <?php endif; ?>
165
  <?php if(wpsc_show_pnp()) : ?>
166
  <p class="pricedisplay"><?php _e('Shipping', 'wpsc'); ?>:<span class="pp_price"><?php echo wpsc_product_postage_and_packaging(); ?></span></p>
167
  <?php endif; ?>
188
  <?php if(wpsc_product_has_stock()) : ?>
189
  <div class="wpsc_buy_button_container">
190
  <?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
191
+ <?php $action = wpsc_product_external_link( wpsc_the_product_id() ); ?>
192
+ <input class="wpsc_buy_button" type="submit" value="<?php echo wpsc_product_external_link_text( wpsc_the_product_id(), __( 'Buy Now', 'wpsc' ) ); ?>" onclick="return gotoexternallink('<?php echo $action; ?>', '<?php echo wpsc_product_external_link_target( wpsc_the_product_id() ); ?>')">
193
  <?php else: ?>
194
  <input type="submit" value="<?php _e('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
195
  <?php endif; ?>
wpsc-theme/wpsc-transaction_results.php CHANGED
@@ -9,24 +9,20 @@
9
  */
10
 
11
  global $wpsc_query, $purchase_log, $wpdb, $errorcode, $sessionid, $echo_to_screen, $cart, $message_html,$wpsc_purchlog_statuses;
12
-
13
  ?>
14
  <div class="wrap">
15
 
16
- <?php
17
- echo wpsc_transaction_theme();
18
- if ( ( true === $echo_to_screen ) && ( $cart != null ) && ( $errorcode == 0 ) && ( $sessionid != null ) ) {
19
-
20
- foreach($wpsc_purchlog_statuses as $status)
21
- if($status['order'] == $purchase_log['processed']) $the_status = $status;
22
-
23
- if(isset($the_status['is_transaction']) && 1 == $the_status['is_transaction'])
24
- _e('The Transaction was successful', 'wpsc')."<br />";
25
-
26
- echo "<br />" . nl2br(str_replace("$",'\$',$message_html));
27
- }elseif ( true === $echo_to_screen && ( !isset($purchase_log) ) ) {
28
- _e('Oops, there is nothing in your cart.', 'wpsc') . "<a href=".get_option("product_list_url").">" . __('Please visit our shop', 'wpsc') . "</a>";
29
- }
30
- ?>
31
 
32
  </div>
9
  */
10
 
11
  global $wpsc_query, $purchase_log, $wpdb, $errorcode, $sessionid, $echo_to_screen, $cart, $message_html,$wpsc_purchlog_statuses;
 
12
  ?>
13
  <div class="wrap">
14
 
15
+ <?php
16
+ echo wpsc_transaction_theme();
17
+ if ( ( true === $echo_to_screen ) && ( $cart != null ) && ( $errorcode == 0 ) && ( $sessionid != null ) ) {
18
+
19
+ // Code to check whether transaction is processed, true if accepted false if pending or incomplete
20
+
21
+
22
+ echo "<br />" . nl2br(str_replace("$",'\$',$message_html));
23
+ }elseif ( true === $echo_to_screen && ( !isset($purchase_log) ) ) {
24
+ _e('Oops, there is nothing in your cart.', 'wpsc') . "<a href=".get_option("product_list_url").">" . __('Please visit our shop', 'wpsc') . "</a>";
25
+ }
26
+ ?>
 
 
 
27
 
28
  </div>
wpsc-theme/wpsc-user-log.php CHANGED
@@ -16,6 +16,7 @@ global $files, $separator, $purchase_log, $col_count, $siteurl, $products, $link
16
  <a href="<?php echo get_option( 'user_account_url' ); ?>"><?php _e('Purchase History','wpsc'); ?></a> |
17
  <a href="<?php echo get_option( 'user_account_url' ) . $separator . "edit_profile=true"; ?>"><?php _e('Your Details','wpsc'); ?></a> |
18
  <a href="<?php echo get_option( 'user_account_url' ) . $separator . "downloads=true"; ?>"><?php _e('Your Downloads','wpsc'); ?></a>
 
19
  </div>
20
 
21
  <br />
16
  <a href="<?php echo get_option( 'user_account_url' ); ?>"><?php _e('Purchase History','wpsc'); ?></a> |
17
  <a href="<?php echo get_option( 'user_account_url' ) . $separator . "edit_profile=true"; ?>"><?php _e('Your Details','wpsc'); ?></a> |
18
  <a href="<?php echo get_option( 'user_account_url' ) . $separator . "downloads=true"; ?>"><?php _e('Your Downloads','wpsc'); ?></a>
19
+ <?php do_action('wpsc_additional_user_profile_links', '|'); ?>
20
  </div>
21
 
22
  <br />
wpsc-updates/database_template.php CHANGED
@@ -106,125 +106,6 @@ $wpsc_database_template[$table_name]['indexes']['product_id'] = " KEY `product_i
106
  $wpsc_database_template[$table_name]['indexes']['uniqueid'] = "UNIQUE KEY `uniqueid` ( `uniqueid` )";
107
  $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}download_status";
108
 
109
-
110
-
111
- // code to create or update the {$wpdb->prefix}wpsc_item_category_assoc table
112
- /*
113
- $table_name = WPSC_TABLE_ITEM_CATEGORY_ASSOC;
114
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
115
- $wpsc_database_template[$table_name]['columns']['product_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
116
- $wpsc_database_template[$table_name]['columns']['category_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
117
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
118
- $wpsc_database_template[$table_name]['indexes']['product_id'] = "UNIQUE KEY `product_id` (`product_id`,`category_id`)";
119
- $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}item_category_associations";
120
- */
121
-
122
-
123
- // code to create or update the {$wpdb->prefix}wpsc_product_categories table
124
- /*
125
- $table_name = WPSC_TABLE_PRODUCT_CATEGORIES;
126
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) NOT NULL auto_increment";
127
- $wpsc_database_template[$table_name]['columns']['group_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
128
- $wpsc_database_template[$table_name]['columns']['name'] = "text NOT NULL ";
129
- $wpsc_database_template[$table_name]['columns']['nice-name'] = "varchar(255) NOT NULL DEFAULT '' ";
130
- $wpsc_database_template[$table_name]['columns']['description'] = "text NOT NULL ";
131
- $wpsc_database_template[$table_name]['columns']['image'] = "text NULL ";
132
- $wpsc_database_template[$table_name]['columns']['fee'] = "varchar(1) NOT NULL DEFAULT '0' ";
133
- $wpsc_database_template[$table_name]['columns']['active'] = "varchar(1) NOT NULL DEFAULT '1' ";
134
- $wpsc_database_template[$table_name]['columns']['category_parent'] = "bigint(20) unsigned NULL DEFAULT '0' ";
135
- $wpsc_database_template[$table_name]['columns']['order'] = "bigint(20) unsigned NULL ";
136
- $wpsc_database_template[$table_name]['columns']['display_type'] = "varchar(10) NULL DEFAULT '' ";
137
- $wpsc_database_template[$table_name]['columns']['image_width'] = "varchar(32) NULL DEFAULT '' ";
138
- $wpsc_database_template[$table_name]['columns']['image_height'] = "varchar(32) NULL DEFAULT '' ";
139
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
140
- $wpsc_database_template[$table_name]['indexes']['group_id'] = " KEY `group_id` ( `group_id` )";
141
- $wpsc_database_template[$table_name]['indexes']['nice-name'] = " KEY `nice-name` ( `nice-name` )";
142
- $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}product_categories";
143
- */
144
-
145
-
146
- // code to create or update the {$wpdb->prefix}wpsc_product_files table
147
- /*
148
- $table_name = WPSC_TABLE_PRODUCT_FILES;
149
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
150
- $wpsc_database_template[$table_name]['columns']['product_id'] = "bigint(20) unsigned NULL";
151
- $wpsc_database_template[$table_name]['columns']['filename'] = "varchar(255) NOT NULL DEFAULT '' ";
152
- $wpsc_database_template[$table_name]['columns']['mimetype'] = "varchar(128) NOT NULL DEFAULT '' ";
153
- $wpsc_database_template[$table_name]['columns']['idhash'] = "varchar(45) NOT NULL DEFAULT '' ";
154
- $wpsc_database_template[$table_name]['columns']['preview'] = "varchar(255) NOT NULL DEFAULT '' ";
155
- $wpsc_database_template[$table_name]['columns']['preview_mimetype'] = "varchar(128) NOT NULL DEFAULT '' ";
156
- $wpsc_database_template[$table_name]['columns']['date'] = "varchar(255) NOT NULL DEFAULT '' ";
157
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
158
- $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}product_files";
159
- */
160
-
161
-
162
- // code to create or update the {$wpdb->prefix}wpsc_product_images table
163
- /*
164
- $table_name = WPSC_TABLE_PRODUCT_IMAGES;
165
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
166
- $wpsc_database_template[$table_name]['columns']['product_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
167
- $wpsc_database_template[$table_name]['columns']['image'] = "varchar(255) NOT NULL DEFAULT '' ";
168
- $wpsc_database_template[$table_name]['columns']['width'] = "mediumint(8) unsigned NULL DEFAULT '0' ";
169
- $wpsc_database_template[$table_name]['columns']['height'] = "mediumint(8) unsigned NULL DEFAULT '0' ";
170
- $wpsc_database_template[$table_name]['columns']['image_order'] = "bigint(20) NOT NULL DEFAULT '0' ";
171
- $wpsc_database_template[$table_name]['columns']['meta'] = "longtext NULL";
172
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
173
- $wpsc_database_template[$table_name]['indexes']['product_id'] = " KEY `product_id` ( `product_id` )";
174
- $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}product_images";
175
- */
176
-
177
-
178
- // code to create or update the {$wpdb->prefix}wpsc_product_list table
179
- /*
180
- $table_name = WPSC_TABLE_PRODUCT_LIST;
181
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
182
- $wpsc_database_template[$table_name]['columns']['name'] = "text NOT NULL ";
183
- $wpsc_database_template[$table_name]['columns']['description'] = "longtext NOT NULL";
184
- $wpsc_database_template[$table_name]['columns']['additional_description'] = "longtext NOT NULL ";
185
- $wpsc_database_template[$table_name]['columns']['price'] = "decimal(11,2) NOT NULL DEFAULT '0' ";
186
- $wpsc_database_template[$table_name]['columns']['weight'] = "float NOT NULL DEFAULT '0' ";
187
- $wpsc_database_template[$table_name]['columns']['weight_unit'] = "varchar(10) NOT NULL DEFAULT '' ";
188
- $wpsc_database_template[$table_name]['columns']['pnp'] = "decimal(11,2) NOT NULL DEFAULT '0' ";
189
- $wpsc_database_template[$table_name]['columns']['international_pnp'] = "decimal(11,2) NOT NULL DEFAULT '0' ";
190
- $wpsc_database_template[$table_name]['columns']['file'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
191
- $wpsc_database_template[$table_name]['columns']['image'] = "bigint(20) unsigned NULL DEFAULT NULL ";
192
- $wpsc_database_template[$table_name]['columns']['quantity_limited'] = "varchar(1) NOT NULL DEFAULT '' ";
193
- $wpsc_database_template[$table_name]['columns']['quantity'] = "int(10) unsigned NOT NULL DEFAULT '0' ";
194
- $wpsc_database_template[$table_name]['columns']['special'] = "varchar(1) NOT NULL DEFAULT '0' ";
195
- $wpsc_database_template[$table_name]['columns']['special_price'] = "decimal(11,2) NOT NULL DEFAULT '0' ";
196
- $wpsc_database_template[$table_name]['columns']['display_frontpage'] = "varchar(1) NOT NULL DEFAULT '0' ";
197
- $wpsc_database_template[$table_name]['columns']['notax'] = "varchar(1) NOT NULL DEFAULT '0' ";
198
- $wpsc_database_template[$table_name]['columns']['publish'] = "varchar(1) NOT NULL DEFAULT '1' ";
199
- $wpsc_database_template[$table_name]['columns']['active'] = "varchar(1) NOT NULL DEFAULT '1' ";
200
- $wpsc_database_template[$table_name]['columns']['donation'] = "varchar(1) NOT NULL DEFAULT '0' ";
201
- $wpsc_database_template[$table_name]['columns']['no_shipping'] = "varchar(1) NOT NULL DEFAULT '0' ";
202
- $wpsc_database_template[$table_name]['columns']['thumbnail_image'] = "text NULL ";
203
- $wpsc_database_template[$table_name]['columns']['thumbnail_state'] = "int(11) NOT NULL DEFAULT '0' ";
204
- $wpsc_database_template[$table_name]['columns']['date_added'] = "TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
205
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
206
- $wpsc_database_template[$table_name]['actions']['before']['international_pnp'] = "wpsc_update_remove_nulls";
207
- $wpsc_database_template[$table_name]['actions']['before']['special_price'] = "wpsc_update_remove_nulls";
208
- $wpsc_database_template[$table_name]['actions']['before']['image'] = "wpsc_update_image_records";
209
- $wpsc_database_template[$table_name]['actions']['after']['date_added'] = "wpsc_set_product_creation_dates";
210
- $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}product_list";
211
- */
212
-
213
-
214
- // code to create or update the {$wpdb->prefix}wpsc_product_order table
215
- /*
216
- $table_name = WPSC_TABLE_PRODUCT_ORDER;
217
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
218
- $wpsc_database_template[$table_name]['columns']['category_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
219
- $wpsc_database_template[$table_name]['columns']['product_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
220
- $wpsc_database_template[$table_name]['columns']['order'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
221
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
222
- $wpsc_database_template[$table_name]['indexes']['category_id'] = "UNIQUE KEY `category_id` (`category_id`,`product_id`)";
223
- $wpsc_database_template[$table_name]['indexes']['order'] = " KEY `order` ( `order` )";
224
- $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}product_order";
225
- */
226
-
227
-
228
  // code to create or update the {$wpdb->prefix}wpsc_product_rating table
229
  $table_name = WPSC_TABLE_PRODUCT_RATING; /* !wpsc_product_rating */
230
  $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
106
  $wpsc_database_template[$table_name]['indexes']['uniqueid'] = "UNIQUE KEY `uniqueid` ( `uniqueid` )";
107
  $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}download_status";
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  // code to create or update the {$wpdb->prefix}wpsc_product_rating table
110
  $table_name = WPSC_TABLE_PRODUCT_RATING; /* !wpsc_product_rating */
111
  $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
wpsc-updates/update.php DELETED
@@ -1,130 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * more code to update from old versions, messy code too
5
- */
6
-
7
- $coldata = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` LIKE 'image'", ARRAY_A );
8
- if ( $coldata == null )
9
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` ADD `image` TEXT NOT NULL DEFAULT '' AFTER `description`" );
10
-
11
- $coldata2 = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIKE 'quantity_limited'", ARRAY_A );
12
- if ( $coldata2 == null ) {
13
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` ADD `quantity_limited` VARCHAR( 1 ) NOT NULL DEFAULT '0' AFTER `category`" );
14
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` ADD `quantity` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `quantity_limited`" );
15
- }
16
-
17
- $coldata3 = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIKE 'file'", ARRAY_A );
18
- if ( $coldata3 == null )
19
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` ADD `file` BIGINT UNSIGNED NOT NULL AFTER `category`" );
20
-
21
- $coldata4 = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIKE 'special_price'", ARRAY_A );
22
- if ( $coldata4 == null )
23
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` ADD `special_price` VARCHAR( 20 ) NOT NULL AFTER `special`" );
24
-
25
- $coldata5 = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` LIKE 'processed'", ARRAY_A );
26
- if ( $coldata5[0]['Type'] == "char(1)" )
27
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PURCHASE_LOGS . "` CHANGE `processed` `processed` BIGINT UNSIGNED NOT NULL DEFAULT '1'" );
28
-
29
- $coldata6 = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_CART_CONTENTS . "` LIKE 'price'", ARRAY_A );
30
- if ( $coldata6 == null ) {
31
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_CART_CONTENTS . "` ADD `price` VARCHAR( 128 ) NOT NULL" );
32
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_CART_CONTENTS . "` ADD `pnp` VARCHAR( 128 ) NOT NULL" );
33
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_CART_CONTENTS . "` ADD `gst` VARCHAR( 128 ) NOT NULL" );
34
- }
35
-
36
- $coldata7 = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIKE 'brand'", ARRAY_A );
37
- if ( $coldata7 == null )
38
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` ADD `brand` BIGINT UNSIGNED NOT NULL AFTER `category`" );
39
-
40
- $coldata8 = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIKE 'additional_description'", ARRAY_A );
41
- if ( $coldata8 == null )
42
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` ADD `additional_description` LONGTEXT NOT NULL AFTER `description`" );
43
-
44
- $coldata9 = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIKE 'pnp'", ARRAY_A );
45
- if ( $coldata9[0]['Type'] != "varchar(20)" ) {
46
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` CHANGE `pnp` `pnp` VARCHAR( 20 ) DEFAULT '0' NOT NULL" );
47
- }
48
-
49
- $add_cart_quantity = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_CART_CONTENTS . "` LIKE 'quantity'", ARRAY_A );
50
- if ( $add_cart_quantity == null )
51
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_CART_CONTENTS . "` ADD `quantity` INT UNSIGNED NOT NULL AFTER `gst` ;" );
52
-
53
- $add_cart_donation = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_CART_CONTENTS . "` LIKE 'donation'", ARRAY_A );
54
- if ( $add_cart_donation == null )
55
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_CART_CONTENTS . "` ADD `donation` VARCHAR( 1 ) NOT NULL AFTER `quantity` ;" );
56
-
57
- $add_international_pnp = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIKE 'international_pnp'", ARRAY_A );
58
- if ( $add_international_pnp == null )
59
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` ADD `international_pnp` VARCHAR( 20 ) NOT NULL AFTER `pnp`;" );
60
-
61
- $add_gateway_log = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` LIKE 'gateway'", ARRAY_A );
62
- if ( $add_gateway_log == null ) {
63
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PURCHASE_LOGS . "` ADD `gateway` VARCHAR( 64 ) NOT NULL AFTER `date`;" );
64
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PURCHASE_LOGS . "` ADD INDEX ( `gateway` ) ;" );
65
- }
66
-
67
- $add_shipping_country = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` LIKE 'shipping_country'", ARRAY_A );
68
- if ( $add_shipping_country == null )
69
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PURCHASE_LOGS . "` ADD `shipping_country` CHAR( 6 ) NOT NULL AFTER `gateway`;" );
70
-
71
- $add_shipping_country = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` LIKE 'user_ID'", ARRAY_A );
72
- if ( $add_shipping_country == null )
73
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PURCHASE_LOGS . "` ADD `user_ID` BIGINT UNSIGNED NULL AFTER `processed`;" );
74
-
75
- $add_billing_country = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` LIKE 'billing_country'", ARRAY_A );
76
- if ( $add_billing_country == null ) {
77
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PURCHASE_LOGS . "` ADD `billing_country` CHAR( 6 ) NOT NULL AFTER `gateway`;" );
78
- // copy shipping_country into billing_country, shipping_country did the job of both before
79
- $wpdb->query( "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `billing_country` = `shipping_country`" );
80
- }
81
- // `email_sent` CHAR( 1 ) NOT NULL,
82
-
83
- $add_email_sent = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` LIKE 'email_sent'", ARRAY_A );
84
- if ( $add_email_sent == null )
85
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PURCHASE_LOGS . "` ADD `email_sent` CHAR( 1 ) DEFAULT '0' NOT NULL AFTER `shipping_country`;" );
86
-
87
- $add_shipping_region = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` LIKE 'shipping_region'", ARRAY_A );
88
- if ( $add_shipping_region == null )
89
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PURCHASE_LOGS . "` ADD `shipping_region` CHAR( 6 ) NOT NULL AFTER `shipping_country`;" );
90
-
91
- $add_display_frontpage = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIKE 'display_frontpage';", ARRAY_A );
92
- if ( $add_display_frontpage == null )
93
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` ADD `display_frontpage` VARCHAR( 1 ) NOT NULL AFTER `special_price`;" );
94
-
95
- $add_currency_tax = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_CURRENCY_LIST . "` LIKE 'tax';", ARRAY_A );
96
- if ( $add_currency_tax == null )
97
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_CURRENCY_LIST . "` ADD `tax` VARCHAR( 8 ) NOT NULL AFTER `code`;" );
98
-
99
- $add_currency_has_regions = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_CURRENCY_LIST . "` LIKE 'has_regions';", ARRAY_A );
100
- if ( $add_currency_has_regions == null )
101
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_CURRENCY_LIST . "` ADD `has_regions` VARCHAR( 8 ) NOT NULL AFTER `code`;" );
102
-
103
- $add_product_thumbnail = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIKE 'thumbnail_image';", ARRAY_A );
104
- if ( $add_product_thumbnail == null )
105
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` ADD `thumbnail_image` TEXT NULL AFTER `active`;" );
106
-
107
- $add_thumbnail_state = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIKE 'thumbnail_state';", ARRAY_A );
108
- if ( $add_thumbnail_state == null )
109
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` ADD `thumbnail_state` INTEGER NOT NULL AFTER `active`;" );
110
-
111
- $add_thumbnail_state = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIKE 'donation';", ARRAY_A );
112
- if ( $add_thumbnail_state == null )
113
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` ADD `donation` VARCHAR( 1 ) DEFAULT '0' NOT NULL AFTER `active`;" );
114
-
115
- $add_no_shipping = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIKE 'no_shipping'", ARRAY_A );
116
- if ( $add_no_shipping == null )
117
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_LIST . "` ADD `no_shipping` VARCHAR( 1 ) DEFAULT '0' NOT NULL AFTER `donation` ;" );
118
-
119
- $add_cart_no_shipping = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_CART_CONTENTS . "` LIKE 'no_shipping'", ARRAY_A );
120
- if ( $add_cart_no_shipping == null )
121
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_CART_CONTENTS . "` ADD `no_shipping` VARCHAR( 1 ) DEFAULT '0' NOT NULL AFTER `donation` ;" );
122
-
123
-
124
- $add_category_parent = $wpdb->get_results( "SHOW FULL COLUMNS FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` LIKE 'category_parent'", ARRAY_A );
125
- if ( $add_category_parent == null ) {
126
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` ADD `category_parent` BIGINT UNSIGNED DEFAULT '0' NOT NULL AFTER `active`" );
127
- $wpdb->query( "ALTER TABLE `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` ADD INDEX ( `category_parent` )" );
128
- }
129
-
130
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-updates/updating_tasks.php CHANGED
@@ -7,30 +7,6 @@ if(get_option('wpsc_trackingid_subject') == ''){
7
  update_option('wpsc_trackingid_subject', __('Your Order from %shop_name% has been dispatched', 'wpsc'));
8
  }
9
 
10
-
11
- /*
12
- if(!$wpdb->get_results("SELECT `id` FROM `".WPSC_TABLE_ALSO_BOUGHT."`")) {
13
- // inserts data on what was bought with what however many times
14
- $product_ids = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `active` IN('1')");
15
- foreach((array)$product_ids as $prodid) {
16
- $cart_ids = $wpdb->get_results("SELECT `purchaseid` FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `prodid` IN ('$prodid')", ARRAY_A);
17
- $popular_array = array();
18
- foreach((array)$cart_ids as $cart_id) {
19
- $purchase_data = $wpdb->get_results("SELECT `prodid` FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid` IN ('".$cart_id['purchaseid']."') AND `prodid` NOT IN('$prodid')", ARRAY_A);
20
- foreach((array)$purchase_data as $purchase_row) {
21
- if(isset($popular_array[$purchase_row['prodid']])) {
22
- $popular_array[$purchase_row['prodid']]++;
23
- } else {
24
- $popular_array[$purchase_row['prodid']] = 1;
25
- }
26
- }
27
- }
28
- foreach((array)$popular_array as $assoc_prodid => $quantity) {
29
- $wpdb->query("INSERT INTO `".WPSC_TABLE_ALSO_BOUGHT."` ( `id` , `selected_product` , `associated_product` , `quantity` ) VALUES ('', '$prodid', '".$assoc_prodid."', '".$quantity."' );");
30
- }
31
- }
32
- }*/
33
-
34
  if($wpdb->get_results("SHOW FULL COLUMNS FROM `".WPSC_TABLE_REGION_TAX."` LIKE 'code';",ARRAY_A)) {
35
  //$wpdb->query("ALTER TABLE `".WPSC_TABLE_REGION_TAX."` ADD `code` char(2) NOT NULL default '' AFTER `name`;");
36
 
7
  update_option('wpsc_trackingid_subject', __('Your Order from %shop_name% has been dispatched', 'wpsc'));
8
  }
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  if($wpdb->get_results("SHOW FULL COLUMNS FROM `".WPSC_TABLE_REGION_TAX."` LIKE 'code';",ARRAY_A)) {
11
  //$wpdb->query("ALTER TABLE `".WPSC_TABLE_REGION_TAX."` ADD `code` char(2) NOT NULL default '' AFTER `name`;");
12
 
wpsc-widgets/donations_widget.php CHANGED
@@ -144,6 +144,7 @@ function wpsc_donations( $args = null ) {
144
  'order' => 'ASC'
145
  ) );
146
  $attached_image = $attached_images[0];
 
147
  if ( ( $attached_image->ID > 0 ) ) {
148
  $output .= "<img src='" . wpsc_product_image( $attached_image->ID, get_option( 'product_image_width' ), get_option( 'product_image_height' ) ) . "' title='" . $product['post_title'] . "' alt='" . $product['post_title'] . "' /><br />";
149
  }
@@ -163,7 +164,7 @@ function wpsc_donations( $args = null ) {
163
  $output .= "<label for='donation_widget_price_" . $product['ID'] . "'>" . __( 'Donation', 'wpsc' ) . ":</label> $currency_symbol<input type='text' id='donation_widget_price_" . $product['ID'] . "' name='donation_price' value='" . number_format( $price, 2 ) . "' size='6' /><br />";
164
  $output .= "<input type='submit' name='Buy' class='wpsc_buy_button' value='" . __( 'Add To Cart', 'wpsc' ) . "' />";
165
  $output .= "</form>";
166
-
167
  }
168
  } else {
169
  $output = '';
144
  'order' => 'ASC'
145
  ) );
146
  $attached_image = $attached_images[0];
147
+ $output .= "<div class='wpsc_product_donation'>";
148
  if ( ( $attached_image->ID > 0 ) ) {
149
  $output .= "<img src='" . wpsc_product_image( $attached_image->ID, get_option( 'product_image_width' ), get_option( 'product_image_height' ) ) . "' title='" . $product['post_title'] . "' alt='" . $product['post_title'] . "' /><br />";
150
  }
164
  $output .= "<label for='donation_widget_price_" . $product['ID'] . "'>" . __( 'Donation', 'wpsc' ) . ":</label> $currency_symbol<input type='text' id='donation_widget_price_" . $product['ID'] . "' name='donation_price' value='" . number_format( $price, 2 ) . "' size='6' /><br />";
165
  $output .= "<input type='submit' name='Buy' class='wpsc_buy_button' value='" . __( 'Add To Cart', 'wpsc' ) . "' />";
166
  $output .= "</form>";
167
+ $output .= "</div>";
168
  }
169
  } else {
170
  $output = '';
wpsc-widgets/specials_widget.php CHANGED
@@ -202,6 +202,7 @@ function wpsc_specials( $args = null, $instance ) {
202
  endif;
203
  endwhile;
204
  list( $wp_query, $special_products ) = array( $special_products, $wp_query ); // swap the wpsc_query object
 
205
  }
206
  }
207
  function wpsc_specials_excludes(){
202
  endif;
203
  endwhile;
204
  list( $wp_query, $special_products ) = array( $special_products, $wp_query ); // swap the wpsc_query object
205
+ wp_reset_query();
206
  }
207
  }
208
  function wpsc_specials_excludes(){
wpsc-widgets/tagging_functions.php CHANGED
@@ -18,7 +18,6 @@ function product_tag_cloud( $args = '' ) {
18
 
19
  // Always query top tags
20
  $tags = get_product_tags( array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) );
21
-
22
  if ( empty( $tags ) )
23
  return;
24
 
18
 
19
  // Always query top tags
20
  $tags = get_product_tags( array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) );
 
21
  if ( empty( $tags ) )
22
  return;
23