WP eCommerce - Version 3.8.Public.Beta

Version Description

Download this release

Release Info

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

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

Files changed (85) hide show
  1. wpsc-admin/admin-form-functions.php +1 -11
  2. wpsc-admin/admin.php +73 -120
  3. wpsc-admin/ajax-and-init.php +24 -86
  4. wpsc-admin/css/admin.css +1 -1
  5. wpsc-admin/display-coupons.php +0 -1
  6. wpsc-admin/display-debug.page.php +7 -11
  7. wpsc-admin/display-groups.page.php +1 -2
  8. wpsc-admin/display-items.page.php +0 -17
  9. wpsc-admin/display-sales-logs.php +3 -6
  10. wpsc-admin/display-update.page.php +0 -1
  11. wpsc-admin/display-variations.page.php +0 -11
  12. wpsc-admin/includes/display-items-functions.php +0 -27
  13. wpsc-admin/includes/product-functions.php +20 -54
  14. wpsc-admin/includes/products.php +62 -27
  15. wpsc-admin/includes/purchlogs_upgrade.php +0 -7
  16. wpsc-admin/includes/save-data.functions.php +0 -20
  17. wpsc-admin/includes/settings-pages/admin.php +1 -57
  18. wpsc-admin/includes/settings-pages/checkout.php +0 -4
  19. wpsc-admin/includes/settings-pages/gateway.php +0 -3
  20. wpsc-admin/includes/settings-pages/general.php +0 -39
  21. wpsc-admin/includes/settings-pages/import.php +0 -4
  22. wpsc-admin/includes/settings-pages/presentation.php +1 -3
  23. wpsc-admin/includes/settings-pages/shipping.php +0 -2
  24. wpsc-admin/includes/tax_and_shipping.php +0 -18
  25. wpsc-admin/includes/updating-functions.php +0 -4
  26. wpsc-core/images/icon32.png +0 -0
  27. wpsc-core/js/tinymce3/editor_plugin.js +3 -14
  28. wpsc-core/js/user.js +5 -55
  29. wpsc-core/js/wp-e-commerce.js +8 -12
  30. wpsc-core/wpsc-deprecated.php +0 -1
  31. wpsc-core/wpsc-functions.php +0 -18
  32. wpsc-core/wpsc-includes.php +0 -1
  33. wpsc-core/wpsc-installer.php +78 -85
  34. wpsc-includes/ajax.functions.php +3 -23
  35. wpsc-includes/breadcrumbs.class.php +0 -5
  36. wpsc-includes/cart.class.php +2 -91
  37. wpsc-includes/category.functions.php +0 -45
  38. wpsc-includes/checkout.class.php +7 -33
  39. wpsc-includes/coupons.class.php +0 -15
  40. wpsc-includes/currency_converter.inc.php +0 -3
  41. wpsc-includes/display.functions.php +0 -2
  42. wpsc-includes/form-display.functions.php +0 -5
  43. wpsc-includes/image_processing.php +0 -9
  44. wpsc-includes/merchant.class.php +0 -5
  45. wpsc-includes/meta.functions.php +0 -3
  46. wpsc-includes/misc.functions.php +0 -15
  47. wpsc-includes/processing.functions.php +36 -36
  48. wpsc-includes/product-template.php +1 -25
  49. wpsc-includes/productfeed.php +3 -8
  50. wpsc-includes/purchaselogs.class.php +0 -116
  51. wpsc-includes/rss_template.php +0 -1
  52. wpsc-includes/share-this.php +0 -11
  53. wpsc-includes/shopping_cart_functions.php +0 -4
  54. wpsc-includes/shortcode.functions.php +9 -16
  55. wpsc-includes/theme.functions.php +13 -13
  56. wpsc-includes/theming.class.php +0 -1
  57. wpsc-includes/variations.class.php +0 -13
  58. wpsc-languages/EN_en.php +2 -2
  59. wpsc-merchants/GoogleCheckout-XML.php +104 -150
  60. wpsc-merchants/library/googlecart.php +5 -11
  61. wpsc-merchants/library/googlecart1.php +0 -1644
  62. wpsc-merchants/library/googleshipping.php +0 -12
  63. wpsc-merchants/paypal-express.merchant.php +0 -3
  64. wpsc-merchants/paypal-pro.merchant.php +0 -19
  65. wpsc-merchants/paypal-standard.merchant.php +0 -7
  66. wpsc-merchants/paypal_certified.php +0 -1147
  67. wpsc-merchants/testmode.merchant.php +0 -3
  68. wpsc-shipping/flatrate.php +0 -38
  69. wpsc-shipping/library/shipwire_functions.php +0 -5
  70. wpsc-shipping/nzpost.php +0 -83
  71. wpsc-shipping/tablerate.php +0 -27
  72. wpsc-shipping/ups.php +9 -29
  73. wpsc-shipping/usps.php +0 -22
  74. wpsc-shipping/weightrate.php +0 -32
  75. wpsc-taxes/controllers/taxes_controller.class.php +12 -14
  76. wpsc-theme/functions/wpsc-transaction_results_functions.php +0 -2
  77. wpsc-theme/functions/wpsc-user_log_functions.php +1 -11
  78. wpsc-theme/wpsc-cart_widget.php +0 -3
  79. wpsc-theme/wpsc-products_page.php +0 -2
  80. wpsc-theme/wpsc-shopping_cart_page.php +2 -5
  81. wpsc-theme/wpsc-single_product.php +0 -1
  82. wpsc-updates/database_template.php +0 -140
  83. wpsc-updates/updating_tasks.php +2 -12
  84. wpsc-widgets/latest_product_widget.php +2 -2
  85. wpsc-widgets/tagging_functions.php +0 -5
wpsc-admin/admin-form-functions.php CHANGED
@@ -1,10 +1,7 @@
1
  <?php
2
- // ini_set('display_errors','1');
3
-
4
  function coupon_edit_form($coupon) {
5
 
6
  $conditions = unserialize($coupon['condition']);
7
- //exit('<pre>'.print_r($coupon, true).'</pre>');
8
 
9
  $start_timestamp = strtotime($coupon['start']);
10
  $end_timestamp = strtotime($coupon['expiry']);
@@ -173,9 +170,7 @@ function setting_button(){
173
  $output.="<li><a href='admin.php?page=wpsc-settings'>".__('Shop Settings', 'wpsc')."</a></li>";
174
  $output.="<li><a href='admin.php?page=wpsc-settings&amp;tab=gateway'>".__('Money and Payment', 'wpsc')."</a></li>";
175
  $output.="<li><a href='admin.php?page=wpsc-settings&amp;tab=checkout'>".__('Checkout Page Settings', 'wpsc')."</a></li>";
176
- //$output.="<li><a href='?page=".WPSC_DIR_NAME."/instructions.php'>Help/Upgrade</a></li>";
177
  $output.="</ul>";
178
- // $output.="<div>Checkout Settings</div>";
179
  $output.="</span>&emsp;&emsp;</div>";
180
 
181
  return $output;
@@ -224,7 +219,6 @@ function wpsc_right_now() {
224
  $output .= "<div class='inside'>";
225
  $output .= "<div class='table'>";
226
  $output .= "<p class='sub'>".__('At a Glance', 'wpsc')."</p>";
227
- //$output.="<p class='youhave'>".__('You have <a href='admin.php?page=wpsc-edit-products'>:productcount:</a>, contained within <a href='admin.php?page=wpsc-edit-groups'>:groupcount:</a>. This month you made :salecount: and generated a total of :monthtotal: and your total sales ever is :overaltotal:. You have :pendingcount: awaiting approval.', 'wpsc')."</p>";
228
  $output .= "<table style='border-top:1px solid #ececec;'>";
229
  $output .= "<tr class='first'>";
230
  $output .= "<td class='first b'>";
@@ -281,13 +275,10 @@ function wpsc_right_now() {
281
  $output.=" <h3 class='reallynow'>\n\r";
282
  $output.=" <a class='rbutton' href='admin.php?page=wpsc-edit-products'><strong>".__('Add New Product', 'wpsc')."</strong></a>\n\r";
283
  $output.=" <span>"._('Right Now')."</span>\n\r";
284
- //$output.=" <br class='clear'/>\n\r";
285
  $output.=" </h3>\n\r";
286
  $output.="<p class='youhave'>".__('You have <a href="admin.php?page=wpsc-edit-products">:productcount:</a>, contained within <a href="admin.php?page=wpsc-edit-groups">:groupcount:</a>. This month you made :salecount: and generated a total of :monthtotal: and your total sales ever is :overaltotal:. You have :pendingcount: awaiting approval.', 'wpsc')."</p>\n\r";
287
  $output.=" <p class='youare'>\n\r";
288
  $output.=" ".__('You are using the :theme: style. This is WP e-Commerce :versionnumber:.', 'wpsc')."\n\r";
289
- //$output.=" <a class='rbutton' href='themes.php'>Change Theme</a>\n\r";
290
- //$output.="<span id='wp-version-message'>This is WordPress version 2.6. <a class='rbutton' href='http://wordpress.org/download/'>Update to 2.6.1</a></span>\n\r";
291
  $output.=" </p>\n\r";
292
  $output.="</div>\n\r";
293
  $output.="<br />\n\r";
@@ -301,7 +292,6 @@ function wpsc_packing_slip($purchase_id) {
301
  global $wpdb;
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."";
@@ -402,7 +392,7 @@ function wpsc_packing_slip($purchase_id) {
402
  if(($j % 2) != 0) {
403
  $alternate = "class='alt'";
404
  }
405
- //$cart_row['prodid']
406
 
407
  $variation_list = '';
408
 
1
  <?php
 
 
2
  function coupon_edit_form($coupon) {
3
 
4
  $conditions = unserialize($coupon['condition']);
 
5
 
6
  $start_timestamp = strtotime($coupon['start']);
7
  $end_timestamp = strtotime($coupon['expiry']);
170
  $output.="<li><a href='admin.php?page=wpsc-settings'>".__('Shop Settings', 'wpsc')."</a></li>";
171
  $output.="<li><a href='admin.php?page=wpsc-settings&amp;tab=gateway'>".__('Money and Payment', 'wpsc')."</a></li>";
172
  $output.="<li><a href='admin.php?page=wpsc-settings&amp;tab=checkout'>".__('Checkout Page Settings', 'wpsc')."</a></li>";
 
173
  $output.="</ul>";
 
174
  $output.="</span>&emsp;&emsp;</div>";
175
 
176
  return $output;
219
  $output .= "<div class='inside'>";
220
  $output .= "<div class='table'>";
221
  $output .= "<p class='sub'>".__('At a Glance', 'wpsc')."</p>";
 
222
  $output .= "<table style='border-top:1px solid #ececec;'>";
223
  $output .= "<tr class='first'>";
224
  $output .= "<td class='first b'>";
275
  $output.=" <h3 class='reallynow'>\n\r";
276
  $output.=" <a class='rbutton' href='admin.php?page=wpsc-edit-products'><strong>".__('Add New Product', 'wpsc')."</strong></a>\n\r";
277
  $output.=" <span>"._('Right Now')."</span>\n\r";
 
278
  $output.=" </h3>\n\r";
279
  $output.="<p class='youhave'>".__('You have <a href="admin.php?page=wpsc-edit-products">:productcount:</a>, contained within <a href="admin.php?page=wpsc-edit-groups">:groupcount:</a>. This month you made :salecount: and generated a total of :monthtotal: and your total sales ever is :overaltotal:. You have :pendingcount: awaiting approval.', 'wpsc')."</p>\n\r";
280
  $output.=" <p class='youare'>\n\r";
281
  $output.=" ".__('You are using the :theme: style. This is WP e-Commerce :versionnumber:.', 'wpsc')."\n\r";
 
 
282
  $output.=" </p>\n\r";
283
  $output.="</div>\n\r";
284
  $output.="<br />\n\r";
292
  global $wpdb;
293
  $purch_sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`='".$purchase_id."'";
294
  $purch_data = $wpdb->get_row($purch_sql,ARRAY_A) ;
 
295
  //echo "<p style='padding-left: 5px;'><strong>".__('Date', 'wpsc')."</strong>:".date("jS M Y", $purch_data['date'])."</p>";
296
 
297
  $cartsql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=".$purchase_id."";
392
  if(($j % 2) != 0) {
393
  $alternate = "class='alt'";
394
  }
395
+ // product ID will be $cart_row['prodid']. need to fetch name and stuff
396
 
397
  $variation_list = '';
398
 
wpsc-admin/admin.php CHANGED
@@ -179,7 +179,7 @@ function wpsc_admin_pages() {
179
  }
180
 
181
  function wpsc_product_log_rss_feed() {
182
- echo "<link type='application/rss+xml' href='" . get_option( 'siteurl' ) . "/wp-admin/index.php?rss=true&amp;rss_key=key&amp;action=purchase_log&amp;type=rss' title='WP E-Commerce Purchase Log RSS' rel='alternate'/>";
183
  }
184
 
185
  function wpsc_admin_include_coupon_js() {
@@ -385,23 +385,23 @@ function wpsc_admin_dynamic_css() {
385
 
386
  if ( $flash = 1 ) {
387
  ?>
388
- div.flash-image-uploader {
389
- display: block;
390
- }
391
 
392
- div.browser-image-uploader {
393
- display: none;
394
- }
395
  <?php
396
  } else {
397
  ?>
398
- div.flash-image-uploader {
399
- display: none;
400
- }
401
 
402
- div.browser-image-uploader {
403
- display: block;
404
- }
405
  <?php
406
  }
407
  exit();
@@ -411,32 +411,18 @@ if ( isset( $_GET['wpsc_admin_dynamic_css'] ) && ($_GET['wpsc_admin_dynamic_css'
411
  add_action( "admin_init", 'wpsc_admin_dynamic_css' );
412
  }
413
 
414
-
415
- //add_action("admin_init", 'wpsc_admin_css_and_js');
416
  add_action( 'admin_menu', 'wpsc_admin_pages' );
417
 
418
 
419
- /*
420
- * Inserts the summary box on the WordPress Dashboard
421
- */
422
-
423
- //if(function_exists('wp_add_dashboard_widget')) {
424
- if ( IS_WP27 ) {
425
- add_action( 'wp_dashboard_setup', 'wpsc_dashboard_widget_setup' );
426
- } else {
427
- add_action( 'activity_box_end', 'wpsc_admin_dashboard_rightnow' );
428
- }
429
-
430
  function wpsc_admin_latest_activity() {
431
  global $wpdb;
432
  $totalOrders = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "`" );
433
 
434
-
435
  /*
436
  * This is the right hand side for the past 30 days revenue on the wp dashboard
437
  */
438
  echo "<div id='leftDashboard'>";
439
- echo "<strong class='dashboardHeading'>" . __( 'Last 30 Days', 'wpsc' ) . "</strong><br />";
440
  echo "<p class='dashboardWidgetSpecial'>";
441
  // calculates total amount of orders for the month
442
  $year = date( "Y" );
@@ -458,7 +444,6 @@ function wpsc_admin_latest_activity() {
458
  echo "<span class='dashboardWidget'>" . __( 'Orders', 'wpsc' ) . "</span>";
459
  echo "</p>";
460
  echo "<p class='dashboardWidgetSpecial'>";
461
- //echo "<span class='pricedisplay'>";
462
  //calculates average sales amount per order for the month
463
  if ( $currentMonthOrders > 0 ) {
464
  $monthsAverage = ((int)admin_display_total_price( $start_timestamp, $end_timestamp ) / (int)$currentMonthOrders);
@@ -467,15 +452,13 @@ function wpsc_admin_latest_activity() {
467
  //echo "</span>";
468
  echo "<span class='dashboardWidget'>" . __( 'Avg Orders', 'wpsc' ) . "</span>";
469
  echo "</p>";
470
-
471
-
472
  echo "</div>";
473
  /*
474
  * This is the left side for the total life time revenue on the wp dashboard
475
  */
476
 
477
  echo "<div id='rightDashboard' >";
478
- echo "<strong class='dashboardHeading'>" . __( 'Life Time', 'wpsc' ) . "</strong><br />";
479
 
480
  echo "<p class='dashboardWidgetSpecial'>";
481
  echo wpsc_currency_display( admin_display_total_price() );
@@ -488,7 +471,6 @@ function wpsc_admin_latest_activity() {
488
  echo "<span class='dashboardWidget'>" . __( 'Orders', 'wpsc' ) . "</span>";
489
  echo "</p>";
490
  echo "<p class='dashboardWidgetSpecial'>";
491
- //echo "<span class='pricedisplay'>";
492
  //calculates average sales amount per order for the month
493
  if ( (admin_display_total_price() > 0) && ($totalOrders > 0) ) {
494
  $totalAverage = ((int)admin_display_total_price() / (int)$totalOrders);
@@ -506,56 +488,63 @@ function wpsc_admin_latest_activity() {
506
  add_action( 'wpsc_admin_pre_activity', 'wpsc_admin_latest_activity' );
507
 
508
 
509
-
510
-
511
-
512
- /*
513
- * Pre-2.7 Dashboard Information
514
- */
515
-
516
- function wpsc_admin_dashboard_rightnow() {
517
- $user = wp_get_current_user();
518
- if ( $user->user_level > 9 ) {
519
- echo "<div>";
520
- echo "<h3>" . __( 'e-Commerce', 'wpsc' ) . "</h3>";
521
- echo "<p>";
522
- do_action( 'wpsc_admin_pre_activity' );
523
- // wpsc_admin_latest_activity();
524
- do_action( 'wpsc_admin_post_activity' );
525
- echo "</div>";
526
- }
527
- }
528
-
529
  /*
530
- * Dashboard Widget for 2.7 (TRansom)
 
 
531
  */
532
 
533
  function wpsc_dashboard_widget_setup() {
534
  global $current_user;
535
  get_currentuserinfo();
536
- if ( $current_user->user_level > 9 ) {
537
  $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
 
538
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
539
- wp_add_dashboard_widget( 'wpsc_dashboard_widget', __( 'E-Commerce' ), 'wpsc_dashboard_widget' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
  }
541
  }
542
 
543
  /*
544
- if(file_exists(WPSC_FILE_PATH."/wpsc-admin/includes/flot_graphs.php")){
545
- function wpsc_dashboard_quarterly_widget_setup() {
546
- wp_enqueue_script('flot', WPSC_URL.'/wpsc-admin/js/jquery.flot.pack.js', array('jquery'), '0.9.8');
547
- wp_enqueue_script('canvas', WPSC_URL.'/wpsc-admin/js/excanvas.pack.js', array('jquery', 'flot'), '0.9.8');
548
-
549
- wp_add_dashboard_widget('wpsc_quarterly_dashboard_widget', __('Sales by Quarter'),'wpsc_quarterly_dashboard_widget');
550
- }
551
- function wpsc_quarterly_dashboard_widget(){
552
- require_once(WPSC_FILE_PATH."/wpsc-admin/includes/flot_graphs.php");
553
- $flot = new flot();
554
-
555
- }
556
- }
557
  */
558
 
 
 
 
 
 
 
 
 
 
559
  function wpsc_get_quarterly_summary() {
560
  global $wpdb;
561
  (int)$firstquarter = get_option( 'wpsc_first_quart' );
@@ -632,8 +621,8 @@ function wpsc_quarterly_dashboard_widget() {
632
  ?>
633
  <div id='box'>
634
  <p class='atglance'>
635
- <span class='wpsc_quart_left'>At a Glance</span>
636
- <span class='wpsc_quart_right'>Revenue</span>
637
  </p>
638
  <div style='clear:both'></div>
639
  <p class='quarterly'>
@@ -656,17 +645,6 @@ function wpsc_quarterly_dashboard_widget() {
656
  }
657
  }
658
 
659
- function wpsc_quarterly_setup() {
660
- global $current_user;
661
- get_currentuserinfo();
662
- if ( $current_user->user_level > 9 ) {
663
- $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
664
- wp_enqueue_script( 'datepicker-ui', WPSC_URL . "/wpsc-core/js/ui.datepicker.js", array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable' ), $version_identifier );
665
- wp_add_dashboard_widget( 'wpsc_quarterly_dashboard_widget', __( 'Sales by Quarter' ), 'wpsc_quarterly_dashboard_widget' );
666
- }
667
- }
668
-
669
- add_action( 'wp_dashboard_setup', 'wpsc_quarterly_setup' );
670
 
671
  function wpsc_dashboard_widget() {
672
  global $current_user;
@@ -764,28 +742,6 @@ function wpsc_dashboard_4months_widget() {
764
  echo $output;
765
  }
766
 
767
- function wpsc_dashboard_4months_widget_setup() {
768
- global $current_user;
769
- get_currentuserinfo();
770
- if ( $current_user->user_level == 10 ) {
771
- wp_add_dashboard_widget( 'wpsc_dashboard_4months_widget', __( 'Sales by' ), 'wpsc_dashboard_4months_widget' );
772
- }
773
- }
774
-
775
- function wpsc_admin_4months_widget_rightnow() {
776
- $user = wp_get_current_user();
777
- if ( $user->user_level > 9 ) {
778
- echo "<div>";
779
- echo "<h3>" . __( 'e-Commerce', 'wpsc' ) . "</h3>";
780
- echo "<p>";
781
- wpsc_dashboard_4months_widget();
782
- echo "</div>";
783
- }
784
- }
785
- if ( IS_WP27 )
786
- add_action( 'wp_dashboard_setup', 'wpsc_dashboard_4months_widget_setup' );
787
- else
788
- add_action( 'activity_box_end', 'wpsc_admin_4months_widget_rightnow' );
789
 
790
  //Modification to allow for multiple column layout
791
 
@@ -803,25 +759,22 @@ function wpsc_fav_action( $actions ) {
803
  }
804
  add_filter( 'favorite_actions', 'wpsc_fav_action' );
805
 
806
- function wpsc_admin_notices() {
807
- global $wpdb;
808
- // exit(get_option('wpsc_default_category'));
809
- if ( get_option( 'wpsc_default_category' ) != 'all+list' && get_option( 'wpsc_default_category' ) != 'all' && get_option( 'wpsc_default_category' ) != 'list' ) {
810
- if ( (get_option( 'wpsc_default_category' ) < 1 ) ) { // if there is no default category or it is deleted
811
- if ( !$_POST['wpsc_default_category'] ) { // if we are not changing the default category
812
- echo "<div id='message' class='updated fade' style='background-color: rgb(255, 251, 204);'>";
813
- echo "<p>" . __( 'Your "products page" is not currently set to display any products. You need to select a product grouping to display by default. <br /> This is set in the Shop Settings page.', 'wpsc' ) . "</p>";
814
- echo "</div>\n\r";
815
- }
816
- }
817
- }
818
- }
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
  ?>
179
  }
180
 
181
  function wpsc_product_log_rss_feed() {
182
+ echo "<link type='application/rss+xml' href='" . get_option( 'siteurl' ) . "/wp-admin/index.php?rss=true&amp;rss_key=key&amp;action=purchase_log&amp;type=rss' title='WP e-Commerce Purchase Log RSS' rel='alternate'/>";
183
  }
184
 
185
  function wpsc_admin_include_coupon_js() {
385
 
386
  if ( $flash = 1 ) {
387
  ?>
388
+ div.flash-image-uploader {
389
+ display: block;
390
+ }
391
 
392
+ div.browser-image-uploader {
393
+ display: none;
394
+ }
395
  <?php
396
  } else {
397
  ?>
398
+ div.flash-image-uploader {
399
+ display: none;
400
+ }
401
 
402
+ div.browser-image-uploader {
403
+ display: block;
404
+ }
405
  <?php
406
  }
407
  exit();
411
  add_action( "admin_init", 'wpsc_admin_dynamic_css' );
412
  }
413
 
 
 
414
  add_action( 'admin_menu', 'wpsc_admin_pages' );
415
 
416
 
 
 
 
 
 
 
 
 
 
 
 
417
  function wpsc_admin_latest_activity() {
418
  global $wpdb;
419
  $totalOrders = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "`" );
420
 
 
421
  /*
422
  * This is the right hand side for the past 30 days revenue on the wp dashboard
423
  */
424
  echo "<div id='leftDashboard'>";
425
+ echo "<strong class='dashboardHeading'>" . __( 'Current Month', 'wpsc' ) . "</strong><br />";
426
  echo "<p class='dashboardWidgetSpecial'>";
427
  // calculates total amount of orders for the month
428
  $year = date( "Y" );
444
  echo "<span class='dashboardWidget'>" . __( 'Orders', 'wpsc' ) . "</span>";
445
  echo "</p>";
446
  echo "<p class='dashboardWidgetSpecial'>";
 
447
  //calculates average sales amount per order for the month
448
  if ( $currentMonthOrders > 0 ) {
449
  $monthsAverage = ((int)admin_display_total_price( $start_timestamp, $end_timestamp ) / (int)$currentMonthOrders);
452
  //echo "</span>";
453
  echo "<span class='dashboardWidget'>" . __( 'Avg Orders', 'wpsc' ) . "</span>";
454
  echo "</p>";
 
 
455
  echo "</div>";
456
  /*
457
  * This is the left side for the total life time revenue on the wp dashboard
458
  */
459
 
460
  echo "<div id='rightDashboard' >";
461
+ echo "<strong class='dashboardHeading'>" . __( 'Total Income', 'wpsc' ) . "</strong><br />";
462
 
463
  echo "<p class='dashboardWidgetSpecial'>";
464
  echo wpsc_currency_display( admin_display_total_price() );
471
  echo "<span class='dashboardWidget'>" . __( 'Orders', 'wpsc' ) . "</span>";
472
  echo "</p>";
473
  echo "<p class='dashboardWidgetSpecial'>";
 
474
  //calculates average sales amount per order for the month
475
  if ( (admin_display_total_price() > 0) && ($totalOrders > 0) ) {
476
  $totalAverage = ((int)admin_display_total_price() / (int)$totalOrders);
488
  add_action( 'wpsc_admin_pre_activity', 'wpsc_admin_latest_activity' );
489
 
490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
  /*
492
+ * Dashboard Widget Setup
493
+ * Adds the dashboard widgets if the user is an admin
494
+ * Since 3.6
495
  */
496
 
497
  function wpsc_dashboard_widget_setup() {
498
  global $current_user;
499
  get_currentuserinfo();
500
+ if ( is_admin() ) {
501
  $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
502
+ // Enqueue the styles and scripts necessary
503
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
504
+ wp_enqueue_script( 'datepicker-ui', WPSC_URL . "/wpsc-core/js/ui.datepicker.js", array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable' ), $version_identifier );
505
+ // Add the dashboard widgets
506
+ wp_add_dashboard_widget( 'wpsc_dashboard_news', __( 'Getshopped News' ), 'wpsc_dashboard_news' );
507
+ wp_add_dashboard_widget( 'wpsc_dashboard_widget', __( 'Sales Summary' ), 'wpsc_dashboard_widget' );
508
+ wp_add_dashboard_widget( 'wpsc_quarterly_dashboard_widget', __( 'Sales by Quarter' ), 'wpsc_quarterly_dashboard_widget' );
509
+ wp_add_dashboard_widget( 'wpsc_dashboard_4months_widget', __( 'Sales by Month' ), 'wpsc_dashboard_4months_widget' );
510
+
511
+ // Sort the Dashboard widgets so ours it at the top
512
+ global $wp_meta_boxes;
513
+ $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
514
+ // Backup and delete our new dashbaord widget from the end of the array
515
+ $wpsc_widget_backup = array('wpsc_dashboard_news' => $normal_dashboard['wpsc_dashboard_news']);
516
+ $wpsc_widget_backup += array('wpsc_dashboard_widget' => $normal_dashboard['wpsc_dashboard_widget']);
517
+ $wpsc_widget_backup += array('wpsc_quarterly_dashboard_widget' => $normal_dashboard['wpsc_quarterly_dashboard_widget']);
518
+ $wpsc_widget_backup += array('wpsc_dashboard_4months_widget' => $normal_dashboard['wpsc_dashboard_4months_widget']);
519
+
520
+ unset($normal_dashboard['wpsc_dashboard_news']);
521
+ unset($normal_dashboard['wpsc_dashboard_widget']);
522
+ unset($normal_dashboard['wpsc_quarterly_dashboard_widget']);
523
+ unset($normal_dashboard['wpsc_dashboard_4months_widget']);
524
+
525
+ // Merge the two arrays together so our widget is at the beginning
526
+
527
+ $sorted_dashboard = array_merge($wpsc_widget_backup, $normal_dashboard);
528
+
529
+ // Save the sorted array back into the original metaboxes
530
+
531
+ $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
532
  }
533
  }
534
 
535
  /*
536
+ * Registers the widgets on the WordPress Dashboard
 
 
 
 
 
 
 
 
 
 
 
 
537
  */
538
 
539
+ add_action( 'wp_dashboard_setup', 'wpsc_dashboard_widget_setup' );
540
+
541
+ function wpsc_dashboard_news(){
542
+ $rss = fetch_feed('http://getshopped.org/category/wp-e-commerce-plugin/');
543
+ $args = array('show_author' => 1, 'show_date' => 1, 'show_summary' => 1, 'items'=>3 );
544
+ wp_widget_rss_output($rss, $args);
545
+
546
+ }
547
+
548
  function wpsc_get_quarterly_summary() {
549
  global $wpdb;
550
  (int)$firstquarter = get_option( 'wpsc_first_quart' );
621
  ?>
622
  <div id='box'>
623
  <p class='atglance'>
624
+ <span class='wpsc_quart_left'><?php _e('At a Glance' , 'wpsc'); ?></span>
625
+ <span class='wpsc_quart_right'><?php _e('Revenue' , 'wpsc'); ?></span>
626
  </p>
627
  <div style='clear:both'></div>
628
  <p class='quarterly'>
645
  }
646
  }
647
 
 
 
 
 
 
 
 
 
 
 
 
648
 
649
  function wpsc_dashboard_widget() {
650
  global $current_user;
742
  echo $output;
743
  }
744
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
745
 
746
  //Modification to allow for multiple column layout
747
 
759
  }
760
  add_filter( 'favorite_actions', 'wpsc_fav_action' );
761
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
762
  function wpsc_print_admin_scripts(){
763
  global $version_identifier;
764
  wp_enqueue_script( 'wp-e-commerce-dynamic', get_bloginfo('url') . "/index.php?wpsc_user_dynamic_js=true", false, $version_identifier );
765
  }
766
 
767
+ /**
768
+ * wpsc_update_permalinks update the product pages permalinks when WordPress permalinks are changed
769
+ * @public
770
+ *
771
+ * @3.8
772
+ * @returns nothing
773
+ */
774
+ function wpsc_update_permalinks($return = ''){
775
+ wpsc_update_page_urls(true);
776
+ return $return;
777
+ }
778
+ add_action('permalink_structure_changed' ,'wpsc_update_permalinks');
779
+ add_action('get_sample_permalink_html' ,'wpsc_update_permalinks');
780
  ?>
wpsc-admin/ajax-and-init.php CHANGED
@@ -54,7 +54,6 @@ function wpsc_purchlog_email_trackid() {
54
  $subject = get_option( 'wpsc_trackingid_subject' );
55
  $subject = str_replace( '%shop_name%', get_option( 'blogname' ), $subject );
56
  wp_mail( $email, $subject, $message, "From: " . get_option( 'return_email' ) . " <" . get_option( 'return_email' ) . ">" );
57
- //exit($email.'<br /> '.$subject.'<br /> '. $message.'<br /> '."From: ".get_option('return_email')." <".get_option('return_email').">");
58
  exit( true );
59
  }
60
 
@@ -73,7 +72,6 @@ function wpsc_ajax_sales_quarterly() {
73
  if ( !isset( $date[2] ) )
74
  $date[2] = 0;
75
  $lastquart = mktime( 0, 0, 0, $date[1], $date[2], $date[0] );
76
- //$lastdate = date('M d y', $lastquart);
77
  if ( $lastquart != get_option( 'wpsc_last_quarter' ) ) {
78
  update_option( 'wpsc_last_date', $lastdate );
79
  update_option( 'wpsc_fourth_quart', $lastquart );
@@ -86,9 +84,6 @@ function wpsc_ajax_sales_quarterly() {
86
  $finalquart = mktime( 0, 0, 0, $date[1], $date[2], $date[0] - 1 );
87
  update_option( 'wpsc_final_quart', $finalquart );
88
  }
89
-
90
-
91
- // exit($lastquart.' '.$firstquart.' '.$secondquart.' '.$thirdquart);
92
  }
93
 
94
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_quarterly') ) {
@@ -200,7 +195,6 @@ function wpsc_bulk_modify_products() {
200
  $doaction = $_POST['bulkAction'];
201
  $sendback = wp_get_referer();
202
  $product_ids = $_POST['post'];
203
- //exit( "<pre>".print_r($_POST,true)."</pre>");
204
  switch ( $doaction ) {
205
 
206
  case 'addgroup':
@@ -372,7 +366,6 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
372
 
373
  function wpsc_modify_sku() {
374
  global $wpdb;
375
- // exit('<pre>'.print_r($_POST, true).'</pre>');
376
  $product_data = array_pop( $_POST['sku_field'] );
377
 
378
  $product_id = absint( $product_data['id'] );
@@ -435,7 +428,6 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
435
 
436
  function wpsc_modify_stock() {
437
  global $wpdb;
438
- // exit('<pre>'.print_r($_POST, true).'</pre>');
439
  $product_data = array_pop( $_POST['stock_field'] );
440
 
441
  $product_id = absint( $product_data['id'] );
@@ -512,6 +504,7 @@ function wpsc_duplicate_this_dangit( $id ) {
512
 
513
  function wpsc_duplicate_product_process( $post ) {
514
  global $wpdb;
 
515
 
516
  $new_post_date = $post->post_date;
517
  $new_post_date_gmt = get_gmt_from_date( $new_post_date );
@@ -644,15 +637,12 @@ function wpsc_purchase_log_csv() {
644
  global $wpdb, $user_level, $wp_rewrite, $wpsc_purchlog_statuses;
645
  get_currentuserinfo();
646
  if ( ($_GET['rss_key'] == 'key') && is_numeric( $_GET['start_timestamp'] ) && is_numeric( $_GET['end_timestamp'] ) && ($user_level >= 7) ) {
647
- //exit('in use');
648
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `display_log` = '1';";
649
  $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
650
 
651
  $start_timestamp = $_GET['start_timestamp'];
652
  $end_timestamp = $_GET['end_timestamp'];
653
  $data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '$start_timestamp' AND '$end_timestamp' ORDER BY `date` DESC", ARRAY_A );
654
- // exit('<pre>'.print_r($data, true).'</pre>');
655
-
656
 
657
  header( 'Content-Type: text/csv' );
658
  header( 'Content-Disposition: inline; filename="Purchase Log ' . date( "M-d-Y", $start_timestamp ) . ' to ' . date( "M-d-Y", $end_timestamp ) . '.csv"' );
@@ -698,7 +688,6 @@ function wpsc_purchase_log_csv() {
698
 
699
  $cartsql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase['id'] . "";
700
  $cart = $wpdb->get_results( $cartsql, ARRAY_A );
701
- //exit(nl2br(print_r($cart,true)));
702
 
703
  foreach ( (array)$cart as $item ) {
704
  $output .= ",";
@@ -777,11 +766,9 @@ function wpsc_admin_ajax() {
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'];
786
  update_option( 'wpsc_use_flash_uploader', $upload_state );
787
  exit( "done" );
@@ -794,7 +781,6 @@ function wpsc_admin_ajax() {
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' ) ) {
799
  $wpdb->query( $wpdb->prepare( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `active` = '0' WHERE `id` = %d LIMIT 1 ;", $_POST['form_id'] ) );
800
  exit( ' ' );
@@ -839,11 +825,9 @@ function wpsc_admin_ajax() {
839
 
840
  $update_sql = "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed` = '" . $newvalue . "' WHERE `id` = '" . $_POST['id'] . "' LIMIT 1";
841
  $wpdb->query( $update_sql );
842
- //echo("/*");
843
  if ( ($newvalue > $log_data['processed']) && ($log_data['processed'] < 2) ) {
844
  transaction_results( $log_data['sessionid'], false );
845
  }
846
- //echo("*/");
847
 
848
  $status_name = wpsc_find_purchlog_status_name( $purchase['processed'] );
849
  echo "document.getElementById(\"form_group_" . $_POST['id'] . "_text\").innerHTML = '" . $status_name . "';\n";
@@ -878,10 +862,10 @@ function wpsc_admin_sale_rss() {
878
  $output .= "<?xml version='1.0'?>\n\r";
879
  $output .= "<rss version='2.0'>\n\r";
880
  $output .= " <channel>\n\r";
881
- $output .= " <title>WP E-Commerce Product Log</title>\n\r";
882
  $output .= " <link>" . get_option( 'siteurl' ) . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php</link>\n\r";
883
- $output .= " <description>This is the WP E-Commerce Product Log RSS feed</description>\n\r";
884
- $output .= " <generator>WP E-Commerce Plugin</generator>\n\r";
885
 
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'];
@@ -902,7 +886,6 @@ function wpsc_admin_sale_rss() {
902
 
903
  function wpsc_swfupload_images() {
904
  global $wpdb, $current_user, $user_ID;
905
- // xdebug_start_trace();
906
  $file = $_FILES['async-upload'];
907
  $product_id = absint( $_POST['product_id'] );
908
  $nonce = $_POST['_wpnonce'];
@@ -927,13 +910,8 @@ function wpsc_swfupload_images() {
927
 
928
  $id = media_handle_upload( 'async-upload', $product_id );
929
 
930
- //$object = array('post_author' => $user_ID, 'ping_status' => get_option('default_ping_status'), 'post_parent' => $product_id);
931
- // wp_insert_attachment($object, $file = false, $parent = 0);
932
-
933
  if ( !is_wp_error( $id ) ) {
934
- //$src = $file['name'];
935
  $src = wp_get_attachment_image_src( $id );
936
- //print_r($src);
937
  $output .= "upload_status=1;\n";
938
  $output .= "image_src='" . $src[0] . "';\n";
939
  $output .= "image_id='$id';\n";
@@ -954,10 +932,8 @@ function wpsc_display_invoice() {
954
  $body_id = 'wpsc-packing-slip';
955
  $purchase_id = (int)$_GET['purchaselog_id'];
956
  include_once(WPSC_FILE_PATH . "/wpsc-admin/admin-form-functions.php");
957
- // echo "testing";
958
  require_once(ABSPATH . 'wp-admin/includes/media.php');
959
  wp_iframe( 'wpsc_packing_slip', $purchase_id );
960
- //wpsc_packing_slip($purchase_id);
961
  exit();
962
  }
963
  //other actions are here
@@ -1019,7 +995,6 @@ function wpsc_purchlog_resend_email() {
1019
  'post_status' => 'inherit'
1020
  );
1021
  $dl_data = (array)get_posts( $attachment );
1022
- /* / exit('<pre>'.print_r($purchase_log,true).'</pre>'); */
1023
  if ( $dl_data[0]->ID > 0 ) {
1024
  if ( $purchase_log['email_sent'] != 1 ) {
1025
  $wpdb->query( "UPDATE `" . WPSC_TABLE_DOWNLOAD_STATUS . "` SET `active`='1' WHERE `fileid`='" . $product_data[0]['file'] . "' AND `purchid` = '" . $purchase_log['id'] . "' LIMIT 1" );
@@ -1108,11 +1083,10 @@ function wpsc_purchlog_resend_email() {
1108
  $wpdb->query( "UPDATE `" . WPSC_TABLE_COUPON_CODES . "` SET `active`='0', `is-used`='1' WHERE `id`='" . $coupon_data['id'] . "' LIMIT 1" );
1109
  }
1110
  }
1111
- //$wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `active`='1' WHERE `fileid`='".$product_data[0]['file']."' AND `purchid` = '".$purchase_log['id']."' LIMIT 1");
1112
  $total_shipping += $purchase_log['base_shipping'];
1113
 
1114
  $total = (($total + $total_shipping) - $purchase_log['discount_value']);
1115
- // $message.= "\n\r";
1116
  $product_list.= "Your Purchase # " . $purchase_log['id'] . "\n\r";
1117
  if ( $purchase_log['discount_value'] > 0 ) {
1118
  $discount_email.= __( 'Discount', 'wpsc' ) . ": " . wpsc_currency_display( $purchase_log['discount_value'],array( 'display_as_html' => false ) ) . "\n\r";
@@ -1138,7 +1112,6 @@ function wpsc_purchlog_resend_email() {
1138
  $message = str_replace( '%product_list%', $product_list, $message );
1139
  $message = str_replace( '%total_shipping%', $total_shipping_email, $message );
1140
  $message = str_replace( '%total_price%', $total_price_email, $message );
1141
- //$message = str_replace('%order_status%',get_option('blogname'),$message);
1142
  $message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
1143
 
1144
  $report = str_replace( '%product_list%', $report_product_list, $report );
@@ -1151,8 +1124,6 @@ function wpsc_purchlog_resend_email() {
1151
  $message_html = str_replace( '%total_price%', $total_price_email, $message_html );
1152
  $message_html = str_replace( '%shop_name%', get_option( 'blogname' ), $message_html );
1153
 
1154
-
1155
- // exit($message_html);
1156
  if ( ($email != '' ) ) {
1157
  add_filter( 'wp_mail_from', 'wpsc_replace_reply_address', 0 );
1158
  add_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name', 0 );
@@ -1165,8 +1136,6 @@ function wpsc_purchlog_resend_email() {
1165
  $resent = (bool)wp_mail( $email, __( 'Purchase Receipt', 'wpsc' ), $message );
1166
  $sent = 1;
1167
  }
1168
- //echo "$message<br />";
1169
- //exit($email);
1170
  remove_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name' );
1171
  remove_filter( 'wp_mail_from', 'wpsc_replace_reply_address' );
1172
  }
@@ -1187,7 +1156,6 @@ if ( isset( $_REQUEST['email_buyer_id'] ) && is_numeric( $_REQUEST['email_buyer_
1187
 
1188
  function wpsc_purchlog_clear_download_items() {
1189
  global $wpdb;
1190
- //exit('Just about to redirect');
1191
  if ( is_numeric( $_GET['purchaselog_id'] ) ) {
1192
  $purchase_id = (int)$_GET['purchaselog_id'];
1193
  $downloadable_items = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `purchid` IN ('$purchase_id')", ARRAY_A );
@@ -1224,7 +1192,6 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
1224
  //call to change view for purchase log
1225
 
1226
  function wpsc_purchlog_filter_by() {
1227
- //exit('filter is triggered'.print_r($_POST, true));
1228
  wpsc_change_purchlog_view( $_POST['view_purchlogs_by'], $_POST['view_purchlogs_by_status'] );
1229
  }
1230
 
@@ -1237,7 +1204,6 @@ function wpsc_purchlog_bulk_modify() {
1237
  if ( $_POST['purchlog_multiple_status_change'] != -1 ) {
1238
  if ( is_numeric( $_POST['purchlog_multiple_status_change'] ) && $_POST['purchlog_multiple_status_change'] != 'delete' ) {
1239
  foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
1240
- //exit('<pre>'.print_r($purchlogid,true).'</pre>');
1241
  wpsc_purchlog_edit_status( $purchlogid, $_POST['purchlog_multiple_status_change'] );
1242
  $updated++;
1243
  }
@@ -1410,7 +1376,6 @@ function wpsc_ajax_get_shipping_form() {
1410
  echo "shipping_name_html = '$html_shipping_name'; \n\r";
1411
  echo "shipping_form_html = '$shipping_form'; \n\r";
1412
  echo "has_submit_button = '{$shipping_data['has_submit_button']}'; \n\r";
1413
- //echo "<script type='text/javascript'>jQuery('.gateway_settings h3.hndle').livequery(function(){ jQuery(this).html('".$wpsc_shipping_modules[$shippingname]->name."')})</script>";
1414
  exit();
1415
  }
1416
 
@@ -1424,7 +1389,6 @@ function wpsc_ajax_get_payment_form() {
1424
  echo "payment_name_html = '$html_payment_name'; \n\r";
1425
  echo "payment_form_html = '$payment_form'; \n\r";
1426
  echo "has_submit_button = '{$payment_data['has_submit_button']}'; \n\r";
1427
- //echo "<script type='text/javascript'>jQuery('.gateway_settings h3.hndle').livequery(function(){ jQuery(this).html('".$wpsc_shipping_modules[$shippingname]->name."')})</script>";
1428
  exit();
1429
  }
1430
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'get_shipping_form') )
@@ -1446,7 +1410,6 @@ function wpsc_submit_options( $selected='' ) {
1446
 
1447
  //This is to change the Overall target market selection
1448
  check_admin_referer( 'update-options', 'wpsc-update-options' );
1449
- // exit('<pre>'.print_r($_POST,true).'</pre>');
1450
  if ( isset( $_POST['change-settings'] ) ) {
1451
  if ( isset( $_POST['wpsc_also_bought'] ) && $_POST['wpsc_also_bought'] == 'on' )
1452
  update_option( 'wpsc_also_bought', 1 );
@@ -1464,7 +1427,6 @@ function wpsc_submit_options( $selected='' ) {
1464
  update_option( 'wpsc_share_this', 0 );
1465
 
1466
  }
1467
- // exit('<pre>'.print_r($_POST,1).'</pre>');
1468
  if (empty($_POST['countrylist2']) && !empty($_POST['wpsc_options']['currency_sign_location']))
1469
  $selected = 'all';
1470
 
@@ -1480,12 +1442,10 @@ function wpsc_submit_options( $selected='' ) {
1480
  if ( $selected == 'all' ) {
1481
  $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '1'" );
1482
  $AllSelected = true;
1483
- //return;
1484
  }
1485
  if ( $selected == 'none' ) {
1486
  $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '0'" );
1487
  $AllSelected = true;
1488
- //return;
1489
  }
1490
  if ( $AllSelected != true ) {
1491
  $countrylist = $wpdb->get_col( "SELECT id FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC " );
@@ -1538,16 +1498,12 @@ function wpsc_submit_options( $selected='' ) {
1538
  $option_name = $wpsc_gateways[$selected_gateway]['supported_currencies']['option_name'];
1539
 
1540
  if ( !in_array( $option_name, $already_changed ) ) {
1541
- //echo $option_name;
1542
  update_option( $option_name, $currency_code );
1543
  $already_changed[] = $option_name;
1544
  }
1545
  }
1546
  }
1547
  }
1548
-
1549
-
1550
- //exit("<pre>".print_r($selected_gateways,true)."</pre>");
1551
  }
1552
 
1553
  foreach ( $GLOBALS['wpsc_shipping_modules'] as $shipping ) {
@@ -1568,9 +1524,7 @@ function wpsc_submit_options( $selected='' ) {
1568
 
1569
  foreach ( $GLOBALS['wpsc_shipping_modules'] as $shipping ) {
1570
  foreach ( (array)$_POST['custom_shipping_options'] as $shippingoption ) {
1571
- //echo $shipping->internal_name.' == '.$shippingoption;
1572
  if ( $shipping->internal_name == $shippingoption ) {
1573
- //$shipping->submit_form();
1574
  $shipadd++;
1575
  }
1576
  }
@@ -1621,7 +1575,6 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
1621
 
1622
  function wpsc_rearrange_images() {
1623
  global $wpdb;
1624
- //$wpdb->show_errors = true;
1625
  $images = explode( ",", $_POST['order'] );
1626
  $product_id = absint( $_POST['product_id'] );
1627
  $timestamp = time();
@@ -1636,10 +1589,6 @@ function wpsc_rearrange_images() {
1636
  }
1637
  }
1638
  $output = wpsc_main_product_image_menu( $product_id );
1639
- //echo "/*\n";
1640
- //echo print_r($_POST, true);
1641
- //echo print_r($images, true);
1642
- //echo "*/\n";
1643
  echo "image_menu = '';\n\r";
1644
  echo "image_id = '" . $new_main_image . "';\n\r";
1645
  exit();
@@ -1647,7 +1596,15 @@ function wpsc_rearrange_images() {
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
 
1653
  $wpsc_pageurl_option['product_list_url'] = '[productspage]';
@@ -1671,24 +1628,24 @@ function wpsc_update_page_urls() {
1671
  update_option( $option_key, $the_new_link );
1672
  $updated;
1673
  }
1674
- $sendback = wp_get_referer();
 
 
 
 
1675
 
1676
- if ( isset( $updated ) ) {
1677
- $sendback = add_query_arg( 'updated', $updated, $sendback );
1678
- }
1679
- if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
1680
- $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1681
  }
1682
- wp_redirect( $sendback );
1683
-
1684
- exit();
1685
  }
1686
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'update_page_urls') )
1687
  add_action( 'admin_init', 'wpsc_update_page_urls' );
1688
 
1689
  function wpsc_clean_categories() {
1690
  global $wpdb, $wp_rewrite;
1691
- //exit("<pre>".print_r($check_category_names,true)."</pre>");
1692
  $sql_query = "SELECT `id`, `name`, `active` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`";
1693
  $sql_data = $wpdb->get_results( $sql_query, ARRAY_A );
1694
  foreach ( (array)$sql_data as $datarow ) {
@@ -1739,7 +1696,6 @@ function wpsc_change_region_tax() {
1739
  }
1740
  }
1741
  $sendback = wp_get_referer();
1742
- //$sendback = remove_query_arg('isocode', $sendback);
1743
  wp_redirect( $sendback );
1744
  }
1745
  }
@@ -1760,10 +1716,8 @@ function wpsc_product_files_existing() {
1760
  'numberposts' => -1,
1761
  'post_status' => 'all'
1762
  );
1763
- //echo "<pre>".print_r($file_list, true)."<pre>";
1764
  $attached_files = (array)get_posts( $args );
1765
 
1766
- //echo "<pre>".print_r($attached_files, true)."<pre>";
1767
  foreach ( $attached_files as $key => $attached_file ) {
1768
  $attached_files_by_file[$attached_file->post_title] = & $attached_files[$key];
1769
  }
@@ -1861,7 +1815,6 @@ function wpsc_gateway_settings() {
1861
  foreach ( $_POST['wpsc_options'] as $key => $value ) {
1862
  if ( $value != get_option( $key ) ) {
1863
  update_option( $key, $value );
1864
- //$updated++;
1865
  }
1866
  }
1867
  unset( $_POST['wpsc_options'] );
@@ -1882,7 +1835,6 @@ function wpsc_gateway_settings() {
1882
 
1883
  $nzshpcrt_gateways = nzshpcrt_get_gateways();
1884
  foreach ( $nzshpcrt_gateways as $gateway ) {
1885
- //if($gateway['internalname'] == get_option('payment_gateway'))
1886
  if ( in_array( $gateway['internalname'], $custom_gateways ) ) {
1887
  if ( isset( $gateway['submit_function'] ) ) {
1888
  call_user_func_array( $gateway['submit_function'], array( ) );
@@ -1902,8 +1854,6 @@ function wpsc_gateway_settings() {
1902
  $sendback = add_query_arg( 'page', 'wpsc-settings', $sendback );
1903
  $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1904
  }
1905
- //sexit($sendback);
1906
- // exit('<pre>'.print_r($_POST).'</pre>');
1907
  wp_redirect( $sendback );
1908
  exit();
1909
  }
@@ -1954,7 +1904,6 @@ function wpsc_checkout_settings() {
1954
 
1955
  /*
1956
  // Save checkout options
1957
- if (!isset($_POST['wpsc_checkout_option_label'])) $_POST['wpsc_checkout_option_label'] = '';
1958
  */
1959
  $options = array( );
1960
  if ( is_array( $_POST['wpsc_checkout_option_label'] ) ) {
@@ -1989,10 +1938,7 @@ function wpsc_checkout_settings() {
1989
  if ( $_POST['unique_names'][$form_id] != '-1' ) {
1990
  $unique_name = $_POST['unique_names'][$form_id];
1991
  }
1992
- // $form_order = $_POST['form_order'][$form_id];
1993
  $wpdb->query( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `name` = '$form_name', `type` = '$form_type', `mandatory` = '$form_mandatory', `display_log` = '$form_display_log',`unique_name`='" . $unique_name . "' WHERE `id` ='" . $form_id . "' LIMIT 1 ;" );
1994
- //echo "UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `name` = '$form_name', `type` = '$form_type', `mandatory` = '$form_mandatory', `display_log` = '$form_display_log',`unique_name`='".$unique_name."', `checkout_set`='".$filter."' WHERE `id` ='".$form_id."' LIMIT 1 ;";
1995
- //echo "<br />";
1996
  }
1997
  }
1998
 
@@ -2091,11 +2037,6 @@ function wpsc_settings_page_ajax() {
2091
  $page_title = str_replace( "tab-", "", $modified_page_title );
2092
 
2093
  check_admin_referer( $modified_page_title );
2094
-
2095
- //require_once('includes/settings-pages/'.$functionname1.'.php');
2096
- //$functionname = "wpsc_options_".$functionname1;
2097
- //$html = $functionname();
2098
-
2099
  switch ( $page_title ) {
2100
  case 'checkout' :
2101
  require_once( 'includes/settings-pages/checkout.php' );
@@ -2167,7 +2108,6 @@ function wpsc_update_variations() {
2167
 
2168
  // return admin table listing
2169
  return wpsc_admin_product_listing( $product_id );
2170
- //return $post_data;
2171
  }
2172
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_update_variations') )
2173
  add_action( 'admin_init', 'wpsc_update_variations', 50 );
@@ -2194,8 +2134,6 @@ function wpsc_delete_variation_set() {
2194
  if ( !empty( $variation_set ) ) {
2195
  $return_value = wp_delete_term( $variation_set['term_id'], 'wpsc-variation' );
2196
  }
2197
- //echo "<pre>".print_r($variation_set, true)."</pre>";
2198
- //exit();
2199
  $deleted = 1;
2200
  }
2201
 
54
  $subject = get_option( 'wpsc_trackingid_subject' );
55
  $subject = str_replace( '%shop_name%', get_option( 'blogname' ), $subject );
56
  wp_mail( $email, $subject, $message, "From: " . get_option( 'return_email' ) . " <" . get_option( 'return_email' ) . ">" );
 
57
  exit( true );
58
  }
59
 
72
  if ( !isset( $date[2] ) )
73
  $date[2] = 0;
74
  $lastquart = mktime( 0, 0, 0, $date[1], $date[2], $date[0] );
 
75
  if ( $lastquart != get_option( 'wpsc_last_quarter' ) ) {
76
  update_option( 'wpsc_last_date', $lastdate );
77
  update_option( 'wpsc_fourth_quart', $lastquart );
84
  $finalquart = mktime( 0, 0, 0, $date[1], $date[2], $date[0] - 1 );
85
  update_option( 'wpsc_final_quart', $finalquart );
86
  }
 
 
 
87
  }
88
 
89
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_quarterly') ) {
195
  $doaction = $_POST['bulkAction'];
196
  $sendback = wp_get_referer();
197
  $product_ids = $_POST['post'];
 
198
  switch ( $doaction ) {
199
 
200
  case 'addgroup':
366
 
367
  function wpsc_modify_sku() {
368
  global $wpdb;
 
369
  $product_data = array_pop( $_POST['sku_field'] );
370
 
371
  $product_id = absint( $product_data['id'] );
428
 
429
  function wpsc_modify_stock() {
430
  global $wpdb;
 
431
  $product_data = array_pop( $_POST['stock_field'] );
432
 
433
  $product_id = absint( $product_data['id'] );
504
 
505
  function wpsc_duplicate_product_process( $post ) {
506
  global $wpdb;
507
+ //Commit check
508
 
509
  $new_post_date = $post->post_date;
510
  $new_post_date_gmt = get_gmt_from_date( $new_post_date );
637
  global $wpdb, $user_level, $wp_rewrite, $wpsc_purchlog_statuses;
638
  get_currentuserinfo();
639
  if ( ($_GET['rss_key'] == 'key') && is_numeric( $_GET['start_timestamp'] ) && is_numeric( $_GET['end_timestamp'] ) && ($user_level >= 7) ) {
 
640
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `display_log` = '1';";
641
  $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
642
 
643
  $start_timestamp = $_GET['start_timestamp'];
644
  $end_timestamp = $_GET['end_timestamp'];
645
  $data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '$start_timestamp' AND '$end_timestamp' ORDER BY `date` DESC", ARRAY_A );
 
 
646
 
647
  header( 'Content-Type: text/csv' );
648
  header( 'Content-Disposition: inline; filename="Purchase Log ' . date( "M-d-Y", $start_timestamp ) . ' to ' . date( "M-d-Y", $end_timestamp ) . '.csv"' );
688
 
689
  $cartsql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase['id'] . "";
690
  $cart = $wpdb->get_results( $cartsql, ARRAY_A );
 
691
 
692
  foreach ( (array)$cart as $item ) {
693
  $output .= ",";
766
  array_walk( $current_order["closedboxes"], "wpec_close_box", $closed );
767
 
768
  update_option( 'wpsc_product_page_order', $current_order );
 
769
  }
770
 
771
  if ( ($_POST['save_image_upload_state'] == "true") && is_numeric( $_POST['image_upload_state'] ) ) {
 
772
  $upload_state = (int)(bool)$_POST['image_upload_state'];
773
  update_option( 'wpsc_use_flash_uploader', $upload_state );
774
  exit( "done" );
781
  }
782
 
783
  if ( ($_POST['remove_form_field'] == "true") && is_numeric( $_POST['form_id'] ) ) {
 
784
  if ( current_user_can( 'level_7' ) ) {
785
  $wpdb->query( $wpdb->prepare( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `active` = '0' WHERE `id` = %d LIMIT 1 ;", $_POST['form_id'] ) );
786
  exit( ' ' );
825
 
826
  $update_sql = "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed` = '" . $newvalue . "' WHERE `id` = '" . $_POST['id'] . "' LIMIT 1";
827
  $wpdb->query( $update_sql );
 
828
  if ( ($newvalue > $log_data['processed']) && ($log_data['processed'] < 2) ) {
829
  transaction_results( $log_data['sessionid'], false );
830
  }
 
831
 
832
  $status_name = wpsc_find_purchlog_status_name( $purchase['processed'] );
833
  echo "document.getElementById(\"form_group_" . $_POST['id'] . "_text\").innerHTML = '" . $status_name . "';\n";
862
  $output .= "<?xml version='1.0'?>\n\r";
863
  $output .= "<rss version='2.0'>\n\r";
864
  $output .= " <channel>\n\r";
865
+ $output .= " <title>WP e-Commerce Product Log</title>\n\r";
866
  $output .= " <link>" . get_option( 'siteurl' ) . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php</link>\n\r";
867
+ $output .= " <description>This is the WP e-Commerce Product Log RSS feed</description>\n\r";
868
+ $output .= " <generator>WP e-Commerce Plugin</generator>\n\r";
869
 
870
  foreach ( (array)$purchase_log as $purchase ) {
871
  $purchase_link = get_option( 'siteurl' ) . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php&amp;purchaseid=" . $purchase['id'];
886
 
887
  function wpsc_swfupload_images() {
888
  global $wpdb, $current_user, $user_ID;
 
889
  $file = $_FILES['async-upload'];
890
  $product_id = absint( $_POST['product_id'] );
891
  $nonce = $_POST['_wpnonce'];
910
 
911
  $id = media_handle_upload( 'async-upload', $product_id );
912
 
 
 
 
913
  if ( !is_wp_error( $id ) ) {
 
914
  $src = wp_get_attachment_image_src( $id );
 
915
  $output .= "upload_status=1;\n";
916
  $output .= "image_src='" . $src[0] . "';\n";
917
  $output .= "image_id='$id';\n";
932
  $body_id = 'wpsc-packing-slip';
933
  $purchase_id = (int)$_GET['purchaselog_id'];
934
  include_once(WPSC_FILE_PATH . "/wpsc-admin/admin-form-functions.php");
 
935
  require_once(ABSPATH . 'wp-admin/includes/media.php');
936
  wp_iframe( 'wpsc_packing_slip', $purchase_id );
 
937
  exit();
938
  }
939
  //other actions are here
995
  'post_status' => 'inherit'
996
  );
997
  $dl_data = (array)get_posts( $attachment );
 
998
  if ( $dl_data[0]->ID > 0 ) {
999
  if ( $purchase_log['email_sent'] != 1 ) {
1000
  $wpdb->query( "UPDATE `" . WPSC_TABLE_DOWNLOAD_STATUS . "` SET `active`='1' WHERE `fileid`='" . $product_data[0]['file'] . "' AND `purchid` = '" . $purchase_log['id'] . "' LIMIT 1" );
1083
  $wpdb->query( "UPDATE `" . WPSC_TABLE_COUPON_CODES . "` SET `active`='0', `is-used`='1' WHERE `id`='" . $coupon_data['id'] . "' LIMIT 1" );
1084
  }
1085
  }
1086
+
1087
  $total_shipping += $purchase_log['base_shipping'];
1088
 
1089
  $total = (($total + $total_shipping) - $purchase_log['discount_value']);
 
1090
  $product_list.= "Your Purchase # " . $purchase_log['id'] . "\n\r";
1091
  if ( $purchase_log['discount_value'] > 0 ) {
1092
  $discount_email.= __( 'Discount', 'wpsc' ) . ": " . wpsc_currency_display( $purchase_log['discount_value'],array( 'display_as_html' => false ) ) . "\n\r";
1112
  $message = str_replace( '%product_list%', $product_list, $message );
1113
  $message = str_replace( '%total_shipping%', $total_shipping_email, $message );
1114
  $message = str_replace( '%total_price%', $total_price_email, $message );
 
1115
  $message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
1116
 
1117
  $report = str_replace( '%product_list%', $report_product_list, $report );
1124
  $message_html = str_replace( '%total_price%', $total_price_email, $message_html );
1125
  $message_html = str_replace( '%shop_name%', get_option( 'blogname' ), $message_html );
1126
 
 
 
1127
  if ( ($email != '' ) ) {
1128
  add_filter( 'wp_mail_from', 'wpsc_replace_reply_address', 0 );
1129
  add_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name', 0 );
1136
  $resent = (bool)wp_mail( $email, __( 'Purchase Receipt', 'wpsc' ), $message );
1137
  $sent = 1;
1138
  }
 
 
1139
  remove_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name' );
1140
  remove_filter( 'wp_mail_from', 'wpsc_replace_reply_address' );
1141
  }
1156
 
1157
  function wpsc_purchlog_clear_download_items() {
1158
  global $wpdb;
 
1159
  if ( is_numeric( $_GET['purchaselog_id'] ) ) {
1160
  $purchase_id = (int)$_GET['purchaselog_id'];
1161
  $downloadable_items = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `purchid` IN ('$purchase_id')", ARRAY_A );
1192
  //call to change view for purchase log
1193
 
1194
  function wpsc_purchlog_filter_by() {
 
1195
  wpsc_change_purchlog_view( $_POST['view_purchlogs_by'], $_POST['view_purchlogs_by_status'] );
1196
  }
1197
 
1204
  if ( $_POST['purchlog_multiple_status_change'] != -1 ) {
1205
  if ( is_numeric( $_POST['purchlog_multiple_status_change'] ) && $_POST['purchlog_multiple_status_change'] != 'delete' ) {
1206
  foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
 
1207
  wpsc_purchlog_edit_status( $purchlogid, $_POST['purchlog_multiple_status_change'] );
1208
  $updated++;
1209
  }
1376
  echo "shipping_name_html = '$html_shipping_name'; \n\r";
1377
  echo "shipping_form_html = '$shipping_form'; \n\r";
1378
  echo "has_submit_button = '{$shipping_data['has_submit_button']}'; \n\r";
 
1379
  exit();
1380
  }
1381
 
1389
  echo "payment_name_html = '$html_payment_name'; \n\r";
1390
  echo "payment_form_html = '$payment_form'; \n\r";
1391
  echo "has_submit_button = '{$payment_data['has_submit_button']}'; \n\r";
 
1392
  exit();
1393
  }
1394
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'get_shipping_form') )
1410
 
1411
  //This is to change the Overall target market selection
1412
  check_admin_referer( 'update-options', 'wpsc-update-options' );
 
1413
  if ( isset( $_POST['change-settings'] ) ) {
1414
  if ( isset( $_POST['wpsc_also_bought'] ) && $_POST['wpsc_also_bought'] == 'on' )
1415
  update_option( 'wpsc_also_bought', 1 );
1427
  update_option( 'wpsc_share_this', 0 );
1428
 
1429
  }
 
1430
  if (empty($_POST['countrylist2']) && !empty($_POST['wpsc_options']['currency_sign_location']))
1431
  $selected = 'all';
1432
 
1442
  if ( $selected == 'all' ) {
1443
  $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '1'" );
1444
  $AllSelected = true;
 
1445
  }
1446
  if ( $selected == 'none' ) {
1447
  $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '0'" );
1448
  $AllSelected = true;
 
1449
  }
1450
  if ( $AllSelected != true ) {
1451
  $countrylist = $wpdb->get_col( "SELECT id FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC " );
1498
  $option_name = $wpsc_gateways[$selected_gateway]['supported_currencies']['option_name'];
1499
 
1500
  if ( !in_array( $option_name, $already_changed ) ) {
 
1501
  update_option( $option_name, $currency_code );
1502
  $already_changed[] = $option_name;
1503
  }
1504
  }
1505
  }
1506
  }
 
 
 
1507
  }
1508
 
1509
  foreach ( $GLOBALS['wpsc_shipping_modules'] as $shipping ) {
1524
 
1525
  foreach ( $GLOBALS['wpsc_shipping_modules'] as $shipping ) {
1526
  foreach ( (array)$_POST['custom_shipping_options'] as $shippingoption ) {
 
1527
  if ( $shipping->internal_name == $shippingoption ) {
 
1528
  $shipadd++;
1529
  }
1530
  }
1575
 
1576
  function wpsc_rearrange_images() {
1577
  global $wpdb;
 
1578
  $images = explode( ",", $_POST['order'] );
1579
  $product_id = absint( $_POST['product_id'] );
1580
  $timestamp = time();
1589
  }
1590
  }
1591
  $output = wpsc_main_product_image_menu( $product_id );
 
 
 
 
1592
  echo "image_menu = '';\n\r";
1593
  echo "image_id = '" . $new_main_image . "';\n\r";
1594
  exit();
1596
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'rearrange_images') )
1597
  add_action( 'admin_init', 'wpsc_rearrange_images' );
1598
 
1599
+ /**
1600
+ * wpsc_update_page_urls gets the permalinks for products pages and stores them in the options for quick reference
1601
+ * @public
1602
+ *
1603
+ * @since 3.6
1604
+ * @param $auto (Boolean) true if coming from WordPress Permalink Page, false otherwise
1605
+ * @return nothing
1606
+ */
1607
+ function wpsc_update_page_urls($auto = false) {
1608
  global $wpdb;
1609
 
1610
  $wpsc_pageurl_option['product_list_url'] = '[productspage]';
1628
  update_option( $option_key, $the_new_link );
1629
  $updated;
1630
  }
1631
+
1632
+ if(!$auto){
1633
+ $sendback = wp_get_referer();
1634
+ if ( isset( $updated ) )
1635
+ $sendback = add_query_arg( 'updated', $updated, $sendback );
1636
 
1637
+ if ( isset( $_SESSION['wpsc_settings_curr_page'] ) )
1638
+ $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1639
+
1640
+ wp_redirect( $sendback );
1641
+ exit();
1642
  }
 
 
 
1643
  }
1644
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'update_page_urls') )
1645
  add_action( 'admin_init', 'wpsc_update_page_urls' );
1646
 
1647
  function wpsc_clean_categories() {
1648
  global $wpdb, $wp_rewrite;
 
1649
  $sql_query = "SELECT `id`, `name`, `active` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`";
1650
  $sql_data = $wpdb->get_results( $sql_query, ARRAY_A );
1651
  foreach ( (array)$sql_data as $datarow ) {
1696
  }
1697
  }
1698
  $sendback = wp_get_referer();
 
1699
  wp_redirect( $sendback );
1700
  }
1701
  }
1716
  'numberposts' => -1,
1717
  'post_status' => 'all'
1718
  );
 
1719
  $attached_files = (array)get_posts( $args );
1720
 
 
1721
  foreach ( $attached_files as $key => $attached_file ) {
1722
  $attached_files_by_file[$attached_file->post_title] = & $attached_files[$key];
1723
  }
1815
  foreach ( $_POST['wpsc_options'] as $key => $value ) {
1816
  if ( $value != get_option( $key ) ) {
1817
  update_option( $key, $value );
 
1818
  }
1819
  }
1820
  unset( $_POST['wpsc_options'] );
1835
 
1836
  $nzshpcrt_gateways = nzshpcrt_get_gateways();
1837
  foreach ( $nzshpcrt_gateways as $gateway ) {
 
1838
  if ( in_array( $gateway['internalname'], $custom_gateways ) ) {
1839
  if ( isset( $gateway['submit_function'] ) ) {
1840
  call_user_func_array( $gateway['submit_function'], array( ) );
1854
  $sendback = add_query_arg( 'page', 'wpsc-settings', $sendback );
1855
  $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1856
  }
 
 
1857
  wp_redirect( $sendback );
1858
  exit();
1859
  }
1904
 
1905
  /*
1906
  // Save checkout options
 
1907
  */
1908
  $options = array( );
1909
  if ( is_array( $_POST['wpsc_checkout_option_label'] ) ) {
1938
  if ( $_POST['unique_names'][$form_id] != '-1' ) {
1939
  $unique_name = $_POST['unique_names'][$form_id];
1940
  }
 
1941
  $wpdb->query( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `name` = '$form_name', `type` = '$form_type', `mandatory` = '$form_mandatory', `display_log` = '$form_display_log',`unique_name`='" . $unique_name . "' WHERE `id` ='" . $form_id . "' LIMIT 1 ;" );
 
 
1942
  }
1943
  }
1944
 
2037
  $page_title = str_replace( "tab-", "", $modified_page_title );
2038
 
2039
  check_admin_referer( $modified_page_title );
 
 
 
 
 
2040
  switch ( $page_title ) {
2041
  case 'checkout' :
2042
  require_once( 'includes/settings-pages/checkout.php' );
2108
 
2109
  // return admin table listing
2110
  return wpsc_admin_product_listing( $product_id );
 
2111
  }
2112
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_update_variations') )
2113
  add_action( 'admin_init', 'wpsc_update_variations', 50 );
2134
  if ( !empty( $variation_set ) ) {
2135
  $return_value = wp_delete_term( $variation_set['term_id'], 'wpsc-variation' );
2136
  }
 
 
2137
  $deleted = 1;
2138
  }
2139
 
wpsc-admin/css/admin.css CHANGED
@@ -430,7 +430,7 @@ div#icon_card
430
  {
431
  float: left;
432
  height: 36px;
433
- margin: 14px 6px 0px 0px;
434
  width: 36px;
435
  background: url(../../wpsc-core/images/icon32.png) no-repeat center center;
436
  }
430
  {
431
  float: left;
432
  height: 36px;
433
+ margin: 20px 6px 0px 0px;
434
  width: 36px;
435
  background: url(../../wpsc-core/images/icon32.png) no-repeat center center;
436
  }
wpsc-admin/display-coupons.php CHANGED
@@ -385,7 +385,6 @@ function wpsc_display_coupons_page() {
385
  echo " </tr>\n\r";
386
  echo " <tr class='coupon_edit'>\n\r";
387
  echo " <td colspan='7' style='padding-left:0px;'>\n\r";
388
- // $status_style = "style='display: block;'";
389
  echo " <div id='coupon_box_" . $coupon['id'] . "' class='displaynone modify_coupon' >\n\r";
390
  coupon_edit_form( $coupon );
391
  echo " </div>\n\r";
385
  echo " </tr>\n\r";
386
  echo " <tr class='coupon_edit'>\n\r";
387
  echo " <td colspan='7' style='padding-left:0px;'>\n\r";
 
388
  echo " <div id='coupon_box_" . $coupon['id'] . "' class='displaynone modify_coupon' >\n\r";
389
  coupon_edit_form( $coupon );
390
  echo " </div>\n\r";
wpsc-admin/display-debug.page.php CHANGED
@@ -35,7 +35,13 @@ function wpsc_debug_page() {
35
  </li>
36
  <li>
37
  <a href='<?php echo $fixpage; ?>'>Fix Purchaselogs</a>
38
- </li>
 
 
 
 
 
 
39
  </ul>
40
  <?php
41
  if ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && (constant( 'WPSC_ADD_DEBUG_PAGE' ) == true) ) {
@@ -115,18 +121,10 @@ function wpsc_debug_page() {
115
 
116
  case 'wp_get_object_terms':
117
  global $wp_taxonomies;
118
- //register_taxonomy('product_tag', 'product');
119
- //print_r($wp_taxonomies);
120
  $tags = wp_get_object_terms( 108, 'product_tag', array( 'fields' => 'names' ) );
121
- // wp_set_object_terms(103, $tags, 'product_tag');
122
  print_r( $tags );
123
  break;
124
 
125
- case 'create_also_bought_list':
126
- // wpsc_populate_also_bought_list();
127
-
128
- break;
129
-
130
  case 'unicode_permalinks':
131
  $original_string = "バンプ・オブ・チキン";
132
  $sanitized_string = sanitize_title( $original_string );
@@ -272,7 +270,6 @@ function wpsc_recreate_product_url_names() {
272
  global $wpdb;
273
 
274
  $product_data = $wpdb->get_results( "SELECT `id`, `name` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `active` IN ('1')", ARRAY_A );
275
- //echo "<pre>".print_r($product_data,true)."</pre>";
276
  echo "<pre>";
277
  foreach ( $product_data as $product_row ) {
278
  $product_id = $product_row['id'];
@@ -319,7 +316,6 @@ function wpsc_mass_resize_thumbnails_and_clean_images() {
319
  $width = get_option( 'product_image_width' );
320
 
321
  $product_data = $wpdb->get_results( "SELECT `product`.`id`, `product`.`image` AS `image_id`, `images`.`image` AS `file` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` AS `product` INNER JOIN `" . WPSC_TABLE_PRODUCT_IMAGES . "` AS `images` ON `product`.`image` = `images`.`id` WHERE `product`.`image` > 0 ", ARRAY_A );
322
- //print_r($product_data);
323
  foreach ( (array)$product_data as $product ) {
324
  $image_input = WPSC_IMAGE_DIR . $product['file'];
325
  $image_output = WPSC_THUMBNAIL_DIR . $product['file'];
35
  </li>
36
  <li>
37
  <a href='<?php echo $fixpage; ?>'>Fix Purchaselogs</a>
38
+ </li>
39
+ <li>
40
+ <a href='<?php echo wp_nonce_url("?wpsc_admin_action=update_page_urls"); ?>' ><?php _e('Update Page URLs', 'wpsc'); ?></a>
41
+ </li>
42
+ <li>
43
+ <a href='<?php echo wp_nonce_url("?wpsc_admin_action=clean_categories"); ?>'><?php _e('Fix Product Group Permalinks', 'wpsc'); ?></a>
44
+ </li>
45
  </ul>
46
  <?php
47
  if ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && (constant( 'WPSC_ADD_DEBUG_PAGE' ) == true) ) {
121
 
122
  case 'wp_get_object_terms':
123
  global $wp_taxonomies;
 
 
124
  $tags = wp_get_object_terms( 108, 'product_tag', array( 'fields' => 'names' ) );
 
125
  print_r( $tags );
126
  break;
127
 
 
 
 
 
 
128
  case 'unicode_permalinks':
129
  $original_string = "バンプ・オブ・チキン";
130
  $sanitized_string = sanitize_title( $original_string );
270
  global $wpdb;
271
 
272
  $product_data = $wpdb->get_results( "SELECT `id`, `name` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `active` IN ('1')", ARRAY_A );
 
273
  echo "<pre>";
274
  foreach ( $product_data as $product_row ) {
275
  $product_id = $product_row['id'];
316
  $width = get_option( 'product_image_width' );
317
 
318
  $product_data = $wpdb->get_results( "SELECT `product`.`id`, `product`.`image` AS `image_id`, `images`.`image` AS `file` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` AS `product` INNER JOIN `" . WPSC_TABLE_PRODUCT_IMAGES . "` AS `images` ON `product`.`image` = `images`.`id` WHERE `product`.`image` > 0 ", ARRAY_A );
 
319
  foreach ( (array)$product_data as $product ) {
320
  $image_input = WPSC_IMAGE_DIR . $product['file'];
321
  $image_output = WPSC_THUMBNAIL_DIR . $product['file'];
wpsc-admin/display-groups.page.php CHANGED
@@ -151,7 +151,6 @@ function wpsc_admin_category_group_list() {
151
  */
152
 
153
  function wpsc_admin_display_category_row($category,$subcategory_level = 0) {
154
- //echo "<pre>".print_r($category,true)."</pre>";
155
  $category_image = wpsc_get_categorymeta($category->term_id, 'image');
156
  ?>
157
  <tr>
@@ -389,7 +388,7 @@ function wpsc_admin_category_forms($category_id = null) {
389
  }
390
  $output .= " </td>\n\r";
391
  $output .= " </tr>\n\r";
392
- ////////
393
  echo $output;
394
  ?>
395
  </div>
151
  */
152
 
153
  function wpsc_admin_display_category_row($category,$subcategory_level = 0) {
 
154
  $category_image = wpsc_get_categorymeta($category->term_id, 'image');
155
  ?>
156
  <tr>
388
  }
389
  $output .= " </td>\n\r";
390
  $output .= " </tr>\n\r";
391
+
392
  echo $output;
393
  ?>
394
  </div>
wpsc-admin/display-items.page.php CHANGED
@@ -9,14 +9,6 @@
9
  */
10
  require_once(WPSC_FILE_PATH . '/wpsc-admin/includes/products.php');
11
 
12
-
13
- /*function wpsc_image_downsize( $id, $size ) {
14
- echo "<pre>" . print_r( func_get_args(), true ) . "</pre>";
15
- exit();
16
- }
17
- */
18
- //add_filter('image_downsize', 'wpsc_image_downsize',2,3);
19
-
20
  function wpsc_display_edit_products_page() {
21
  global $wpdb, $wp_query, $wpsc_products;
22
 
@@ -46,7 +38,6 @@ function wpsc_display_edit_products_page() {
46
  $baseurl = includes_url( 'js/tinymce' );
47
  ?>
48
  <div class="wrap">
49
- <?php // screen_icon(); ?>
50
  <div id="icon_card"><br /></div>
51
  <h2>
52
  <a href="admin.php?page=wpsc-edit-products" class="nav-tab nav-tab-active" id="manage"><?php echo esc_html( __( 'Manage Products', 'wpsc' ) ); ?></a>
@@ -71,9 +62,6 @@ function wpsc_display_edit_products_page() {
71
  <div id="message" class="updated fade">
72
  <p>
73
  <?php
74
- //Not sure when or why this was added...seems to be the culprit for the constant deletion notice. Just commenting out in case it's actually necessary.
75
- // if(!isset($_GET['deleted'])) $_GET['deleted'] = 0.00;
76
-
77
  if ( isset( $_GET['updated'] ) ) {
78
  printf( _n( '%s product updated.', '%s products updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
79
  unset( $_GET['updated'] );
@@ -255,8 +243,6 @@ function wpsc_display_edit_products_page() {
255
  }
256
 
257
  if ( count( $parent_terms ) > 0 ) {
258
- //echo "<pre>".print_r($parent_terms, true)."</pre>";
259
- //echo $sql;
260
  $term_count = count( $parent_terms );
261
  $child_terms = implode( ", ", $child_terms );
262
 
@@ -274,7 +260,6 @@ function wpsc_display_edit_products_page() {
274
 
275
  GROUP BY tr.object_id
276
  HAVING `count` = {$term_count}";
277
- //echo "<br /><br />". $new_sql;
278
  return $new_sql;
279
  }
280
  }
@@ -461,7 +446,6 @@ function wpsc_display_edit_products_page() {
461
  $parent_product_data = null;
462
 
463
  wpsc_admin_product_listing( $parent_product_data );
464
- //echo "<pre>".print_r($wp_query, true)."</pre>";
465
  if ( count( $wp_query->posts ) < 1 ) {
466
  ?>
467
  <tr>
@@ -568,7 +552,6 @@ function wpsc_update_featured_products() {
568
  endif;
569
  exit();
570
  }
571
- //$sendback = add_query_arg('featured', "1", wp_get_referer());
572
  wp_redirect( wp_get_referer() );
573
  exit();
574
  }
9
  */
10
  require_once(WPSC_FILE_PATH . '/wpsc-admin/includes/products.php');
11
 
 
 
 
 
 
 
 
 
12
  function wpsc_display_edit_products_page() {
13
  global $wpdb, $wp_query, $wpsc_products;
14
 
38
  $baseurl = includes_url( 'js/tinymce' );
39
  ?>
40
  <div class="wrap">
 
41
  <div id="icon_card"><br /></div>
42
  <h2>
43
  <a href="admin.php?page=wpsc-edit-products" class="nav-tab nav-tab-active" id="manage"><?php echo esc_html( __( 'Manage Products', 'wpsc' ) ); ?></a>
62
  <div id="message" class="updated fade">
63
  <p>
64
  <?php
 
 
 
65
  if ( isset( $_GET['updated'] ) ) {
66
  printf( _n( '%s product updated.', '%s products updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
67
  unset( $_GET['updated'] );
243
  }
244
 
245
  if ( count( $parent_terms ) > 0 ) {
 
 
246
  $term_count = count( $parent_terms );
247
  $child_terms = implode( ", ", $child_terms );
248
 
260
 
261
  GROUP BY tr.object_id
262
  HAVING `count` = {$term_count}";
 
263
  return $new_sql;
264
  }
265
  }
446
  $parent_product_data = null;
447
 
448
  wpsc_admin_product_listing( $parent_product_data );
 
449
  if ( count( $wp_query->posts ) < 1 ) {
450
  ?>
451
  <tr>
552
  endif;
553
  exit();
554
  }
 
555
  wp_redirect( wp_get_referer() );
556
  exit();
557
  }
wpsc-admin/display-sales-logs.php CHANGED
@@ -34,7 +34,6 @@ function wpsc_display_sales_logs() {
34
 
35
  ?>
36
  <div class="wrap">
37
- <?php //screen_icon(); ?>
38
  <h2><?php echo esc_html( __('Sales', 'wpsc') ); ?> </h2>
39
  <?php //START OF PURCHASE LOG DEFAULT VIEW ?>
40
  <?php
@@ -84,7 +83,7 @@ function wpsc_display_sales_logs() {
84
  <?php }
85
 
86
  if(get_option('wpsc_purchaselogs_fixed')== false || (wpsc_check_uniquenames()) ){ ?>
87
- <div class='error' style='padding:8px;line-spacing:8px;'><span ><?php _e('When upgrading the Wp-E-Commerce Plugin from 3.6.* to 3.7 it is required that you associate your checkout form fields with the new Purchase Logs system. To do so please '); ?> <a href='<?php echo $fixpage; ?>'>Click Here</a></span></div>
88
  <?php }
89
  ///// end of update message section //////?>
90
  <div id='dashboard-widgets' style='min-width: 825px;'>
@@ -327,7 +326,7 @@ function wpsc_display_sales_logs() {
327
 
328
  <div class='inside'>
329
  <div class='order_summary_subsection'>
330
- <strong><?php _e('Last 30 Days', 'wpsc'); ?></strong>
331
  <p id='log_total_month'>
332
  <?php
333
  $year = date("Y");
@@ -339,7 +338,7 @@ function wpsc_display_sales_logs() {
339
  </p>
340
  </div>
341
  <div class='order_summary_subsection'>
342
- <strong><?php _e('Life Time', 'wpsc'); ?></strong>
343
  <p id='log_total_absolute'><?php echo wpsc_currency_display( admin_display_total_price() ); ?></p>
344
  </div>
345
 
@@ -643,8 +642,6 @@ function wpsc_custom_checkout_fields(){
643
  </div>
644
  <?php
645
  }
646
- //exit('<pre>'.print_r($purchlogitem, true).'</pre>');
647
-
648
  }
649
 
650
  /**
34
 
35
  ?>
36
  <div class="wrap">
 
37
  <h2><?php echo esc_html( __('Sales', 'wpsc') ); ?> </h2>
38
  <?php //START OF PURCHASE LOG DEFAULT VIEW ?>
39
  <?php
83
  <?php }
84
 
85
  if(get_option('wpsc_purchaselogs_fixed')== false || (wpsc_check_uniquenames()) ){ ?>
86
+ <div class='error' style='padding:8px;line-spacing:8px;'><span ><?php _e('When upgrading the WP e-Commerce Plugin from 3.6.* to 3.7 it is required that you associate your checkout form fields with the new Purchase Logs system. To do so please '); ?> <a href='<?php echo $fixpage; ?>'>Click Here</a></span></div>
87
  <?php }
88
  ///// end of update message section //////?>
89
  <div id='dashboard-widgets' style='min-width: 825px;'>
326
 
327
  <div class='inside'>
328
  <div class='order_summary_subsection'>
329
+ <strong><?php _e('Current Month', 'wpsc'); ?></strong>
330
  <p id='log_total_month'>
331
  <?php
332
  $year = date("Y");
338
  </p>
339
  </div>
340
  <div class='order_summary_subsection'>
341
+ <strong><?php _e('Total Income', 'wpsc'); ?></strong>
342
  <p id='log_total_absolute'><?php echo wpsc_currency_display( admin_display_total_price() ); ?></p>
343
  </div>
344
 
642
  </div>
643
  <?php
644
  }
 
 
645
  }
646
 
647
  /**
wpsc-admin/display-update.page.php CHANGED
@@ -50,7 +50,6 @@ if ( get_option( 'wpsc_version' ) < 3.8 || !get_option( 'wpsc_version' ) ) {
50
  function wpsc_display_update_page() { ?>
51
 
52
  <div class="wrap">
53
- <?php // screen_icon(); ?>
54
  <h2><?php echo esc_html( __('Update WP e-Commerce', 'wpsc') ); ?> </h2>
55
  <br />
56
 
50
  function wpsc_display_update_page() { ?>
51
 
52
  <div class="wrap">
 
53
  <h2><?php echo esc_html( __('Update WP e-Commerce', 'wpsc') ); ?> </h2>
54
  <br />
55
 
wpsc-admin/display-variations.page.php CHANGED
@@ -33,7 +33,6 @@ function wpsc_display_variations_page() {
33
  </noscript>
34
 
35
  <div class="wrap">
36
- <?php // screen_icon(); ?>
37
  <h2><?php echo esc_html( __('Display Variations', 'wpsc') ); ?> </h2>
38
  <p>
39
  <?php _e('A variation can be anything "optional" about a product. ie: Size, Color, etc <br />For example: if you are selling t-shirts you might setup a variation set called size with the values small, medium, large...', 'wpsc');?>
@@ -62,8 +61,6 @@ function wpsc_display_variations_page() {
62
  <div id='poststuff' class="col-wrap">
63
  <form id="modify-variation-groups" method="post" action="" enctype="multipart/form-data" >
64
  <?php
65
- //$product_id = absint($_GET['product_id']);
66
- //wpsc_display_product_form($product_id);
67
  wpsc_admin_variation_forms($_GET['variation_id']);
68
  ?>
69
  </form>
@@ -113,7 +110,6 @@ function wpsc_admin_variation_group_list() {
113
  'hide_empty'=> 0,
114
  'parent' => 0
115
  ));
116
- // echo "<pre>".print_r($variations,true)."</pre>";
117
  foreach((array)$variations as $variation) {
118
  ?>
119
  <tr class="variation-edit" id="variation-<?php echo $variation->term_id; ?>">
@@ -142,18 +138,11 @@ function wpsc_admin_variation_forms($variation_id = null) {
142
  $variation_name = '';
143
  if($variation_id > 0 ) {
144
  $variation_id = absint($variation_id);
145
-
146
- //$variation_name = $wpdb->get_var("SELECT `name` FROM `".WPSC_TABLE_PRODUCT_VARIATIONS."` WHERE `id`='$variation_id' LIMIT 1");
147
- //$variation_values = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `variation_id`='$variation_id' ORDER BY `id` ASC",ARRAY_A);
148
-
149
  $variation_set = get_term($variation_id, 'wpsc-variation', ARRAY_A);
150
-
151
  $variations = get_terms('wpsc-variation', array(
152
  'hide_empty' => 0,
153
  'parent' => $variation_id
154
  ));
155
- //echo "<pre>".print_r($variations,true)."</pre>";
156
- //exit();
157
  $variation_count = count($variations);
158
  }
159
  if(($_GET['valuecount'] > 0)) {
33
  </noscript>
34
 
35
  <div class="wrap">
 
36
  <h2><?php echo esc_html( __('Display Variations', 'wpsc') ); ?> </h2>
37
  <p>
38
  <?php _e('A variation can be anything "optional" about a product. ie: Size, Color, etc <br />For example: if you are selling t-shirts you might setup a variation set called size with the values small, medium, large...', 'wpsc');?>
61
  <div id='poststuff' class="col-wrap">
62
  <form id="modify-variation-groups" method="post" action="" enctype="multipart/form-data" >
63
  <?php
 
 
64
  wpsc_admin_variation_forms($_GET['variation_id']);
65
  ?>
66
  </form>
110
  'hide_empty'=> 0,
111
  'parent' => 0
112
  ));
 
113
  foreach((array)$variations as $variation) {
114
  ?>
115
  <tr class="variation-edit" id="variation-<?php echo $variation->term_id; ?>">
138
  $variation_name = '';
139
  if($variation_id > 0 ) {
140
  $variation_id = absint($variation_id);
 
 
 
 
141
  $variation_set = get_term($variation_id, 'wpsc-variation', ARRAY_A);
 
142
  $variations = get_terms('wpsc-variation', array(
143
  'hide_empty' => 0,
144
  'parent' => $variation_id
145
  ));
 
 
146
  $variation_count = count($variations);
147
  }
148
  if(($_GET['valuecount'] > 0)) {
wpsc-admin/includes/display-items-functions.php CHANGED
@@ -99,7 +99,6 @@ function wpsc_populate_product_data( $product_id, $wpsc_product_defaults ) {
99
  $tt_ids = array( );
100
  $term_ids = array( );
101
  $product = get_post( $product_id );
102
- //print("<pre>" . print_r($product, true) . "</pre>");
103
 
104
  $product_data['id'] = $product->ID;
105
  $product_data['name'] = $product->post_title;
@@ -128,15 +127,12 @@ function wpsc_populate_product_data( $product_id, $wpsc_product_defaults ) {
128
  $product_data['meta'][$meta_name] = maybe_unserialize( array_pop( $meta_value ) );
129
  }
130
  }
131
- //$sql ="SELECT `meta_key`, `meta_value` FROM ".WPSC_TABLE_PRODUCTMETA." WHERE `meta_key` LIKE 'currency%' AND `product_id`=".$product_id;
132
- //$product_data['newCurr']= $wpdb->get_results($sql, ARRAY_A);
133
  $product_data['dimensions'] = get_product_meta( $product_id, 'dimensions', true );
134
 
135
  // Transformed Values have been altered in some way since being extracted from some data source
136
  $product_data['transformed'] = array( );
137
  $product_data['transformed']['weight'] = wpsc_convert_weight( $product_data['meta']['_wpsc_product_metadata']['weight'], "gram", $product_data['meta']['_wpsc_product_metadata']['display_weight_as'] );
138
 
139
- //echo "<pre>".print_r($product_data,true)."</pre>";
140
  if ( function_exists( 'wp_insert_term' ) ) {
141
  $term_relationships = $wpdb->get_results( "SELECT * FROM `{$wpdb->term_relationships}` WHERE object_id = '{$product_data['id']}'", ARRAY_A );
142
 
@@ -178,7 +174,6 @@ function wpsc_display_product_form( $product_id = 0 ) {
178
  // we put the closed postboxes array into the Product data to propagate it to each form without having it global.
179
  $product_data['closed_postboxes'] = (array)get_user_meta( $current_user->ID, 'closedpostboxes_products_page_wpsc-edit-products' );
180
  $product_data['hidden_postboxes'] = (array)get_user_meta( $current_user->ID, 'metaboxhidden_products_page_wpsc-edit-products' );
181
- // echo '<pre>'.print_r($product_data,true).'</pre>';
182
  if ( count( $product_data ) > 0 ) {
183
  wpsc_product_basic_details_form( $product_data );
184
 
@@ -218,7 +213,6 @@ function wpsc_product_basic_details_form( &$product_data ) {
218
  $product_data['product_object'] = new stdClass();
219
  $product = $product_data['product_object'];
220
  $post_ID = (int)$product_data["id"];
221
- /* <h3 class='hndle'><?php echo __('Product Details', 'wpsc'); ?> <?php _e('(enter in your Product details here)', 'wpsc'); ?></h3> */
222
  ?>
223
  <h3 class='form_heading' style="display:none;">
224
  <?php
@@ -580,7 +574,6 @@ function wpsc_product_category_and_tag_forms( $product_data='' ) {
580
  global $closed_postboxes, $wpdb, $variations_processor;
581
 
582
  $output = '';
583
- //echo "<pre>".print_r($product_data['tags'], true)."</pre>";
584
  $tag_array = array();
585
 
586
  if ( !isset( $product_data['tags'] ) )
@@ -607,7 +600,6 @@ function wpsc_product_category_and_tag_forms( $product_data='' ) {
607
  $output .= "<div id='categorydiv' >";
608
 
609
  $search_sql = apply_filters( 'wpsc_product_category_and_tag_forms_group_search_sql', '' );
610
- //$categorisation_groups = get_terms('wpsc_product_category', "hide_empty=0&parent=0", ARRAY_A);
611
 
612
  $output .= wpsc_category_list( $product_data, 0, $product_data['id'], 'edit_' );
613
 
@@ -983,7 +975,6 @@ function wpsc_product_variation_forms( $product_data = '' ) {
983
  $parent_product_data = null;
984
 
985
  wpsc_admin_product_listing( $parent_product_data );
986
- //echo "<pre>".print_r($wp_query, true)."</pre>";
987
  if ( count( $wp_query->posts ) < 1 ) :
988
  ?>
989
  <tr>
@@ -1381,8 +1372,6 @@ function wpsc_product_advanced_forms( $product_data='' ) {
1381
 
1382
  $output = '';
1383
 
1384
- //$custom_fields = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `product_id` IN('{$product_data['id']}') AND `custom` IN('1') ",ARRAY_A);
1385
-
1386
  if ( $product_data == 'empty' )
1387
  $display = "style='display:none;'";
1388
 
@@ -1474,7 +1463,6 @@ function wpsc_product_advanced_forms( $product_data='' ) {
1474
  $output .= ob_get_contents();
1475
  ob_end_clean();
1476
 
1477
- //if (get_option('wpsc_enable_comments') == 1) {
1478
  $output .= "
1479
  <tr>
1480
  <td class='itemfirstcol' colspan='2'><br />
@@ -1487,7 +1475,6 @@ function wpsc_product_advanced_forms( $product_data='' ) {
1487
  <br/>" . __( 'Allow users to comment on this Product.', 'wpsc' ) . "
1488
  </td>
1489
  </tr>";
1490
- //}
1491
 
1492
  $output .= "
1493
  </table></div></div>";
@@ -1551,18 +1538,6 @@ function wpsc_product_image_forms( $product_data = '' ) {
1551
 
1552
  if ( $product_data == 'empty' )
1553
  $display = "style='display:none;'";
1554
-
1555
-
1556
- /* Removing all this goodness in place of the Upload Image Above - justin - 5.20
1557
- //As in WordPress, If Mac and mod_security, no Flash
1558
- $flash = true;
1559
- if ( (false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mac')) && apache_mod_loaded('mod_security') ) {
1560
- $flash = false;
1561
- }
1562
-
1563
- $flash_action_url = admin_url('async-upload.php');
1564
- $flash = apply_filters('flash_uploader', $flash);
1565
- */
1566
  ?>
1567
  <div id='wpsc_product_image_forms' class='postbox <?php echo ((array_search( 'wpsc_product_image_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : ''); ?>' <?php echo ((array_search( 'wpsc_product_image_forms', $product_data['hidden_postboxes'] ) !== false) ? 'style="display: none;"' : ''); ?> ><div class="handlediv" title="Click to toggle"><br></div>
1568
  <h3 class='hndle'> <?php _e( 'Product Images', 'wpsc' ); ?></h3>
@@ -1577,7 +1552,6 @@ function wpsc_product_image_forms( $product_data = '' ) {
1577
 
1578
  </div>
1579
  <?php
1580
- // return $output;
1581
  }
1582
 
1583
  function wpsc_product_download_forms( $product_data='' ) {
@@ -1721,7 +1695,6 @@ function wpsc_category_list( &$product_data, $group_id, $unique_id = '', $catego
1721
  $indenter = "<img class='category_indenter' src='".WPSC_CORE_IMAGES_URL."/indenter.gif' alt='' title='' />";
1722
 
1723
  }
1724
- //echo "<pre>".print_r($values, true)."</pre>";
1725
 
1726
  foreach ( (array)$values as $option ) {
1727
  $option = (array)$option;
99
  $tt_ids = array( );
100
  $term_ids = array( );
101
  $product = get_post( $product_id );
 
102
 
103
  $product_data['id'] = $product->ID;
104
  $product_data['name'] = $product->post_title;
127
  $product_data['meta'][$meta_name] = maybe_unserialize( array_pop( $meta_value ) );
128
  }
129
  }
 
 
130
  $product_data['dimensions'] = get_product_meta( $product_id, 'dimensions', true );
131
 
132
  // Transformed Values have been altered in some way since being extracted from some data source
133
  $product_data['transformed'] = array( );
134
  $product_data['transformed']['weight'] = wpsc_convert_weight( $product_data['meta']['_wpsc_product_metadata']['weight'], "gram", $product_data['meta']['_wpsc_product_metadata']['display_weight_as'] );
135
 
 
136
  if ( function_exists( 'wp_insert_term' ) ) {
137
  $term_relationships = $wpdb->get_results( "SELECT * FROM `{$wpdb->term_relationships}` WHERE object_id = '{$product_data['id']}'", ARRAY_A );
138
 
174
  // we put the closed postboxes array into the Product data to propagate it to each form without having it global.
175
  $product_data['closed_postboxes'] = (array)get_user_meta( $current_user->ID, 'closedpostboxes_products_page_wpsc-edit-products' );
176
  $product_data['hidden_postboxes'] = (array)get_user_meta( $current_user->ID, 'metaboxhidden_products_page_wpsc-edit-products' );
 
177
  if ( count( $product_data ) > 0 ) {
178
  wpsc_product_basic_details_form( $product_data );
179
 
213
  $product_data['product_object'] = new stdClass();
214
  $product = $product_data['product_object'];
215
  $post_ID = (int)$product_data["id"];
 
216
  ?>
217
  <h3 class='form_heading' style="display:none;">
218
  <?php
574
  global $closed_postboxes, $wpdb, $variations_processor;
575
 
576
  $output = '';
 
577
  $tag_array = array();
578
 
579
  if ( !isset( $product_data['tags'] ) )
600
  $output .= "<div id='categorydiv' >";
601
 
602
  $search_sql = apply_filters( 'wpsc_product_category_and_tag_forms_group_search_sql', '' );
 
603
 
604
  $output .= wpsc_category_list( $product_data, 0, $product_data['id'], 'edit_' );
605
 
975
  $parent_product_data = null;
976
 
977
  wpsc_admin_product_listing( $parent_product_data );
 
978
  if ( count( $wp_query->posts ) < 1 ) :
979
  ?>
980
  <tr>
1372
 
1373
  $output = '';
1374
 
 
 
1375
  if ( $product_data == 'empty' )
1376
  $display = "style='display:none;'";
1377
 
1463
  $output .= ob_get_contents();
1464
  ob_end_clean();
1465
 
 
1466
  $output .= "
1467
  <tr>
1468
  <td class='itemfirstcol' colspan='2'><br />
1475
  <br/>" . __( 'Allow users to comment on this Product.', 'wpsc' ) . "
1476
  </td>
1477
  </tr>";
 
1478
 
1479
  $output .= "
1480
  </table></div></div>";
1538
 
1539
  if ( $product_data == 'empty' )
1540
  $display = "style='display:none;'";
 
 
 
 
 
 
 
 
 
 
 
 
1541
  ?>
1542
  <div id='wpsc_product_image_forms' class='postbox <?php echo ((array_search( 'wpsc_product_image_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : ''); ?>' <?php echo ((array_search( 'wpsc_product_image_forms', $product_data['hidden_postboxes'] ) !== false) ? 'style="display: none;"' : ''); ?> ><div class="handlediv" title="Click to toggle"><br></div>
1543
  <h3 class='hndle'> <?php _e( 'Product Images', 'wpsc' ); ?></h3>
1552
 
1553
  </div>
1554
  <?php
 
1555
  }
1556
 
1557
  function wpsc_product_download_forms( $product_data='' ) {
1695
  $indenter = "<img class='category_indenter' src='".WPSC_CORE_IMAGES_URL."/indenter.gif' alt='' title='' />";
1696
 
1697
  }
 
1698
 
1699
  foreach ( (array)$values as $option ) {
1700
  $option = (array)$option;
wpsc-admin/includes/product-functions.php CHANGED
@@ -212,8 +212,7 @@ function wpsc_sanitise_product_forms($post_data = null) {
212
  *
213
  * @param unknown
214
  * @return unknown
215
- */
216
- // exit('Image height'.get_option('product_image_height'));
217
  function wpsc_insert_product($post_data, $wpsc_error = false) {
218
  global $wpdb, $user_ID;
219
  $adding = false;
@@ -337,9 +336,6 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
337
  // and the meta
338
  wpsc_update_product_meta($product_id, $post_data['meta']);
339
 
340
- // the variations too :jghazally commented this out cause it was OTT 20/8/2010
341
- //wpsc_edit_product_variations($product_id, $post_data);
342
-
343
  // and the custom meta
344
  wpsc_update_custom_meta($product_id, $post_data);
345
 
@@ -355,7 +351,6 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
355
  wpsc_item_reassign_file($product_id, $post_data['select_product_file']);
356
  }
357
 
358
- //exit('<pre>'.print_r($post_data, true).'</pre>');
359
  if(isset($post_data['files']['preview_file']['tmp_name']) && ($post_data['files']['preview_file']['tmp_name'] != '')) {
360
  wpsc_item_add_preview_file($product_id, $post_data['files']['preview_file']);
361
  }
@@ -464,11 +459,8 @@ function wpsc_edit_product_variations($product_id, $post_data) {
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'],
@@ -503,10 +495,7 @@ function wpsc_edit_product_variations($product_id, $post_data) {
503
  $product_values['post_title'] .= " (".implode(", ", $term_names).")";
504
  $product_values['post_name'] = sanitize_title($product_values['post_title']);
505
 
506
- // wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) {
507
-
508
  $selected_post = get_posts(array(
509
- //'numberposts' => 1,
510
  'name' => $product_values['post_name'],
511
  'post_parent' => $product_id,
512
  'post_type' => "wpsc-product",
@@ -534,7 +523,6 @@ function wpsc_edit_product_variations($product_id, $post_data) {
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") {
@@ -550,7 +538,6 @@ function wpsc_edit_product_variations($product_id, $post_data) {
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];
@@ -608,7 +595,6 @@ function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
608
  $sql = "SELECT `isocode` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`=".$newCurrency;
609
  $isocode = $wpdb->get_var($sql);
610
 
611
- //echo('<pre>'.print_r($old_curr,true).'</pre>');
612
  $newCurrency = 'currency';
613
  $old_curr[$isocode] = $newPrice;
614
  if(($newPrice != '') && ($newPrice > 0)){
@@ -620,8 +606,6 @@ function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
620
  update_product_meta($product_id, $newCurrency, $old_curr);
621
 
622
  }
623
-
624
- //exit('<pre>'.print_r($newCurrency, true).'</pre>'.$newPrice);
625
  }
626
  /**
627
  * wpsc_update_categories function
@@ -774,7 +758,6 @@ function wpsc_ajax_toggle_publish() {
774
  $status = (wpsc_toggle_publish_status($_REQUEST['productid'])) ? ('true') : ('false');
775
  exit( $status );
776
  }
777
- //add_action('wp_ajax_wpsc_toggle_publish','wpsc_ajax_toggle_publish');
778
  /*
779
  /* END - Publish /No Publish functions
780
  */
@@ -818,16 +801,13 @@ function wpsc_item_process_file($product_id, $submitted_file, $preview_file = nu
818
  $time = $post->post_date;
819
  }
820
 
821
- //$name = basename($submitted_file['name']);
822
  $file = wp_handle_upload($submitted_file, $overrides, $time);
823
 
824
  if ( isset($file['error']) )
825
  return new WP_Error( 'upload_error', $file['error'] );
826
 
827
  $name_parts = pathinfo($file['file']);
828
- //$name = trim( substr( $name, 0, -(1 + strlen($name_parts['extension'])) ) );
829
  $name = $name_parts['basename'];
830
- //echo "<pre>".print_r($name_parts,true)."</pre>"; exit();
831
 
832
  $url = $file['url'];
833
  $type = $file['type'];
@@ -849,12 +829,9 @@ function wpsc_item_process_file($product_id, $submitted_file, $preview_file = nu
849
  // Save the data
850
  $id = wp_insert_post($attachment, $file, $product_id);
851
  remove_filter('upload_dir', 'wpsc_modify_upload_directory');
852
- //return $id;
853
- //exit($id);
854
  }
855
 
856
  function wpsc_modify_upload_directory($input) {
857
- //echo "<pre>".print_r($input,true)."</pre>";
858
  $previous_subdir = $input['subdir'];
859
  $download_subdir = str_replace($input['basedir'], '', WPSC_FILE_DIR);
860
 
@@ -862,7 +839,6 @@ function wpsc_modify_upload_directory($input) {
862
  $input['url'] = str_replace($previous_subdir, $download_subdir, $input['url']);
863
  $input['subdir'] = str_replace($previous_subdir, $download_subdir, $input['subdir']);
864
 
865
- //echo "<pre>".print_r($input,true)."</pre>";
866
  return $input;
867
  }
868
 
@@ -910,26 +886,24 @@ function wpsc_item_reassign_file($product_id, $selected_files) {
910
  $file_is_attached = true;
911
  }
912
 
913
- //if(is_file($selected_file_path)) {
914
- if($file_is_attached == false ) {
915
- $type = wpsc_get_mimetype($selected_file_path);
916
- $attachment = array(
917
- 'post_mime_type' => $type,
918
- 'post_parent' => $product_id,
919
- 'post_title' => $selected_file,
920
- 'post_content' => '',
921
- 'post_type' => "wpsc-product-file",
922
- 'post_status' => 'inherit'
923
- );
924
- wp_insert_post($attachment);
925
- } else {
926
- $product_post_values = array(
927
- 'ID' => $attached_files_by_file[$selected_file]->ID,
928
- 'post_status' => 'inherit'
929
- );
930
- wp_update_post($product_post_values);
931
- }
932
- //}
933
  }
934
 
935
 
@@ -942,11 +916,7 @@ function wpsc_item_reassign_file($product_id, $selected_files) {
942
  wp_update_post($product_post_values);
943
  }
944
  }
945
-
946
-
947
- //
948
- //exit('<pre>'.print_r($attached_files, true).'</pre>');
949
- //update_product_meta($product_id, 'product_files', $product_file_list);
950
  return $fileid;
951
  }
952
 
@@ -965,7 +935,6 @@ function wpsc_item_add_preview_file($product_id, $preview_file) {
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'] )) {
968
- //echo "test?";
969
  if(function_exists("make_mp3_preview")) {
970
  if($mimetype == "audio/mpeg" && (!isset($preview_file['tmp_name']))) {
971
  // if we can generate a preview file, generate it (most can't due to sox being rare on servers and sox with MP3 support being even rarer), thus this needs to be enabled by editing code
@@ -977,13 +946,11 @@ function wpsc_item_add_preview_file($product_id, $preview_file) {
977
  copy($preview_file['tmp_name'], (WPSC_PREVIEW_DIR.$preview_filename));
978
  $preview_filepath = (WPSC_PREVIEW_DIR.$preview_filename);
979
  $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_FILES."` SET `preview` = '".$wpdb->escape($preview_filename)."', `preview_mimetype` = '".$preview_mimetype."' WHERE `id` = '{$file_data['id']}' LIMIT 1");
980
- //exit("UPDATE `".WPSC_TABLE_PRODUCT_FILES."` SET `preview` = '".$wpdb->escape($preview_filename)."', `preview_mimetype` = '".$preview_mimetype."' WHERE `id` = '{$file_data['id']}' LIMIT 1");
981
  }
982
  $stat = stat( dirname($preview_filepath));
983
  $perms = $stat['mode'] & 0000666;
984
  @ chmod( $preview_filepath, $perms );
985
  }
986
- //exit("<pre>".print_r($preview_file,true)."</pre>");
987
  return $fileid;
988
  } else {
989
  return $selected_files;
@@ -1025,7 +992,6 @@ function wpsc_variation_combinator($variation_sets) {
1025
 
1026
 
1027
  function get_combinations($batch, $elements, $i) {
1028
- //echo "<pre>".print_r($batch,true)."</pre>";
1029
  if ($i >= count($elements)) {
1030
  $this->combinations[] = $batch;
1031
  } else {
212
  *
213
  * @param unknown
214
  * @return unknown
215
+ */
 
216
  function wpsc_insert_product($post_data, $wpsc_error = false) {
217
  global $wpdb, $user_ID;
218
  $adding = false;
336
  // and the meta
337
  wpsc_update_product_meta($product_id, $post_data['meta']);
338
 
 
 
 
339
  // and the custom meta
340
  wpsc_update_custom_meta($product_id, $post_data);
341
 
351
  wpsc_item_reassign_file($product_id, $post_data['select_product_file']);
352
  }
353
 
 
354
  if(isset($post_data['files']['preview_file']['tmp_name']) && ($post_data['files']['preview_file']['tmp_name'] != '')) {
355
  wpsc_item_add_preview_file($product_id, $post_data['files']['preview_file']);
356
  }
459
 
460
 
461
  $variation_sets_and_values = array_merge($variation_sets, $variation_values);
 
462
  wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
463
 
 
 
464
  $child_product_template = array(
465
  'post_author' => $user_ID,
466
  'post_content' => $post_data['description'],
495
  $product_values['post_title'] .= " (".implode(", ", $term_names).")";
496
  $product_values['post_name'] = sanitize_title($product_values['post_title']);
497
 
 
 
498
  $selected_post = get_posts(array(
 
499
  'name' => $product_values['post_name'],
500
  'post_parent' => $product_id,
501
  'post_type' => "wpsc-product",
523
  wp_set_object_terms($child_product_id, $term_slugs, 'wpsc-variation');
524
  }
525
  //JS - 7.9 - Adding loop to include meta data in child product.
 
526
  if(!$already_a_variation){
527
  foreach ($child_product_meta as $meta_key => $meta_value ) :
528
  if ($meta_key == "_wpsc_product_metadata") {
538
  $price = array();
539
  foreach ($term_ids as $term_id_price) {
540
  $price[] = term_id_price($term_id_price, $child_product_meta["_wpsc_price"][0]);
 
541
  }
542
  rsort($price);
543
  $price = $price[0];
595
  $sql = "SELECT `isocode` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`=".$newCurrency;
596
  $isocode = $wpdb->get_var($sql);
597
 
 
598
  $newCurrency = 'currency';
599
  $old_curr[$isocode] = $newPrice;
600
  if(($newPrice != '') && ($newPrice > 0)){
606
  update_product_meta($product_id, $newCurrency, $old_curr);
607
 
608
  }
 
 
609
  }
610
  /**
611
  * wpsc_update_categories function
758
  $status = (wpsc_toggle_publish_status($_REQUEST['productid'])) ? ('true') : ('false');
759
  exit( $status );
760
  }
 
761
  /*
762
  /* END - Publish /No Publish functions
763
  */
801
  $time = $post->post_date;
802
  }
803
 
 
804
  $file = wp_handle_upload($submitted_file, $overrides, $time);
805
 
806
  if ( isset($file['error']) )
807
  return new WP_Error( 'upload_error', $file['error'] );
808
 
809
  $name_parts = pathinfo($file['file']);
 
810
  $name = $name_parts['basename'];
 
811
 
812
  $url = $file['url'];
813
  $type = $file['type'];
829
  // Save the data
830
  $id = wp_insert_post($attachment, $file, $product_id);
831
  remove_filter('upload_dir', 'wpsc_modify_upload_directory');
 
 
832
  }
833
 
834
  function wpsc_modify_upload_directory($input) {
 
835
  $previous_subdir = $input['subdir'];
836
  $download_subdir = str_replace($input['basedir'], '', WPSC_FILE_DIR);
837
 
839
  $input['url'] = str_replace($previous_subdir, $download_subdir, $input['url']);
840
  $input['subdir'] = str_replace($previous_subdir, $download_subdir, $input['subdir']);
841
 
 
842
  return $input;
843
  }
844
 
886
  $file_is_attached = true;
887
  }
888
 
889
+ if($file_is_attached == false ) {
890
+ $type = wpsc_get_mimetype($selected_file_path);
891
+ $attachment = array(
892
+ 'post_mime_type' => $type,
893
+ 'post_parent' => $product_id,
894
+ 'post_title' => $selected_file,
895
+ 'post_content' => '',
896
+ 'post_type' => "wpsc-product-file",
897
+ 'post_status' => 'inherit'
898
+ );
899
+ wp_insert_post($attachment);
900
+ } else {
901
+ $product_post_values = array(
902
+ 'ID' => $attached_files_by_file[$selected_file]->ID,
903
+ 'post_status' => 'inherit'
904
+ );
905
+ wp_update_post($product_post_values);
906
+ }
 
 
907
  }
908
 
909
 
916
  wp_update_post($product_post_values);
917
  }
918
  }
919
+
 
 
 
 
920
  return $fileid;
921
  }
922
 
935
  $file_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='{$current_file_id}' LIMIT 1",ARRAY_A);
936
 
937
  if(apply_filters( 'wpsc_filter_file', $preview_file['tmp_name'] )) {
 
938
  if(function_exists("make_mp3_preview")) {
939
  if($mimetype == "audio/mpeg" && (!isset($preview_file['tmp_name']))) {
940
  // if we can generate a preview file, generate it (most can't due to sox being rare on servers and sox with MP3 support being even rarer), thus this needs to be enabled by editing code
946
  copy($preview_file['tmp_name'], (WPSC_PREVIEW_DIR.$preview_filename));
947
  $preview_filepath = (WPSC_PREVIEW_DIR.$preview_filename);
948
  $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_FILES."` SET `preview` = '".$wpdb->escape($preview_filename)."', `preview_mimetype` = '".$preview_mimetype."' WHERE `id` = '{$file_data['id']}' LIMIT 1");
 
949
  }
950
  $stat = stat( dirname($preview_filepath));
951
  $perms = $stat['mode'] & 0000666;
952
  @ chmod( $preview_filepath, $perms );
953
  }
 
954
  return $fileid;
955
  } else {
956
  return $selected_files;
992
 
993
 
994
  function get_combinations($batch, $elements, $i) {
 
995
  if ($i >= count($elements)) {
996
  $this->combinations[] = $batch;
997
  } else {
wpsc-admin/includes/products.php CHANGED
@@ -61,15 +61,15 @@ add_filter('display_post_states','wpsc_trashed_post_status');
61
  function wpsc_product_row(&$product, $parent_product = null) {
62
  global $wp_query, $wpsc_products, $mode, $current_user;
63
  static $rowclass;
64
- //echo "<pre>".print_r($product, true)."</pre>";
65
-
66
  $global_product = $product;
67
  setup_postdata($product);
68
 
69
  $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
70
  $post_owner = ( $current_user->ID == $product->post_author ? 'self' : 'other' );
71
  $edit_link = get_edit_post_link( $product->ID );
72
-
 
73
  $title = get_the_title( $product->ID);
74
  if ( empty($title) ) {
75
  $title = __('(no title)');
@@ -82,7 +82,6 @@ function wpsc_product_row(&$product, $parent_product = null) {
82
  $posts_columns = get_column_headers('display-product-list');
83
  $posts_columns = apply_filters( 'manage_display-product-list_columns', $posts_columns );
84
  $hidden = get_hidden_columns('display-product-list');
85
- //exit('<pre>'.print_r($product,true).'</pre>');
86
 
87
  foreach ( $posts_columns as $column_name=>$column_display_name ) {
88
  $class = "class=\"$column_name column-$column_name\"";
@@ -93,7 +92,6 @@ function wpsc_product_row(&$product, $parent_product = null) {
93
 
94
  $attributes = "$class$style";
95
 
96
- //echo "<pre>".print_r($column_name,true)."</pre>".count($posts_columns);
97
  switch ($column_name) {
98
 
99
  case 'cb':
@@ -106,7 +104,7 @@ function wpsc_product_row(&$product, $parent_product = null) {
106
  <?php
107
  break;
108
 
109
- case 'date': /* !date case */
110
  if ( '0000-00-00 00:00:00' == $product->post_date && 'date' == $column_name ) {
111
  $t_time = $h_time = __('Unpublished');
112
  $time_diff = 0;
@@ -144,7 +142,7 @@ function wpsc_product_row(&$product, $parent_product = null) {
144
 
145
 
146
 
147
- case 'title': /* !title case */
148
  $attributes = 'class="post-title column-title"' . $style;
149
  $_GET["product_parent"] = '';
150
  if( isset($_GET["product"]) && ($_GET["product_parent"] == '' )){
@@ -186,8 +184,11 @@ function wpsc_product_row(&$product, $parent_product = null) {
186
 
187
  $actions = array();
188
  if ( current_user_can('edit_post', $product->ID) && 'trash' != $product->post_status ) {
189
- $actions['edit'] = '<a class="edit-product" href="'.$edit_link.'" title="' . esc_attr(__('Edit this product', 'wpsc')) . '">'. __('Edit', 'wpsc') . '</a>';
190
- $actions['quick_edit'] = "<a class='wpsc-quickedit' title='".esc_attr(__('Quick Edit', 'wpsc'))."' href='#'>".__('Quick Edit')."</a>";
 
 
 
191
  }
192
 
193
  if ( current_user_can('delete_post', $product->ID) ) {
@@ -233,7 +234,7 @@ function wpsc_product_row(&$product, $parent_product = null) {
233
 
234
 
235
 
236
- case 'image': /* !image case */
237
  ?>
238
  <td class="product-image ">
239
  <?php
@@ -277,10 +278,9 @@ function wpsc_product_row(&$product, $parent_product = null) {
277
 
278
 
279
 
280
- case 'price': /* !price case */
281
-
282
  $price = get_post_meta($product->ID, '_wpsc_price', true);
283
- // exit($product->ID.'PRICE IS: <pre>'.print_r($price, true).'</pre>');
284
  ?>
285
  <td <?php echo $attributes ?>>
286
  <?php echo wpsc_currency_display( $price ); ?>
@@ -292,13 +292,30 @@ function wpsc_product_row(&$product, $parent_product = null) {
292
 
293
  </div>
294
  </td>
 
295
  <?php
 
 
 
 
 
 
 
 
 
 
296
  break;
297
 
298
  // 5.8.2010 - Justin Sainton - Addition of weight and stock cases to column header switch.
299
 
300
  case 'weight' :
301
-
 
 
 
 
 
 
302
  $product_data['meta'] = array();
303
  $product_data['meta'] = get_post_meta($product->ID, '');
304
  foreach($product_data['meta'] as $meta_name => $meta_value) {
@@ -348,6 +365,7 @@ function wpsc_product_row(&$product, $parent_product = null) {
348
  if($stock == ''){
349
  $stock = 'N/A';
350
  }
 
351
  ?>
352
  <td <?php echo $attributes ?>>
353
  <span class="stockdisplay"><?php echo $stock; ?></span>
@@ -359,10 +377,16 @@ function wpsc_product_row(&$product, $parent_product = null) {
359
 
360
  </div>
361
  </td>
362
- <?php
 
 
 
 
 
 
363
  break;
364
 
365
- case 'categories': /* !categories case */
366
  ?>
367
  <td <?php echo $attributes ?>><?php
368
  $categories = get_the_product_category($product->ID);
@@ -380,7 +404,7 @@ function wpsc_product_row(&$product, $parent_product = null) {
380
 
381
 
382
 
383
- case 'tags': /* !tags case */
384
  ?>
385
  <td <?php echo $attributes ?>><?php
386
  $tags = get_the_tags($product->ID);
@@ -400,7 +424,13 @@ function wpsc_product_row(&$product, $parent_product = null) {
400
  if($sku == ''){
401
  $sku = 'N/A';
402
  }
403
- // exit($product->ID.'PRICE IS: <pre>'.print_r($price, true).'</pre>');
 
 
 
 
 
 
404
  ?>
405
  <td <?php echo $attributes ?>>
406
  <span class="skudisplay"><?php echo $sku; ?></span>
@@ -415,9 +445,14 @@ function wpsc_product_row(&$product, $parent_product = null) {
415
  <?php
416
  break;
417
  case 'sale_price':
418
-
 
 
 
 
 
 
419
  $price = get_post_meta($product->ID, '_wpsc_special_price', true);
420
- // exit($product->ID.'PRICE IS: <pre>'.print_r($price, true).'</pre>');
421
  ?>
422
  <td <?php echo $attributes ?>>
423
  <?php echo wpsc_currency_display( $price ); ?>
@@ -432,7 +467,7 @@ function wpsc_product_row(&$product, $parent_product = null) {
432
  break;
433
 
434
 
435
- case 'comments': /* !comments case */
436
  ?>
437
  <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
438
  <?php
@@ -449,14 +484,14 @@ function wpsc_product_row(&$product, $parent_product = null) {
449
 
450
 
451
 
452
- case 'author': /* !author case */
453
  ?>
454
  <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
455
  <?php
456
  break;
457
 
458
 
459
- case 'control_view': /* !control view case */
460
  ?>
461
  <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
462
  <?php
@@ -464,7 +499,7 @@ function wpsc_product_row(&$product, $parent_product = null) {
464
 
465
 
466
 
467
- case 'control_edit': /* !control edit case */
468
  ?>
469
  <td><?php if ( current_user_can('edit_post', $product->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
470
  <?php
@@ -472,18 +507,18 @@ function wpsc_product_row(&$product, $parent_product = null) {
472
 
473
 
474
 
475
- case 'control_delete': /* !control delete case */
476
  ?>
477
  <td><?php if ( current_user_can('delete_post', $product->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $product->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
478
  <?php
479
  break;
480
 
481
- case 'featured': /* !control featured case */
482
  ?>
483
  <td><?php do_action('manage_posts_featured_column', $product->ID); ?></td>
484
  <?php
485
  break;
486
- default: /* !default case */
487
  ?>
488
  <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $product->ID); ?></td>
489
  <?php
61
  function wpsc_product_row(&$product, $parent_product = null) {
62
  global $wp_query, $wpsc_products, $mode, $current_user;
63
  static $rowclass;
64
+ $is_parent = false;
 
65
  $global_product = $product;
66
  setup_postdata($product);
67
 
68
  $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
69
  $post_owner = ( $current_user->ID == $product->post_author ? 'self' : 'other' );
70
  $edit_link = get_edit_post_link( $product->ID );
71
+ $is_parent = wpsc_product_has_children($product->ID);
72
+ if( !empty($children) ) $is_parent = true;
73
  $title = get_the_title( $product->ID);
74
  if ( empty($title) ) {
75
  $title = __('(no title)');
82
  $posts_columns = get_column_headers('display-product-list');
83
  $posts_columns = apply_filters( 'manage_display-product-list_columns', $posts_columns );
84
  $hidden = get_hidden_columns('display-product-list');
 
85
 
86
  foreach ( $posts_columns as $column_name=>$column_display_name ) {
87
  $class = "class=\"$column_name column-$column_name\"";
92
 
93
  $attributes = "$class$style";
94
 
 
95
  switch ($column_name) {
96
 
97
  case 'cb':
104
  <?php
105
  break;
106
 
107
+ case 'date':
108
  if ( '0000-00-00 00:00:00' == $product->post_date && 'date' == $column_name ) {
109
  $t_time = $h_time = __('Unpublished');
110
  $time_diff = 0;
142
 
143
 
144
 
145
+ case 'title':
146
  $attributes = 'class="post-title column-title"' . $style;
147
  $_GET["product_parent"] = '';
148
  if( isset($_GET["product"]) && ($_GET["product_parent"] == '' )){
184
 
185
  $actions = array();
186
  if ( current_user_can('edit_post', $product->ID) && 'trash' != $product->post_status ) {
187
+ $actions['edit'] = '<a class="edit-product" href="'.$edit_link.'" title="' . esc_attr(__('Edit this product', 'wpsc')) . '">'. __('Edit', 'wpsc') . '</a>';
188
+ if(!$is_parent)
189
+ $actions['quick_edit'] = "<a class='wpsc-quickedit' title='".esc_attr(__('Quick Edit', 'wpsc'))."' href='#'>".__('Quick Edit')."</a>";
190
+ else
191
+ $actions['quick_edit'] = __('Quick Edit');
192
  }
193
 
194
  if ( current_user_can('delete_post', $product->ID) ) {
234
 
235
 
236
 
237
+ case 'image':
238
  ?>
239
  <td class="product-image ">
240
  <?php
278
 
279
 
280
 
281
+ case 'price':
282
+ if(!$is_parent){
283
  $price = get_post_meta($product->ID, '_wpsc_price', true);
 
284
  ?>
285
  <td <?php echo $attributes ?>>
286
  <?php echo wpsc_currency_display( $price ); ?>
292
 
293
  </div>
294
  </td>
295
+
296
  <?php
297
+
298
+ }else{
299
+ $price = wpsc_product_variation_price_available($product->ID);
300
+ ?>
301
+ <td >
302
+ <?php echo $price.'+' ; ?>
303
+
304
+ </td>
305
+ <?php
306
+ }
307
  break;
308
 
309
  // 5.8.2010 - Justin Sainton - Addition of weight and stock cases to column header switch.
310
 
311
  case 'weight' :
312
+ if($is_parent){ ?>
313
+ <td>
314
+ <?php _e( 'N/A', 'wpsc'); ?>
315
+ </td>
316
+ <?php
317
+ break;
318
+ }
319
  $product_data['meta'] = array();
320
  $product_data['meta'] = get_post_meta($product->ID, '');
321
  foreach($product_data['meta'] as $meta_name => $meta_value) {
365
  if($stock == ''){
366
  $stock = 'N/A';
367
  }
368
+ if(!$is_parent){
369
  ?>
370
  <td <?php echo $attributes ?>>
371
  <span class="stockdisplay"><?php echo $stock; ?></span>
377
 
378
  </div>
379
  </td>
380
+ <?php
381
+ }else{
382
+ ?> <td>
383
+ <?php echo '~'.wpsc_variations_stock_remaining($product->ID); ?>
384
+ </td>
385
+ <?php
386
+ }
387
  break;
388
 
389
+ case 'categories':
390
  ?>
391
  <td <?php echo $attributes ?>><?php
392
  $categories = get_the_product_category($product->ID);
404
 
405
 
406
 
407
+ case 'tags':
408
  ?>
409
  <td <?php echo $attributes ?>><?php
410
  $tags = get_the_tags($product->ID);
424
  if($sku == ''){
425
  $sku = 'N/A';
426
  }
427
+ if($is_parent) {
428
+ ?>
429
+ <td> <?php echo $sku; ?></td>
430
+ <?php
431
+ break;
432
+ }
433
+
434
  ?>
435
  <td <?php echo $attributes ?>>
436
  <span class="skudisplay"><?php echo $sku; ?></span>
445
  <?php
446
  break;
447
  case 'sale_price':
448
+ if( $is_parent ){ ?>
449
+ <td>
450
+ <?php _e('N/A' , 'wpsc'); ?>
451
+ </td>
452
+ <?php
453
+ break;
454
+ }
455
  $price = get_post_meta($product->ID, '_wpsc_special_price', true);
 
456
  ?>
457
  <td <?php echo $attributes ?>>
458
  <?php echo wpsc_currency_display( $price ); ?>
467
  break;
468
 
469
 
470
+ case 'comments':
471
  ?>
472
  <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
473
  <?php
484
 
485
 
486
 
487
+ case 'author':
488
  ?>
489
  <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
490
  <?php
491
  break;
492
 
493
 
494
+ case 'control_view':
495
  ?>
496
  <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
497
  <?php
499
 
500
 
501
 
502
+ case 'control_edit':
503
  ?>
504
  <td><?php if ( current_user_can('edit_post', $product->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
505
  <?php
507
 
508
 
509
 
510
+ case 'control_delete':
511
  ?>
512
  <td><?php if ( current_user_can('delete_post', $product->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $product->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
513
  <?php
514
  break;
515
 
516
+ case 'featured':
517
  ?>
518
  <td><?php do_action('manage_posts_featured_column', $product->ID); ?></td>
519
  <?php
520
  break;
521
+ default:
522
  ?>
523
  <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $product->ID); ?></td>
524
  <?php
wpsc-admin/includes/purchlogs_upgrade.php CHANGED
@@ -4,9 +4,7 @@
4
  $numQueries = 0;
5
  $purchlog = "SELECT DISTINCT id FROM `".WPSC_TABLE_PURCHASE_LOGS."` LIMIT 1";
6
  $id = $wpdb->get_var($purchlog);
7
- //exit($id);
8
  $usersql = "SELECT DISTINCT `".WPSC_TABLE_SUBMITED_FORM_DATA."`.value, `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN `".WPSC_TABLE_SUBMITED_FORM_DATA."` ON `".WPSC_TABLE_CHECKOUT_FORMS."`.id = `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`form_id` WHERE `".WPSC_TABLE_SUBMITED_FORM_DATA."`.log_id=".$id." ORDER BY `".WPSC_TABLE_CHECKOUT_FORMS."`.`order`" ;
9
- //exit($usersql);
10
  $formfields = $wpdb->get_results($usersql);
11
 
12
 
@@ -16,15 +14,11 @@
16
  $formfields = $wpdb->get_results($usersql);
17
 
18
  }
19
- //exit('<pre>'.print_r($formfields,true).'</pre>');
20
- //echo '<pre>'.print_r($formfields, true).'</pre>';
21
  if(isset($_POST)){
22
- //echo '<pre>'.print_r($_POST, true).'</pre>';
23
  foreach($_POST as $key=>$value){
24
  if($value != '-1'){
25
  $sql = "UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `unique_name`='".$value."' WHERE id=".$key;
26
  $complete = $wpdb->query($sql);
27
- // exit(' ' .$sql);
28
  }
29
  $numChaged++;
30
  $numQueries ++;
@@ -102,7 +96,6 @@ function wpsc_select_options_purchlogs_fix($id){
102
  }
103
 
104
  }
105
- //exit('<pre>'.print_r($duplicate, true).'</pre>');
106
  ?>
107
  <input type='submit' value='Apply' class='button-secondary action' />
108
  </form>
4
  $numQueries = 0;
5
  $purchlog = "SELECT DISTINCT id FROM `".WPSC_TABLE_PURCHASE_LOGS."` LIMIT 1";
6
  $id = $wpdb->get_var($purchlog);
 
7
  $usersql = "SELECT DISTINCT `".WPSC_TABLE_SUBMITED_FORM_DATA."`.value, `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN `".WPSC_TABLE_SUBMITED_FORM_DATA."` ON `".WPSC_TABLE_CHECKOUT_FORMS."`.id = `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`form_id` WHERE `".WPSC_TABLE_SUBMITED_FORM_DATA."`.log_id=".$id." ORDER BY `".WPSC_TABLE_CHECKOUT_FORMS."`.`order`" ;
 
8
  $formfields = $wpdb->get_results($usersql);
9
 
10
 
14
  $formfields = $wpdb->get_results($usersql);
15
 
16
  }
 
 
17
  if(isset($_POST)){
 
18
  foreach($_POST as $key=>$value){
19
  if($value != '-1'){
20
  $sql = "UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `unique_name`='".$value."' WHERE id=".$key;
21
  $complete = $wpdb->query($sql);
 
22
  }
23
  $numChaged++;
24
  $numQueries ++;
96
  }
97
 
98
  }
 
99
  ?>
100
  <input type='submit' value='Apply' class='button-secondary action' />
101
  </form>
wpsc-admin/includes/save-data.functions.php CHANGED
@@ -34,12 +34,6 @@ function wpsc_save_variation_set() {
34
  }
35
  }
36
 
37
-
38
-
39
-
40
- //print("<pre>".print_r($term,true)."</pre>");
41
- //exit("<pre>".print_r($_POST,true)."</pre>");
42
-
43
  if(($_POST['submit_action'] == "add") || ($_POST['submit_action'] == "edit")) {
44
  check_admin_referer('edit-variation', 'wpsc-edit-variation');
45
 
@@ -51,8 +45,6 @@ function wpsc_save_variation_set() {
51
  $term = wp_insert_term( $name, 'wpsc-variation',array('parent' => 0));
52
  }
53
 
54
- //print("<pre>".print_r($term,true)."</pre>");
55
- //exit("<pre>".print_r($_POST,true)."</pre>");
56
  if(!empty($term)) {
57
  $variation_id = $term['term_id'];
58
  $variation_values = $_POST['new_variation_values'];
@@ -80,22 +72,15 @@ function wpsc_save_variation_set() {
80
  ));
81
  }
82
 
83
-
84
-
85
-
86
- //exit("<pre>".print_r($_POST, true)."</pre>");
87
  foreach($_POST['variation_values'] as $variation_value_id => $variation_value_name) {
88
  if(is_numeric($variation_value_id)) {
89
  $variation_value_id = absint($variation_value_id);
90
  wp_update_term($variation_value_id, 'wpsc-variation', array(
91
  'name' => $variation_value_name
92
  ));
93
- //$variation_value_state = $wpdb->get_results("SELECT `name` FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id` = '$variation_value_id' AND `variation_id` = '$variation_id' LIMIT 1",ARRAY_A);
94
- //$variation_value_state = $variation_value_state[0]['name'];
95
  }
96
 
97
  if($variation_value_state != $variation_value) {
98
- //$wpdb->query("UPDATE `".WPSC_TABLE_VARIATION_VALUES."` SET `name` = '".$wpdb->escape($variation_value)."' WHERE `id` = '$variation_value_id' AND `variation_id` = '".$variation_id."' LIMIT 1;");
99
  }
100
  }
101
 
@@ -120,7 +105,6 @@ function wpsc_save_variation_set() {
120
  $sendback = add_query_arg('page', 'wpsc-edit-variations', $sendback);
121
  }
122
  $sendback = add_query_arg('message', 1, $sendback);
123
- //exit($sendback);
124
  wp_redirect($sendback);
125
  }
126
 
@@ -174,7 +158,6 @@ function wpsc_save_category_set() {
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;
@@ -185,14 +168,12 @@ function wpsc_save_category_set() {
185
  $category = get_term_by('id', $category_id, 'wpsc_product_category');
186
  $url_name=$category->slug;
187
 
188
- //$wp_rewrite->flush_rules();
189
  if($category_id > 0) {
190
  wpsc_update_categorymeta($category_id, 'nice-name', $url_name);
191
  wpsc_update_categorymeta($category_id, 'description', $wpdb->escape(stripslashes($_POST['description'])));
192
  if($image != '') {
193
  wpsc_update_categorymeta($category_id, 'image', $image);
194
  }
195
- //wpsc_update_categorymeta($category_id, 'image', $image);
196
  wpsc_update_categorymeta($category_id, 'fee', '0');
197
  wpsc_update_categorymeta($category_id, 'active', '1');
198
  wpsc_update_categorymeta($category_id, 'order', '0');
@@ -245,7 +226,6 @@ function wpsc_save_category_set() {
245
  'name' => $name , 'parent' => $parent_category
246
  ));
247
  $category = get_term($category_id, 'wpsc_product_category');
248
- //$wp_rewrite->flush_rules();
249
  }
250
 
251
 
34
  }
35
  }
36
 
 
 
 
 
 
 
37
  if(($_POST['submit_action'] == "add") || ($_POST['submit_action'] == "edit")) {
38
  check_admin_referer('edit-variation', 'wpsc-edit-variation');
39
 
45
  $term = wp_insert_term( $name, 'wpsc-variation',array('parent' => 0));
46
  }
47
 
 
 
48
  if(!empty($term)) {
49
  $variation_id = $term['term_id'];
50
  $variation_values = $_POST['new_variation_values'];
72
  ));
73
  }
74
 
 
 
 
 
75
  foreach($_POST['variation_values'] as $variation_value_id => $variation_value_name) {
76
  if(is_numeric($variation_value_id)) {
77
  $variation_value_id = absint($variation_value_id);
78
  wp_update_term($variation_value_id, 'wpsc-variation', array(
79
  'name' => $variation_value_name
80
  ));
 
 
81
  }
82
 
83
  if($variation_value_state != $variation_value) {
 
84
  }
85
  }
86
 
105
  $sendback = add_query_arg('page', 'wpsc-edit-variations', $sendback);
106
  }
107
  $sendback = add_query_arg('message', 1, $sendback);
 
108
  wp_redirect($sendback);
109
  }
110
 
158
  $term = wp_insert_term( $name, 'wpsc_product_category',array('parent' => $parent_category));
159
 
160
  if (is_wp_error($term)) {
 
161
  $sendback = add_query_arg('message',$term->get_error_code());
162
  wp_redirect($sendback);
163
  return;
168
  $category = get_term_by('id', $category_id, 'wpsc_product_category');
169
  $url_name=$category->slug;
170
 
 
171
  if($category_id > 0) {
172
  wpsc_update_categorymeta($category_id, 'nice-name', $url_name);
173
  wpsc_update_categorymeta($category_id, 'description', $wpdb->escape(stripslashes($_POST['description'])));
174
  if($image != '') {
175
  wpsc_update_categorymeta($category_id, 'image', $image);
176
  }
 
177
  wpsc_update_categorymeta($category_id, 'fee', '0');
178
  wpsc_update_categorymeta($category_id, 'active', '1');
179
  wpsc_update_categorymeta($category_id, 'order', '0');
226
  'name' => $name , 'parent' => $parent_category
227
  ));
228
  $category = get_term($category_id, 'wpsc_product_category');
 
229
  }
230
 
231
 
wpsc-admin/includes/settings-pages/admin.php CHANGED
@@ -154,63 +154,7 @@ global $wpdb;
154
  <td><textarea name="wpsc_options[wpsc_trackingid_message]" cols='' rows='' style='width: 300px; height: 200px;'><?php echo stripslashes(get_option('wpsc_trackingid_message'));?></textarea></td>
155
  </tr>
156
  </table>
157
- <h3 class="form_group"><?php _e('URL Settings', 'wpsc');?>:</h3>
158
- <table class='wpsc_options form-table'>
159
-
160
- <tr class='merged'>
161
- <th scope="row">
162
- <?php _e('The location of the product list', 'wpsc');?>:
163
- </th>
164
- <td>
165
- <input class='text' type='text' size='50' value='<?php echo get_option('product_list_url'); ?>' name='wpsc_options[product_list_url]' />
166
- </td>
167
- </tr>
168
- <tr class='merged'>
169
- <th scope="row">
170
- <?php _e('The location of the shopping cart', 'wpsc');?>:
171
- </th>
172
- <td>
173
- <input class='text' type='text' size='50' value='<?php echo get_option('shopping_cart_url'); ?>' name='wpsc_options[shopping_cart_url]' />
174
- </td>
175
- </tr>
176
- <?php /*
177
- <tr class='merged'>
178
- <th scope="row">
179
- <?php _e('The location of the checkout page', 'wpsc');?>:
180
- </th>
181
- <td>
182
- <input class='text' type='text' size='50' value='<?php echo get_option('checkout_url'); ?>' name='checkout_url' />
183
- </td>
184
- </tr>*/
185
- ?>
186
- <tr class='merged'>
187
- <th scope="row">
188
- <?php _e('Transaction Details URL', 'wpsc');?>:
189
- </th>
190
- <td>
191
- <input class='text' type='text' size='50' value='<?php echo get_option('transact_url'); ?>' name='wpsc_options[transact_url]' />
192
- </td>
193
- </tr>
194
- <?php
195
- if(function_exists("nzshpcrt_user_log")) {
196
- ?>
197
- <tr class='merged'>
198
- <th scope="row">
199
- <?php _e('User Account URL', 'wpsc');?>:
200
- </th>
201
- <td>
202
- <input class='text' type='text' size='50' value='<?php echo get_option('user_account_url'); ?>' name='wpsc_options[user_account_url]' />
203
- </td>
204
- </tr>
205
- <?php
206
- }
207
- ?>
208
- <tr class='merged'>
209
- <td colspan="2"><a href='<?php echo wp_nonce_url("?wpsc_admin_action=update_page_urls"); ?>' ><?php _e('Update Page URLs', 'wpsc'); ?></a> &nbsp; | &nbsp;
210
- <a href='<?php echo wp_nonce_url("?wpsc_admin_action=clean_categories"); ?>'><?php _e('Fix Product Group Permalinks', 'wpsc'); ?></a>
211
- </td>
212
- </tr>
213
- </table>
214
  <?php
215
  /* here end the admin options */
216
  ?>
154
  <td><textarea name="wpsc_options[wpsc_trackingid_message]" cols='' rows='' style='width: 300px; height: 200px;'><?php echo stripslashes(get_option('wpsc_trackingid_message'));?></textarea></td>
155
  </tr>
156
  </table>
157
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  <?php
159
  /* here end the admin options */
160
  ?>
wpsc-admin/includes/settings-pages/checkout.php CHANGED
@@ -26,7 +26,6 @@ do_action('wpsc_checkout_form_fields_page');
26
  $columns = array(
27
  'drag' => 'Drag',
28
  'name' => 'Name',
29
- //'alt_name' => 'Alternate Name',
30
  'type' => 'Type',
31
  'unique_names' => 'Unique Names',
32
  'mandatory' => 'Mandatory',
@@ -188,8 +187,6 @@ $form_types = get_option('wpsc_checkout_form_fields');
188
  echo "<tr id='checkout_".$form_field['id']."' class='checkout_form_field'>\n\r";
189
  echo '<td class="drag"><a href="" onclick="return false;" title="Click and Drag to Order Checkout Fields"><img src="' . WPSC_CORE_IMAGES_URL . '/roll-over-drag.jpg" alt="roll-over-drag" /></a></td>';
190
  echo "<td class='namecol'><input type='text' name='form_name[".$form_field['id']."]' value='".htmlentities(stripslashes($form_field['name']), ENT_QUOTES, "UTF-8")."' /></td>";
191
-
192
- //echo "<td class='namecol'><input type='text' name='form_name[".$form_field['id']."]' value='".$form_field['name']."' /></td>";
193
 
194
  echo " <td class='typecol'>";
195
  echo "<select class='wpsc_checkout_selectboxes' name='form_type[".$form_field['id']."]'>";
@@ -198,7 +195,6 @@ $form_types = get_option('wpsc_checkout_form_fields');
198
  if($form_type === $form_field['type']) {
199
  $selected = "selected='selected'";
200
  }
201
- // define('__('Textarea', 'wpsc')', 'Textarea');
202
  echo "<option value='".$form_type."' ".$selected.">".__($form_type_name, 'wpsc')."</option>";
203
  }
204
 
26
  $columns = array(
27
  'drag' => 'Drag',
28
  'name' => 'Name',
 
29
  'type' => 'Type',
30
  'unique_names' => 'Unique Names',
31
  'mandatory' => 'Mandatory',
187
  echo "<tr id='checkout_".$form_field['id']."' class='checkout_form_field'>\n\r";
188
  echo '<td class="drag"><a href="" onclick="return false;" title="Click and Drag to Order Checkout Fields"><img src="' . WPSC_CORE_IMAGES_URL . '/roll-over-drag.jpg" alt="roll-over-drag" /></a></td>';
189
  echo "<td class='namecol'><input type='text' name='form_name[".$form_field['id']."]' value='".htmlentities(stripslashes($form_field['name']), ENT_QUOTES, "UTF-8")."' /></td>";
 
 
190
 
191
  echo " <td class='typecol'>";
192
  echo "<select class='wpsc_checkout_selectboxes' name='form_type[".$form_field['id']."]'>";
195
  if($form_type === $form_field['type']) {
196
  $selected = "selected='selected'";
197
  }
 
198
  echo "<option value='".$form_type."' ".$selected.">".__($form_type_name, 'wpsc')."</option>";
199
  }
200
 
wpsc-admin/includes/settings-pages/gateway.php CHANGED
@@ -17,7 +17,6 @@ function wpsc_options_gateway() {
17
  $selected = "selected='selected'";
18
  $form = $gateway['form']();
19
  $selected_gateway_data = $gateway;
20
- //exit($form);
21
  } else {
22
  $selected = '';
23
  }
@@ -48,7 +47,6 @@ function wpsc_options_gateway() {
48
  </script>
49
 
50
  <div class="wrap">
51
- <?php // global $nzshpcrt_gateways; print_r($nzshpcrt_gateways);?>
52
  <div class='metabox-holder'>
53
  <form name='gatewayopt' method='post' id='gateway_opt' action='' >
54
  <input type='hidden' name='gateway_submits' value='true' />
@@ -81,7 +79,6 @@ function wpsc_options_gateway() {
81
  <br />
82
  <?php
83
  $selected_gateways = get_option( 'custom_gateway_options' );
84
- //echo("<pre>".print_r($selected_gateways,true)."</pre>");
85
  foreach ( $nzshpcrt_gateways as $gateway ) {
86
  if ( isset( $gateway['admin_name'] ) )
87
  $gateway['name'] = $gateway['admin_name'];
17
  $selected = "selected='selected'";
18
  $form = $gateway['form']();
19
  $selected_gateway_data = $gateway;
 
20
  } else {
21
  $selected = '';
22
  }
47
  </script>
48
 
49
  <div class="wrap">
 
50
  <div class='metabox-holder'>
51
  <form name='gatewayopt' method='post' id='gateway_opt' action='' >
52
  <input type='hidden' name='gateway_submits' value='true' />
79
  <br />
80
  <?php
81
  $selected_gateways = get_option( 'custom_gateway_options' );
 
82
  foreach ( $nzshpcrt_gateways as $gateway ) {
83
  if ( isset( $gateway['admin_name'] ) )
84
  $gateway['name'] = $gateway['admin_name'];
wpsc-admin/includes/settings-pages/general.php CHANGED
@@ -43,45 +43,6 @@ function wpsc_options_general() {
43
  <br /><?php _e( 'Select your primary business location.', 'wpsc' ); ?>
44
  </td>
45
  </tr>
46
- <?php
47
- /* SEE TAX SETTINGS PAGE
48
- <tr>
49
- <th scope="row"><?php _e('Tax Settings', 'wpsc');?>:</th>
50
- <td>
51
- <span id='options_region'>
52
- <?php
53
- $country_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode`='".get_option('base_country')."' LIMIT 1",ARRAY_A);
54
- echo $country_data['country'];
55
- $region_count = $wpdb->get_var("SELECT COUNT(*) AS `count` FROM `".WPSC_TABLE_REGION_TAX."`, `".WPSC_TABLE_CURRENCY_LIST."` WHERE `".WPSC_TABLE_CURRENCY_LIST."`.`isocode` IN('".get_option('base_country')."') AND `".WPSC_TABLE_CURRENCY_LIST."`.`id` = `".WPSC_TABLE_REGION_TAX."`.`country_id`") ;
56
- if($country_data['has_regions'] == 1) {
57
- ?>&nbsp;&nbsp;&nbsp;&nbsp;<a href='<?php echo add_query_arg(array( 'page' => 'wpsc-settings', 'isocode' => get_option('base_country') )); ?>'><?php echo $region_count ?> Regions</a>
58
- <?php } else { ?>
59
- <input type='hidden' name='country_id' value='<?php echo $country_data['id']; ?>' />
60
- &nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='country_tax' class='tax_forms' maxlength='5' size='5' value='<?php echo $country_data['tax']; ?>' />%
61
- <?php } ?>
62
- </span>
63
- </td>
64
- </tr>
65
- <tr>
66
- <th scope="row"><?php _e('Tax Included in prices','wpsc') ?>:</th>
67
- <td>
68
- <?php
69
- $tax_inprice0= '';
70
- $tax_inprice1= '';
71
- if(wpsc_tax_isincluded()){
72
- $tax_inprice1= 'checked="checked"';
73
- }else{
74
- $tax_inprice0= 'checked="checked"';
75
- }
76
- ?>
77
- <input <?php echo $tax_inprice1; ?> type='radio' name='wpsc_options[tax_inprice]' value='1' id='tax_inprice1' />
78
- <label for='tax_inprice1'><?php _e('Yes', 'wpsc'); ?></label>
79
- <input <?php echo $tax_inprice0; ?> type='radio' name='wpsc_options[tax_inprice]' value='0' id='tax_inprice0' />
80
- <label for='tax_inprice1'><?php _e('No', 'wpsc'); ?></label>
81
- </td>
82
- </tr>
83
- END SEE TAX SETTINGS PAGE */
84
- ?>
85
  <?php
86
  /* START OF TARGET MARKET SELECTION */
87
  $countrylist = $wpdb->get_results( "SELECT id,country,visible FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC ", ARRAY_A );
43
  <br /><?php _e( 'Select your primary business location.', 'wpsc' ); ?>
44
  </td>
45
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  <?php
47
  /* START OF TARGET MARKET SELECTION */
48
  $countrylist = $wpdb->get_results( "SELECT id,country,visible FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC ", ARRAY_A );
wpsc-admin/includes/settings-pages/import.php CHANGED
@@ -16,15 +16,11 @@ function wpsc_options_import() {
16
  <input type='file' name='csv_file' />
17
  <input type='submit' value='Import' class='button-primary'>
18
  <?php
19
- //exit('<pre>'.print_r($_FILES, true).'</pre>');
20
-
21
  if ( isset( $_FILES['csv_file']['name'] ) && ($_FILES['csv_file']['name'] != '') ) {
22
  ini_set( "auto_detect_line_endings", 1 );
23
  $file = $_FILES['csv_file'];
24
- //exit('<pre>'.print_r($file,true).'</pre>');
25
  if ( move_uploaded_file( $file['tmp_name'], WPSC_FILE_DIR . $file['name'] ) ) {
26
  $content = file_get_contents( WPSC_FILE_DIR . $file['name'] );
27
- //exit('<pre>'.print_r(WPSC_FILE_DIR.$file['name'], true).'</pre>');
28
  $handle = @fopen( WPSC_FILE_DIR . $file['name'], 'r' );
29
  while ( ($csv_data = @fgetcsv( $handle, filesize( $handle ), "," )) !== false ) {
30
  $fields = count( $csv_data );
16
  <input type='file' name='csv_file' />
17
  <input type='submit' value='Import' class='button-primary'>
18
  <?php
 
 
19
  if ( isset( $_FILES['csv_file']['name'] ) && ($_FILES['csv_file']['name'] != '') ) {
20
  ini_set( "auto_detect_line_endings", 1 );
21
  $file = $_FILES['csv_file'];
 
22
  if ( move_uploaded_file( $file['tmp_name'], WPSC_FILE_DIR . $file['name'] ) ) {
23
  $content = file_get_contents( WPSC_FILE_DIR . $file['name'] );
 
24
  $handle = @fopen( WPSC_FILE_DIR . $file['name'], 'r' );
25
  while ( ($csv_data = @fgetcsv( $handle, filesize( $handle ), "," )) !== false ) {
26
  $fields = count( $csv_data );
wpsc-admin/includes/settings-pages/presentation.php CHANGED
@@ -102,8 +102,7 @@ function wpsc_theme_presentation_page_metabox(){
102
  <?php } ?>
103
  <p><?php
104
  wp_nonce_field('wpsc_copy_themes');
105
-
106
- //printf( __( "<a href='%s' class='button preview'>Move Theme Files</a>", 'wpsc' ), wp_nonce_url( "admin.php?wpsc_admin_action=copy_themes", 'copy_themes' ) ); ?>
107
  <input type='submit' value='Move Template Files' class="button" name='wpsc_move_themes' />
108
  <?php printf( __( '<a href="%s" class="button preview">Backup Your Theme</a>', 'wpsc' ), wp_nonce_url( 'admin.php?wpsc_admin_action=backup_themes', 'backup_themes' ) ); ?>
109
  <?php printf( __( '<a href="%s" class="button preview">Flush Theme Cache</a>', 'wpsc' ), wp_nonce_url( 'admin.php?wpsc_flush_theme_transients=true', 'wpsc_flush_theme_transients' ) ); ?>
@@ -153,7 +152,6 @@ function options_categorylist() {
153
  $categorylist .= "<option value='all+list' " . $selected . " >" . __( 'Show all products + list', 'wpsc' ) . "</option>";
154
  $categorylist .= "<optgroup label='Product Categories'>";
155
  foreach ( $group_data as $group ) {
156
- //$group = (array)$group;
157
  $selected = "";
158
  if ( get_option( 'wpsc_default_category' ) == $group->term_id )
159
  $selected = "selected='selected'";
102
  <?php } ?>
103
  <p><?php
104
  wp_nonce_field('wpsc_copy_themes');
105
+ ?>
 
106
  <input type='submit' value='Move Template Files' class="button" name='wpsc_move_themes' />
107
  <?php printf( __( '<a href="%s" class="button preview">Backup Your Theme</a>', 'wpsc' ), wp_nonce_url( 'admin.php?wpsc_admin_action=backup_themes', 'backup_themes' ) ); ?>
108
  <?php printf( __( '<a href="%s" class="button preview">Flush Theme Cache</a>', 'wpsc' ), wp_nonce_url( 'admin.php?wpsc_flush_theme_transients=true', 'wpsc_flush_theme_transients' ) ); ?>
152
  $categorylist .= "<option value='all+list' " . $selected . " >" . __( 'Show all products + list', 'wpsc' ) . "</option>";
153
  $categorylist .= "<optgroup label='Product Categories'>";
154
  foreach ( $group_data as $group ) {
 
155
  $selected = "";
156
  if ( get_option( 'wpsc_default_category' ) == $group->term_id )
157
  $selected = "selected='selected'";
wpsc-admin/includes/settings-pages/shipping.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  function wpsc_options_shipping() {
4
  global $wpdb, $wpsc_shipping_modules, $external_shipping_modules, $internal_shipping_modules;
5
- //exit('<pre>'.print_r($wpsc_shipping_modules,true).'</pre>');
6
  // sort into external and internal arrays.
7
  foreach ( $GLOBALS['wpsc_shipping_modules'] as $key => $module ) {
8
  if ( isset( $module->is_external ) && ($module->is_external == true) ) {
@@ -56,7 +55,6 @@ function wpsc_options_shipping() {
56
  <td>
57
  <?php
58
  $do_not_use_shipping = get_option( 'do_not_use_shipping' );
59
- // exit($do_not_use_shipping);
60
  $do_not_use_shipping1 = "";
61
  $do_not_use_shipping2 = "";
62
  if( $do_not_use_shipping )
2
 
3
  function wpsc_options_shipping() {
4
  global $wpdb, $wpsc_shipping_modules, $external_shipping_modules, $internal_shipping_modules;
 
5
  // sort into external and internal arrays.
6
  foreach ( $GLOBALS['wpsc_shipping_modules'] as $key => $module ) {
7
  if ( isset( $module->is_external ) && ($module->is_external == true) ) {
55
  <td>
56
  <?php
57
  $do_not_use_shipping = get_option( 'do_not_use_shipping' );
 
58
  $do_not_use_shipping1 = "";
59
  $do_not_use_shipping2 = "";
60
  if( $do_not_use_shipping )
wpsc-admin/includes/tax_and_shipping.php CHANGED
@@ -1,24 +1,6 @@
1
  <?php
2
  global $wpdb;
3
  $changes_made = false;
4
-
5
-
6
- // function country_list($selected_country = null)
7
- // {
8
- // global $wpdb;
9
- // $output = "";
10
- // $country_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY `country` ASC",ARRAY_A);
11
- // foreach ($country_data as $country)
12
- // {
13
- // $selected ='';
14
- // if($selected_country == $country['isocode'])
15
- // {
16
- // $selected = "selected='true'";
17
- // }
18
- // $output .= "<option value='".$country['isocode']."' $selected>".$country['country']."</option>";
19
- // }
20
- // return $output;
21
- // }
22
 
23
  if(preg_match("/[a-zA-Z]{2,4}/",$_GET['isocode']))
24
  {
1
  <?php
2
  global $wpdb;
3
  $changes_made = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  if(preg_match("/[a-zA-Z]{2,4}/",$_GET['isocode']))
6
  {
wpsc-admin/includes/updating-functions.php CHANGED
@@ -241,7 +241,6 @@ GROUP BY ".WPSC_TABLE_PRODUCT_LIST.".id", ARRAY_A);
241
  if(isset($post_data['meta'])) {
242
  $post_data['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
243
  }
244
- /* $post_data['meta']['_wpsc_product_metadata']['notax'] = (int)(bool)$post_data['notax']; */
245
  $post_data['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$product['no_shipping'];
246
 
247
  foreach($post_data as $meta_key => $meta_value) {
@@ -263,7 +262,6 @@ GROUP BY ".WPSC_TABLE_PRODUCT_LIST.".id", ARRAY_A);
263
 
264
  $product_data = get_post($post_id);
265
  $image_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `product_id` IN ('{$product['id']}') ORDER BY `image_order` ASC", ARRAY_A);
266
- //echo "SELECT * FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `product_id` IN ('{$product['id']}') ORDER BY `image_order` ASC \n";
267
  foreach((array)$image_data as $image_row) {
268
  // Get the image path info
269
  $image_pathinfo = pathinfo($image_row['image']);
@@ -352,7 +350,6 @@ function wpsc_convert_variation_combinations() {
352
  'numberposts' => -1
353
  ) );
354
 
355
- //return false;
356
  foreach((array)$posts as $post) {
357
 
358
  $base_product_terms = array();
@@ -513,7 +510,6 @@ function wpsc_update_files() {
513
  }else{
514
  $product_post_id = (int)$wpdb->get_var("SELECT `id` FROM ".WPSC_TABLE_PRODUCT_LIST." WHERE file=".$product_file->id);
515
  $product_post_id = (int)$wpdb->get_var($wpdb->prepare( "SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product_post_id ));
516
- // exit('Post ID'.$product_post_id);
517
  }
518
  $variation_items = $wpdb->get_col("SELECT `id` FROM ".WPSC_TABLE_VARIATION_PROPERTIES." WHERE `file` = '{$product_file->id}'");
519
 
241
  if(isset($post_data['meta'])) {
242
  $post_data['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
243
  }
 
244
  $post_data['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$product['no_shipping'];
245
 
246
  foreach($post_data as $meta_key => $meta_value) {
262
 
263
  $product_data = get_post($post_id);
264
  $image_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `product_id` IN ('{$product['id']}') ORDER BY `image_order` ASC", ARRAY_A);
 
265
  foreach((array)$image_data as $image_row) {
266
  // Get the image path info
267
  $image_pathinfo = pathinfo($image_row['image']);
350
  'numberposts' => -1
351
  ) );
352
 
 
353
  foreach((array)$posts as $post) {
354
 
355
  $base_product_terms = array();
510
  }else{
511
  $product_post_id = (int)$wpdb->get_var("SELECT `id` FROM ".WPSC_TABLE_PRODUCT_LIST." WHERE file=".$product_file->id);
512
  $product_post_id = (int)$wpdb->get_var($wpdb->prepare( "SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product_post_id ));
 
513
  }
514
  $variation_items = $wpdb->get_col("SELECT `id` FROM ".WPSC_TABLE_VARIATION_PROPERTIES." WHERE `file` = '{$product_file->id}'");
515
 
wpsc-core/images/icon32.png CHANGED
Binary file
wpsc-core/js/tinymce3/editor_plugin.js CHANGED
@@ -92,9 +92,6 @@
92
  ed.execCommand('mceInsertContent', 0, pb);
93
  });
94
 
95
- // Register buttons
96
- //ed.addButton('subscribe2', {title : 'Insert Products Page Token', image : url + '/productspage.gif', cmd : cls});
97
-
98
  ed.onInit.add(function() {
99
  //ed.dom.loadCSS(url + "/css/content.css");
100
  if (ed.theme.onResolveName) {
@@ -144,7 +141,7 @@
144
 
145
  tinymce.create('tinymce.plugins.transactionresultpage_image', {
146
  init : function(ed, url) {
147
- var pb = '<img src="' + url + '/productspage.gif" class="transactionresultpage_image mceItemNoResize" />', cls = 'transactionresultpage_image', sep = ed.getParam('transactionresultpage_image', '[transactionresults]'), pbRE;
148
 
149
  pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
150
 
@@ -153,8 +150,6 @@
153
  ed.execCommand('mceInsertContent', 0, pb);
154
  });
155
 
156
- // Register buttons
157
- //ed.addButton('subscribe2', {title : 'Insert Products Page Token', image : url + '/productspage.gif', cmd : cls});
158
 
159
  ed.onInit.add(function() {
160
  //ed.dom.loadCSS(url + "/css/content.css");
@@ -205,7 +200,7 @@
205
 
206
  tinymce.create('tinymce.plugins.checkoutpage_image', {
207
  init : function(ed, url) {
208
- var pb = '<img src="' + url + '/productspage.gif" class="checkoutpage_image mceItemNoResize" />', cls = 'checkoutpage_image', sep = ed.getParam('checkoutpage_image', '[shoppingcart]'), pbRE;
209
 
210
  pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
211
 
@@ -214,9 +209,6 @@
214
  ed.execCommand('mceInsertContent', 0, pb);
215
  });
216
 
217
- // Register buttons
218
- //ed.addButton('subscribe2', {title : 'Insert Products Page Token', image : url + '/productspage.gif', cmd : cls});
219
-
220
  ed.onInit.add(function() {
221
  //ed.dom.loadCSS(url + "/css/content.css");
222
  if (ed.theme.onResolveName) {
@@ -266,7 +258,7 @@
266
 
267
  tinymce.create('tinymce.plugins.userlogpage_image', {
268
  init : function(ed, url) {
269
- var pb = '<img src="' + url + '/productspage.gif" class="userlogpage_image mceItemNoResize" />', cls = 'userlogpage_image', sep = ed.getParam('userlogpage_image', '[userlog]'), pbRE;
270
 
271
  pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
272
 
@@ -275,9 +267,6 @@
275
  ed.execCommand('mceInsertContent', 0, pb);
276
  });
277
 
278
- // Register buttons
279
- //ed.addButton('subscribe2', {title : 'Insert Products Page Token', image : url + '/productspage.gif', cmd : cls});
280
-
281
  ed.onInit.add(function() {
282
  //ed.dom.loadCSS(url + "/css/content.css");
283
  if (ed.theme.onResolveName) {
92
  ed.execCommand('mceInsertContent', 0, pb);
93
  });
94
 
 
 
 
95
  ed.onInit.add(function() {
96
  //ed.dom.loadCSS(url + "/css/content.css");
97
  if (ed.theme.onResolveName) {
141
 
142
  tinymce.create('tinymce.plugins.transactionresultpage_image', {
143
  init : function(ed, url) {
144
+ var pb = '<img src="' + url + '/productspage.jpg" class="transactionresultpage_image mceItemNoResize" />', cls = 'transactionresultpage_image', sep = ed.getParam('transactionresultpage_image', '[transactionresults]'), pbRE;
145
 
146
  pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
147
 
150
  ed.execCommand('mceInsertContent', 0, pb);
151
  });
152
 
 
 
153
 
154
  ed.onInit.add(function() {
155
  //ed.dom.loadCSS(url + "/css/content.css");
200
 
201
  tinymce.create('tinymce.plugins.checkoutpage_image', {
202
  init : function(ed, url) {
203
+ var pb = '<img src="' + url + '/productspage.jpg" class="checkoutpage_image mceItemNoResize" />', cls = 'checkoutpage_image', sep = ed.getParam('checkoutpage_image', '[shoppingcart]'), pbRE;
204
 
205
  pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
206
 
209
  ed.execCommand('mceInsertContent', 0, pb);
210
  });
211
 
 
 
 
212
  ed.onInit.add(function() {
213
  //ed.dom.loadCSS(url + "/css/content.css");
214
  if (ed.theme.onResolveName) {
258
 
259
  tinymce.create('tinymce.plugins.userlogpage_image', {
260
  init : function(ed, url) {
261
+ var pb = '<img src="' + url + '/productspage.jpg" class="userlogpage_image mceItemNoResize" />', cls = 'userlogpage_image', sep = ed.getParam('userlogpage_image', '[userlog]'), pbRE;
262
 
263
  pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
264
 
267
  ed.execCommand('mceInsertContent', 0, pb);
268
  });
269
 
 
 
 
270
  ed.onInit.add(function() {
271
  //ed.dom.loadCSS(url + "/css/content.css");
272
  if (ed.theme.onResolveName) {
wpsc-core/js/user.js CHANGED
@@ -40,75 +40,25 @@ var getresults=function(results) {
40
 
41
  function submitform(frm, show_notification)
42
  {
43
- if(show_notification != false)
44
- {
45
- show_notification = true;
46
- }
47
- //alert(ajax.serialize(frm));
48
  ajax.post("index.php?ajax=true&user=true",getresults,ajax.serialize(frm));
49
- if(document.getElementById('loadingimage') != null)
50
- {
51
  document.getElementById('loadingimage').src = WPSC_CORE_IMAGES_URL + '/indicator.gif';
52
  document.getElementById('loadingindicator').style.visibility = 'visible';
53
- }
54
- else if(document.getElementById('alt_loadingimage') != null)
55
- {
56
  document.getElementById('alt_loadingimage').src = WPSC_CORE_IMAGES_URL + '/indicator.gif';
57
  document.getElementById('alt_loadingindicator').style.visibility = 'visible';
58
  }
59
- if((show_notification == true) && (document.getElementById('fancy_notification') != null))
60
- {
61
- var options = {
62
- margin: 1 ,
63
- border: 1 ,
64
- padding: 1 ,
65
- scroll: 1
66
- };
67
-
68
- form_button_id = frm.id + "_submit_button";
69
- //alert(form_button_id);
70
-
71
- var container_offset = {};
72
- new_container_offset = jQuery('#products_page_container').offset(options, container_offset);
73
-
74
- if(container_offset['left'] == null) {
75
- container_offset['left'] = new_container_offset.left;
76
- container_offset['top'] = new_container_offset.top;
77
- }
78
-
79
-
80
- var button_offset = {};
81
- new_button_offset = jQuery('#'+form_button_id).offset(options, button_offset)
82
-
83
-
84
- if(button_offset['left'] == null) {
85
- button_offset['left'] = new_button_offset.left;
86
- button_offset['top'] = new_button_offset.top;
87
- }
88
-
89
-
90
- jQuery('#fancy_notification').css("left", (button_offset['left'] - container_offset['left'] + 10) + 'px');
91
- jQuery('#fancy_notification').css("top", ((button_offset['top'] - container_offset['top']) -60) + 'px');
92
-
93
-
94
-
95
- jQuery('#fancy_notification').css("display", 'block');
96
- jQuery('#loading_animation').css("display", 'block');
97
- jQuery('#fancy_notification_content').css("display", 'none');
98
- }
99
  return false;
100
  }
101
 
102
 
103
  function prodgroupswitch(state)
104
  {
105
- if(state == 'brands')
106
- {
107
  jQuery('.categorydisplay').css("display", 'none');
108
  jQuery('.branddisplay').css("display", 'block');
109
- }
110
- else if(state == 'categories')
111
- {
112
  jQuery('.categorydisplay').css("display", 'block');
113
  jQuery('.branddisplay').css("display", 'none');
114
  }
40
 
41
  function submitform(frm, show_notification)
42
  {
 
 
 
 
 
43
  ajax.post("index.php?ajax=true&user=true",getresults,ajax.serialize(frm));
44
+ if(document.getElementById('loadingimage') != null) {
 
45
  document.getElementById('loadingimage').src = WPSC_CORE_IMAGES_URL + '/indicator.gif';
46
  document.getElementById('loadingindicator').style.visibility = 'visible';
47
+ }else if(document.getElementById('alt_loadingimage') != null){
 
 
48
  document.getElementById('alt_loadingimage').src = WPSC_CORE_IMAGES_URL + '/indicator.gif';
49
  document.getElementById('alt_loadingindicator').style.visibility = 'visible';
50
  }
51
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  return false;
53
  }
54
 
55
 
56
  function prodgroupswitch(state)
57
  {
58
+ if(state == 'brands'){
 
59
  jQuery('.categorydisplay').css("display", 'none');
60
  jQuery('.branddisplay').css("display", 'block');
61
+ }else if(state == 'categories'){
 
 
62
  jQuery('.categorydisplay').css("display", 'block');
63
  jQuery('.branddisplay').css("display", 'none');
64
  }
wpsc-core/js/wp-e-commerce.js CHANGED
@@ -256,10 +256,8 @@ function wpsc_fancy_notification(parent_form){
256
  };
257
 
258
  form_button_id = jQuery(parent_form).attr('id') + "_submit_button";
259
- //console.log(form_button_id);
260
- //return;
261
  var container_offset = {};
262
- new_container_offset = jQuery('#products_page_container').offset(options, container_offset);
263
 
264
  if(container_offset['left'] == null) {
265
  container_offset['left'] = new_container_offset.left;
@@ -267,15 +265,13 @@ function wpsc_fancy_notification(parent_form){
267
  }
268
 
269
  var button_offset = {};
270
- new_button_offset = jQuery('#'+form_button_id).offset(options, button_offset)
271
 
272
- if(button_offset['left'] == null) {
273
- button_offset['left'] = new_button_offset.left;
274
- button_offset['top'] = new_button_offset.top;
275
- }
276
 
277
- jQuery('#fancy_notification').css("left", (button_offset['left'] - container_offset['left'] + 10) + 'px');
278
- jQuery('#fancy_notification').css("top", ((button_offset['top'] - container_offset['top']) -60) + 'px');
279
 
280
 
281
  jQuery('#fancy_notification').css("display", 'block');
@@ -341,7 +337,7 @@ jQuery(document).ready(function(){
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 != '')
@@ -349,7 +345,7 @@ jQuery(document).ready(function(){
349
  });
350
  });
351
 
352
- //Javascript for variations: bounce the variatio box when nothing is selected and return false for add to cart button.
353
  jQuery(document).ready(function(){
354
  jQuery('.productcol, .textcol').each(function(){
355
  jQuery('.wpsc_buy_button', this).click(function(){
256
  };
257
 
258
  form_button_id = jQuery(parent_form).attr('id') + "_submit_button";
 
 
259
  var container_offset = {};
260
+ new_container_offset = jQuery('#default_products_page_container, #products_page_container, #list_view_products_page_container, #grid_view_products_page_container, #single_product_page_container').offset();
261
 
262
  if(container_offset['left'] == null) {
263
  container_offset['left'] = new_container_offset.left;
265
  }
266
 
267
  var button_offset = {};
268
+ new_button_offset = jQuery('#'+form_button_id).offset()
269
 
270
+ button_offset['left'] = new_button_offset.left;
271
+ button_offset['top'] = new_button_offset.top;
 
 
272
 
273
+ jQuery('#fancy_notification').css("left", (button_offset['left'] - container_offset['left'] - 140) + 'px');
274
+ jQuery('#fancy_notification').css("top", ((button_offset['top'] - container_offset['top']) + 40) + 'px');
275
 
276
 
277
  jQuery('#fancy_notification').css("display", 'block');
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(/<span class="?asterix"?>\*<\/span>/i,'');
341
  }
342
  jQuery(this).inlineFieldLabel({label:jQuery.trim(value)});
343
  if(real_value != '')
345
  });
346
  });
347
 
348
+ //Javascript for variations: bounce the variation box when nothing is selected and return false for add to cart button.
349
  jQuery(document).ready(function(){
350
  jQuery('.productcol, .textcol').each(function(){
351
  jQuery('.wpsc_buy_button', this).click(function(){
wpsc-core/wpsc-deprecated.php CHANGED
@@ -29,7 +29,6 @@ function wpsc_merchants_modules_deprecated($nzshpcrt_gateways){
29
 
30
  $nzshpcrt_gateways = apply_filters( 'wpsc_gateway_modules', $nzshpcrt_gateways );
31
  return $nzshpcrt_gateways;
32
- // return apply_filters('wpsc_gateway_modules', $nzshpcrt_gateways);
33
  }
34
  add_filter('wpsc_merchants_modules','wpsc_merchants_modules_deprecated',1);
35
 
29
 
30
  $nzshpcrt_gateways = apply_filters( 'wpsc_gateway_modules', $nzshpcrt_gateways );
31
  return $nzshpcrt_gateways;
 
32
  }
33
  add_filter('wpsc_merchants_modules','wpsc_merchants_modules_deprecated',1);
34
 
wpsc-core/wpsc-functions.php CHANGED
@@ -424,10 +424,6 @@ function wpsc_taxonomy_rewrite_rules( $rewrite_rules ) {
424
  }
425
  }
426
 
427
- //$new_rewrite_rules['products/.+?/[^/]+/attachment/([^/]+)/?$'] = 'index.php?attachment=$1';
428
- //$new_rewrite_rules['products/(.+?)/([^/]+)/comment-page-([0-9]{1,})/?$'] = 'index.php??post_type=wpsc-product&products=$1&name=$2&cpage=$3';
429
- //$new_rewrite_rules['products/.+?/([^/]+)/page/?([0-9]{1,})/?$'] = 'index.php?post_type=wpsc-product&products=$matches[1]&paged=$matches[2]';
430
- //$new_rewrite_rules['(products/checkout)(/[0-9]+)?/?$'] = 'index.php?pagename=$1&page=$2';
431
  $new_rewrite_rules[$products_page . '/(.+?)/product/([^/]+)/comment-page-([0-9]{1,})/?$'] = 'index.php?post_type=wpsc-product&products=$matches[1]&name=$matches[2]&cpage=$matches[3]';
432
  $new_rewrite_rules[$products_page . '/(.+?)/product/([^/]+)/?$'] = 'index.php?post_type=wpsc-product&products=$matches[1]&name=$matches[2]';
433
  $new_rewrite_rules[$products_page . '/(.+?)/([^/]+)/comment-page-([0-9]{1,})/?$'] = 'index.php?post_type=wpsc-product&products=$matches[1]&wpsc_item=$matches[2]&cpage=$matches[3]';
@@ -444,7 +440,6 @@ function wpsc_taxonomy_rewrite_rules( $rewrite_rules ) {
444
  $rebuilt_rewrite_rules[$rewrite_key] = $rewrite_query;
445
  }
446
 
447
- //echo "<pre>".print_r($new_rewrite_rules, true)."</pre>";
448
  return $rebuilt_rewrite_rules;
449
  }
450
 
@@ -479,7 +474,6 @@ add_filter( 'query_vars', 'wpsc_query_vars' );
479
  */
480
  function wpsc_split_the_query( $query ) {
481
  global $wpsc_page_titles, $wpsc_query, $wpsc_query_vars;
482
- //exit('Page Titles: <pre>'.print_r($wpsc_page_titles,true).'</pre>');
483
  // These values are to be dynamically defined
484
  $products_page = $wpsc_page_titles['products'];
485
  $checkout_page = $wpsc_page_titles['checkout'];
@@ -518,8 +512,6 @@ function wpsc_split_the_query( $query ) {
518
  $query->is_tax = false;
519
  $query->is_archive = false;
520
  $query->is_single = false;
521
- //$post = get_post($post_id);
522
- //$query->get_posts();
523
 
524
  if ( ($wpsc_query_vars == null ) ) {
525
  unset( $wpsc_query_data['pagename'] );
@@ -694,7 +686,6 @@ class wpsc_products_by_category {
694
  add_filter( 'posts_orderby', array( &$this, 'order_by_sql' ) );
695
  add_filter( 'posts_groupby', array( &$this, 'group_by_sql' ) );
696
  }
697
- //add_filter('posts_request', array(&$this, 'request_sql'));
698
  }
699
 
700
  function join_sql( $sql ) {
@@ -753,7 +744,6 @@ class wpsc_products_by_category {
753
  function wpsc_break_canonical_redirects( $redirect_url, $requested_url ) {
754
  global $wp_query;
755
 
756
- //exit("<pre>".print_r($wp_query,true)."</pre>");
757
  if ( ( isset( $wp_query->query_vars['products'] ) && ($wp_query->query_vars['products'] != '') ) || ( isset( $wp_query->query_vars['products'] ) && $wp_query->query_vars['products'] != 'wpsc_item') )
758
  return false;
759
 
@@ -852,7 +842,6 @@ function wpsc_product_link( $permalink, $post, $leavename ) {
852
  $product_categories[0] = '';
853
 
854
  $product_category = $product_categories[0];
855
- //if(!isset($product_category->slug)) $product_category->slug="";
856
 
857
  if ( !is_object( $product_category ) )
858
  $product_category = new stdClass();
@@ -865,7 +854,6 @@ function wpsc_product_link( $permalink, $post, $leavename ) {
865
  $term_url = get_term_link( $category_slug, 'wpsc_product_category' );
866
  }
867
 
868
- //echo "'><pre>_".print_r($product_categories, true)."_</pre>";
869
  $post_name = $post->post_name;
870
  if ( in_array( $post_name, $product_category_slugs ) )
871
  $post_name = "product/{$post_name}";
@@ -923,14 +911,10 @@ function wpsc_products_template_fallback() {
923
  return wpsc_template_fallback( 'products' );
924
  }
925
 
926
- //add_filter("products_template", 'wpsc_products_template_fallback');
927
-
928
  function wpsc_checkout_template_fallback() {
929
  return wpsc_template_fallback( 'checkout' );
930
  }
931
 
932
- //add_filter("checkout_template", 'wpsc_checkout_template_fallback');
933
-
934
  /**
935
  * wpsc_get_page_post_names function.
936
  * Seems that using just one SQL query and then processing the results is probably going to be around as efficient as just doing three separate queries
@@ -969,8 +953,6 @@ function wpsc_template_loader() {
969
  }
970
  }
971
 
972
- // add_action('template_redirect','wpsc_template_loader');
973
-
974
  /**
975
  * select_wpsc_theme_functions function, provides a place to override the e-commece theme path
976
  * add to switch "theme's functions file
424
  }
425
  }
426
 
 
 
 
 
427
  $new_rewrite_rules[$products_page . '/(.+?)/product/([^/]+)/comment-page-([0-9]{1,})/?$'] = 'index.php?post_type=wpsc-product&products=$matches[1]&name=$matches[2]&cpage=$matches[3]';
428
  $new_rewrite_rules[$products_page . '/(.+?)/product/([^/]+)/?$'] = 'index.php?post_type=wpsc-product&products=$matches[1]&name=$matches[2]';
429
  $new_rewrite_rules[$products_page . '/(.+?)/([^/]+)/comment-page-([0-9]{1,})/?$'] = 'index.php?post_type=wpsc-product&products=$matches[1]&wpsc_item=$matches[2]&cpage=$matches[3]';
440
  $rebuilt_rewrite_rules[$rewrite_key] = $rewrite_query;
441
  }
442
 
 
443
  return $rebuilt_rewrite_rules;
444
  }
445
 
474
  */
475
  function wpsc_split_the_query( $query ) {
476
  global $wpsc_page_titles, $wpsc_query, $wpsc_query_vars;
 
477
  // These values are to be dynamically defined
478
  $products_page = $wpsc_page_titles['products'];
479
  $checkout_page = $wpsc_page_titles['checkout'];
512
  $query->is_tax = false;
513
  $query->is_archive = false;
514
  $query->is_single = false;
 
 
515
 
516
  if ( ($wpsc_query_vars == null ) ) {
517
  unset( $wpsc_query_data['pagename'] );
686
  add_filter( 'posts_orderby', array( &$this, 'order_by_sql' ) );
687
  add_filter( 'posts_groupby', array( &$this, 'group_by_sql' ) );
688
  }
 
689
  }
690
 
691
  function join_sql( $sql ) {
744
  function wpsc_break_canonical_redirects( $redirect_url, $requested_url ) {
745
  global $wp_query;
746
 
 
747
  if ( ( isset( $wp_query->query_vars['products'] ) && ($wp_query->query_vars['products'] != '') ) || ( isset( $wp_query->query_vars['products'] ) && $wp_query->query_vars['products'] != 'wpsc_item') )
748
  return false;
749
 
842
  $product_categories[0] = '';
843
 
844
  $product_category = $product_categories[0];
 
845
 
846
  if ( !is_object( $product_category ) )
847
  $product_category = new stdClass();
854
  $term_url = get_term_link( $category_slug, 'wpsc_product_category' );
855
  }
856
 
 
857
  $post_name = $post->post_name;
858
  if ( in_array( $post_name, $product_category_slugs ) )
859
  $post_name = "product/{$post_name}";
911
  return wpsc_template_fallback( 'products' );
912
  }
913
 
 
 
914
  function wpsc_checkout_template_fallback() {
915
  return wpsc_template_fallback( 'checkout' );
916
  }
917
 
 
 
918
  /**
919
  * wpsc_get_page_post_names function.
920
  * Seems that using just one SQL query and then processing the results is probably going to be around as efficient as just doing three separate queries
953
  }
954
  }
955
 
 
 
956
  /**
957
  * select_wpsc_theme_functions function, provides a place to override the e-commece theme path
958
  * add to switch "theme's functions file
wpsc-core/wpsc-includes.php CHANGED
@@ -54,7 +54,6 @@ include_once( WPSC_FILE_PATH . '/wpsc-widgets/latest_product_widget.php' );
54
  include_once( WPSC_FILE_PATH . '/wpsc-widgets/price_range_widget.php' );
55
  include_once( WPSC_FILE_PATH . '/wpsc-widgets/admin_menu_widget.php' );
56
  include_once( WPSC_FILE_PATH . '/wpsc-widgets/category_widget.php' );
57
- //include_once( WPSC_FILE_PATH . '/image_processing.php' );
58
 
59
  // Admin
60
  if ( is_admin() )
54
  include_once( WPSC_FILE_PATH . '/wpsc-widgets/price_range_widget.php' );
55
  include_once( WPSC_FILE_PATH . '/wpsc-widgets/admin_menu_widget.php' );
56
  include_once( WPSC_FILE_PATH . '/wpsc-widgets/category_widget.php' );
 
57
 
58
  // Admin
59
  if ( is_admin() )
wpsc-core/wpsc-installer.php CHANGED
@@ -47,8 +47,6 @@ function wpsc_install() {
47
  if ( !wp_get_schedule( "wpsc_daily_cron_tasks" ) )
48
  wp_schedule_event( time(), 'daily', 'wpsc_daily_cron_tasks' );
49
 
50
- //wp_get_schedule( $hook, $args )
51
-
52
  // All code to add new database tables and columns must be above here
53
  if ( (get_option( 'wpsc_version' ) < WPSC_VERSION) || (get_option( 'wpsc_version' ) == WPSC_VERSION) && (get_option( 'wpsc_minor_version' ) < WPSC_MINOR_VERSION) ) {
54
  update_option( 'wpsc_version', WPSC_VERSION );
@@ -74,8 +72,6 @@ function wpsc_install() {
74
  else
75
  add_option( 'cart_location', '1', __( 'Cart Location', 'wpsc' ), 'yes' );
76
 
77
- //add_option('show_categorybrands', '0', __('Display categories or brands or both', 'wpsc'), 'yes');
78
-
79
  add_option( 'currency_type', '156', __( 'Currency type', 'wpsc' ), 'yes' );
80
  add_option( 'currency_sign_location', '3', __( 'Currency sign location', 'wpsc' ), 'yes' );
81
 
@@ -109,13 +105,10 @@ function wpsc_install() {
109
  if ( !((get_option( 'show_categorybrands' ) > 0) && (get_option( 'show_categorybrands' ) < 3)) )
110
  update_option( 'show_categorybrands', 2 );
111
 
112
- //add_option('show_categorybrands', '0', __('Display categories or brands or both', 'wpsc'), 'yes');
113
-
114
  // PayPal options
115
  add_option( 'paypal_business', '', __( 'paypal business', 'wpsc' ), 'yes' );
116
  add_option( 'paypal_url', '', __( 'paypal url', 'wpsc' ), 'yes' );
117
  add_option( 'paypal_ipn', '1', __( 'paypal url', 'wpsc' ), 'yes' );
118
- //update_option('paypal_url', "https://www.sandbox.paypal.com/xclick");
119
 
120
 
121
  add_option( 'paypal_multiple_business', '', __( 'paypal business', 'wpsc' ), 'yes' );
@@ -156,77 +149,87 @@ function wpsc_install() {
156
  $post_date = date( "Y-m-d H:i:s" );
157
  $post_date_gmt = gmdate( "Y-m-d H:i:s" );
158
 
159
- $num = 0;
160
- $pages[$num]['name'] = 'products-page';
161
- $pages[$num]['title'] = __( 'Products Page', 'wpsc' );
162
- $pages[$num]['tag'] = '[productspage]';
163
- $pages[$num]['option'] = 'product_list_url';
164
-
165
- $num++;
166
- $pages[$num]['name'] = 'checkout';
167
- $pages[$num]['title'] = __( 'Checkout', 'wpsc' );
168
- $pages[$num]['tag'] = '[shoppingcart]';
169
- $pages[$num]['option'] = 'shopping_cart_url';
170
-
171
- // $num++;
172
- // $pages[$num]['name'] = 'enter-details';
173
- // $pages[$num]['title'] = __('Enter Your Details', 'wpsc');
174
- // $pages[$num]['tag'] = '[checkout]';
175
- // $pages[2$num]['option'] = 'checkout_url';
176
-
177
- $num++;
178
- $pages[$num]['name'] = 'transaction-results';
179
- $pages[$num]['title'] = __( 'Transaction Results', 'wpsc' );
180
- $pages[$num]['tag'] = '[transactionresults]';
181
- $pages[$num]['option'] = 'transact_url';
182
-
183
- $num++;
184
- $pages[$num]['name'] = 'your-account';
185
- $pages[$num]['title'] = __( 'Your Account', 'wpsc' );
186
- $pages[$num]['tag'] = '[userlog]';
187
- $pages[$num]['option'] = 'user_account_url';
188
-
189
  $newpages = false;
190
- $i = 0;
191
- $post_parent = 0;
192
-
193
- foreach ( $pages as $page ) {
194
- $check_page = $wpdb->get_row( "SELECT * FROM `" . $wpdb->posts . "` WHERE `post_content` LIKE '%" . $page['tag'] . "%' AND `post_type` NOT IN('revision') LIMIT 1", ARRAY_A );
195
- if ( $check_page == null ) {
196
-
197
- if ( $i == 0 )
198
- $post_parent = 0;
199
- else
200
- $post_parent = $first_id;
201
-
202
- if ( $wp_version >= 2.1 ) {
203
- $sql = "INSERT INTO " . $wpdb->posts . "
204
- (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_type)
205
- VALUES
206
- ('1', '$post_date', '$post_date_gmt', '" . $page['tag'] . "', '', '" . $page['title'] . "', '', 'publish', 'closed', 'closed', '', '" . $page['name'] . "', '', '', '$post_date', '$post_date_gmt', '$post_parent', '0', 'page')";
207
- } else {
208
- $sql = "INSERT INTO " . $wpdb->posts . "
209
- (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order)
210
- VALUES
211
- ('1', '$post_date', '$post_date_gmt', '" . $page['tag'] . "', '', '" . $page['title'] . "', '', 'static', 'closed', 'closed', '', '" . $page['name'] . "', '', '', '$post_date', '$post_date_gmt', '$post_parent', '0')";
212
- }
213
- $wpdb->query( $sql );
214
- $post_id = $wpdb->insert_id;
215
-
216
- if ( $i == 0 )
217
- $first_id = $post_id;
218
-
219
- $wpdb->query( "UPDATE $wpdb->posts SET guid = '" . get_permalink( $post_id ) . "' WHERE ID = '$post_id'" );
220
- update_option( $page['option'], get_permalink( $post_id ) );
221
-
222
- if ( $page['option'] == 'shopping_cart_url' )
223
- update_option( 'checkout_url', get_permalink( $post_id ) );
224
-
 
 
 
 
 
 
225
  $newpages = true;
226
- $i++;
227
  }
 
 
 
 
 
228
  }
229
- if ( $newpages == true ) {
 
 
230
  wp_cache_delete( 'all_page_ids', 'pages' );
231
  $wp_rewrite->flush_rules();
232
  }
@@ -362,7 +365,6 @@ function wpsc_create_upload_directories() {
362
  wp_mkdir_p( $folder );
363
  @ chmod( $folder, 0775 );
364
  }
365
- //wpsc_copy_themes_to_uploads();
366
  }
367
 
368
  function wpsc_copy_themes_to_uploads() {
@@ -401,10 +403,6 @@ function wpsc_create_or_update_tables( $debug = false ) {
401
  // Filter for adding to or altering the wpsc database template, make sure you return the array your function gets passed, else you will break updating the database tables
402
  $wpsc_database_template = apply_filters( 'wpsc_alter_database_template', $wpsc_database_template );
403
 
404
- if ( (get_option( 'wpsc_database_check' ) == $template_hash) && ($debug == false) ) {
405
- //return true;
406
- }
407
-
408
  $failure_reasons = array( );
409
  $upgrade_failed = false;
410
  foreach ( (array)$wpsc_database_template as $table_name => $table_data ) {
@@ -440,12 +438,10 @@ function wpsc_create_or_update_tables( $debug = false ) {
440
  if ( isset( $table_data['actions']['after']['all'] ) && is_callable( $table_data['actions']['after']['all'] ) ) {
441
  $table_data['actions']['after']['all']();
442
  }
443
- //echo "<pre>$constructed_sql</pre>";
444
  } else {
445
  // check to see if the new table name is in use
446
  if ( !$wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) && (isset( $table_data['previous_names'] ) && $wpdb->get_var( "SHOW TABLES LIKE '{$table_data['previous_names']}'" )) ) {
447
  $wpdb->query( "ALTER TABLE `{$table_data['previous_names']}` RENAME TO `{$table_name}`;" );
448
- //$wpdb->query("RENAME TABLE `{$table_data['previous_names']}` TO `{$table_name}`;");
449
  $failure_reasons[] = $wpdb->last_error;
450
  }
451
 
@@ -509,7 +505,6 @@ function wpsc_create_or_update_tables( $debug = false ) {
509
  $failure_reasons[] = $wpdb->last_error;
510
  }
511
  // run updating functions to do more complex work with default values and the like
512
- //exit($missing_or_extra_table_column);
513
  if ( is_callable( $table_data['actions']['after'][$missing_or_extra_table_column] ) ) {
514
  $table_data['actions']['after'][$missing_or_extra_table_column]( $missing_or_extra_table_column );
515
  }
@@ -553,7 +548,6 @@ function wpsc_create_or_update_tables( $debug = false ) {
553
  } else {
554
  return false;
555
  }
556
- //echo "<pre>".print_r($missing_or_extra_table_indexes,true)."</pre>";
557
  }
558
 
559
  /**
@@ -583,7 +577,6 @@ function wpsc_add_currency_list() {
583
  function wpsc_add_region_list() {
584
  global $wpdb;
585
  $add_regions = $wpdb->get_var( "SELECT COUNT(*) AS `count` FROM `" . WPSC_TABLE_REGION_TAX . "`" );
586
- // exit($add_regions);
587
  if ( $add_regions < 1 ) {
588
  $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Alberta', '', '0')" );
589
  $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'British Columbia', '', '0')" );
@@ -695,7 +688,7 @@ function wpsc_add_checkout_fields() {
695
  ( '" . __( 'State', 'wpsc' ) . "', 'text', '0', '0', '', '1', 15,'shippingstate'),
696
  ( '" . __( 'Country', 'wpsc' ) . "', 'delivery_country', '0', '0', '', '1', 16,'shippingcountry'),
697
  ( '" . __( 'Postal Code', 'wpsc' ) . "', 'text', '0', '0', '', '1', 17,'shippingpostcode');";
698
- // exit($sql);
699
  $wpdb->query( $sql );
700
  update_option( 'country_form_field', $country_form_id[0]['id'] );
701
  update_option( 'email_form_field', $email_form_id[0]['id'] );
47
  if ( !wp_get_schedule( "wpsc_daily_cron_tasks" ) )
48
  wp_schedule_event( time(), 'daily', 'wpsc_daily_cron_tasks' );
49
 
 
 
50
  // All code to add new database tables and columns must be above here
51
  if ( (get_option( 'wpsc_version' ) < WPSC_VERSION) || (get_option( 'wpsc_version' ) == WPSC_VERSION) && (get_option( 'wpsc_minor_version' ) < WPSC_MINOR_VERSION) ) {
52
  update_option( 'wpsc_version', WPSC_VERSION );
72
  else
73
  add_option( 'cart_location', '1', __( 'Cart Location', 'wpsc' ), 'yes' );
74
 
 
 
75
  add_option( 'currency_type', '156', __( 'Currency type', 'wpsc' ), 'yes' );
76
  add_option( 'currency_sign_location', '3', __( 'Currency sign location', 'wpsc' ), 'yes' );
77
 
105
  if ( !((get_option( 'show_categorybrands' ) > 0) && (get_option( 'show_categorybrands' ) < 3)) )
106
  update_option( 'show_categorybrands', 2 );
107
 
 
 
108
  // PayPal options
109
  add_option( 'paypal_business', '', __( 'paypal business', 'wpsc' ), 'yes' );
110
  add_option( 'paypal_url', '', __( 'paypal url', 'wpsc' ), 'yes' );
111
  add_option( 'paypal_ipn', '1', __( 'paypal url', 'wpsc' ), 'yes' );
 
112
 
113
 
114
  add_option( 'paypal_multiple_business', '', __( 'paypal business', 'wpsc' ), 'yes' );
149
  $post_date = date( "Y-m-d H:i:s" );
150
  $post_date_gmt = gmdate( "Y-m-d H:i:s" );
151
 
152
+ $pages = array(
153
+ 'products-page' => array(
154
+ 'name' => 'products-page',
155
+ 'title' => __( 'Products Page', 'wpsc' ),
156
+ 'tag' => '[productspage]',
157
+ 'option' => 'product_list_url'
158
+ ),
159
+ 'checkout' => array(
160
+ 'name' => 'checkout',
161
+ 'title' => __( 'Checkout', 'wpsc' ),
162
+ 'tag' => '[shoppingcart]',
163
+ 'option' => 'shopping_cart_url'
164
+ ),
165
+ 'transaction-results' => array(
166
+ 'name' => 'transaction-results',
167
+ 'title' => __( 'Transaction Results', 'wpsc' ),
168
+ 'tag' => '[transactionresults]',
169
+ 'option' => 'transact_url'
170
+ ),
171
+ 'your-account' => array(
172
+ 'name' => 'your-account',
173
+ 'title' => __( 'Your Account', 'wpsc' ),
174
+ 'tag' => '[userlog]',
175
+ 'option' => 'user_account_url'
176
+ )
177
+ );
178
+
179
+ //indicator. if we will create any new pages we need to flush.. :)
 
 
180
  $newpages = false;
181
+
182
+ //get products page id. if there's no products page then create one
183
+ $products_page_id = $wpdb->get_var("SELECT id FROM `" . $wpdb->posts . "` WHERE `post_content` LIKE '%" . $pages['products-page']['tag'] . "%' AND `post_type` != 'revision'");
184
+ if( empty($products_page_id) ){
185
+ $products_page_id = wp_insert_post( array(
186
+ 'post_title' => $pages['products-page']['title'],
187
+ 'post_type' => 'page',
188
+ 'post_name' => $pages['products-page']['name'],
189
+ 'comment_status'=> 'closed',
190
+ 'ping_status' => 'closed',
191
+ 'post_content' => $pages['products-page']['tag'],
192
+ 'post_status' => 'publish',
193
+ 'post_author' => 1,
194
+ 'menu_order' => 0
195
+ ));
196
+ $newpages = true;
197
+ }
198
+ update_option( $pages['products-page']['option'], get_permalink( $products_page_id ) );
199
+ //done. products page created. no we can unset products page data and create all other pages.
200
+
201
+ //unset products page
202
+ unset($pages['products-page']);
203
+
204
+ //create other pages
205
+ foreach( (array)$pages as $page ){
206
+ //check if page exists and get it's ID
207
+ $page_id = $wpdb->get_var("SELECT id FROM `" . $wpdb->posts . "` WHERE `post_content` LIKE '%" . $page['tag'] . "%' AND `post_type` != 'revision'");
208
+ //if there's no page - create
209
+ if( empty($page_id) ){
210
+ $page_id = wp_insert_post( array(
211
+ 'post_title' => $page['title'],
212
+ 'post_type' => 'page',
213
+ 'post_name' => $page['name'],
214
+ 'comment_status'=> 'closed',
215
+ 'ping_status' => 'closed',
216
+ 'post_content' => $page['tag'],
217
+ 'post_status' => 'publish',
218
+ 'post_author' => 1,
219
+ 'menu_order' => 0,
220
+ 'post_parent' => $products_page_id
221
+ ));
222
  $newpages = true;
 
223
  }
224
+ //update option
225
+ update_option( $page['option'], get_permalink( $page_id ) );
226
+ //also if this is shopping_cart, then update checkout url option
227
+ if ( $page['option'] == 'shopping_cart_url' )
228
+ update_option( 'checkout_url', get_permalink( $page_id ) );
229
  }
230
+
231
+ //if we have created any new pages, then flush... do we need to do this? probably should be removed
232
+ if ( $newpages ) {
233
  wp_cache_delete( 'all_page_ids', 'pages' );
234
  $wp_rewrite->flush_rules();
235
  }
365
  wp_mkdir_p( $folder );
366
  @ chmod( $folder, 0775 );
367
  }
 
368
  }
369
 
370
  function wpsc_copy_themes_to_uploads() {
403
  // Filter for adding to or altering the wpsc database template, make sure you return the array your function gets passed, else you will break updating the database tables
404
  $wpsc_database_template = apply_filters( 'wpsc_alter_database_template', $wpsc_database_template );
405
 
 
 
 
 
406
  $failure_reasons = array( );
407
  $upgrade_failed = false;
408
  foreach ( (array)$wpsc_database_template as $table_name => $table_data ) {
438
  if ( isset( $table_data['actions']['after']['all'] ) && is_callable( $table_data['actions']['after']['all'] ) ) {
439
  $table_data['actions']['after']['all']();
440
  }
 
441
  } else {
442
  // check to see if the new table name is in use
443
  if ( !$wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) && (isset( $table_data['previous_names'] ) && $wpdb->get_var( "SHOW TABLES LIKE '{$table_data['previous_names']}'" )) ) {
444
  $wpdb->query( "ALTER TABLE `{$table_data['previous_names']}` RENAME TO `{$table_name}`;" );
 
445
  $failure_reasons[] = $wpdb->last_error;
446
  }
447
 
505
  $failure_reasons[] = $wpdb->last_error;
506
  }
507
  // run updating functions to do more complex work with default values and the like
 
508
  if ( is_callable( $table_data['actions']['after'][$missing_or_extra_table_column] ) ) {
509
  $table_data['actions']['after'][$missing_or_extra_table_column]( $missing_or_extra_table_column );
510
  }
548
  } else {
549
  return false;
550
  }
 
551
  }
552
 
553
  /**
577
  function wpsc_add_region_list() {
578
  global $wpdb;
579
  $add_regions = $wpdb->get_var( "SELECT COUNT(*) AS `count` FROM `" . WPSC_TABLE_REGION_TAX . "`" );
 
580
  if ( $add_regions < 1 ) {
581
  $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'Alberta', '', '0')" );
582
  $wpdb->query( "INSERT INTO `" . WPSC_TABLE_REGION_TAX . "` ( `country_id` , `name` ,`code`, `tax` ) VALUES ( '100', 'British Columbia', '', '0')" );
688
  ( '" . __( 'State', 'wpsc' ) . "', 'text', '0', '0', '', '1', 15,'shippingstate'),
689
  ( '" . __( 'Country', 'wpsc' ) . "', 'delivery_country', '0', '0', '', '1', 16,'shippingcountry'),
690
  ( '" . __( 'Postal Code', 'wpsc' ) . "', 'text', '0', '0', '', '1', 17,'shippingpostcode');";
691
+
692
  $wpdb->query( $sql );
693
  update_option( 'country_form_field', $country_form_id[0]['id'] );
694
  update_option( 'email_form_field', $email_form_id[0]['id'] );
wpsc-includes/ajax.functions.php CHANGED
@@ -11,7 +11,6 @@
11
  function wpsc_special_widget() {
12
  global $wpdb;
13
  wpsc_add_to_cart();
14
- //exit();
15
  }
16
 
17
  if ( isset( $_REQUEST['wpsc_ajax_action'] ) && ($_REQUEST['wpsc_ajax_action'] == 'special_widget' || $_REQUEST['wpsc_ajax_action'] == 'donations_widget') ) {
@@ -69,7 +68,6 @@ function wpsc_add_to_cart() {
69
  if ( ((float)$_POST['donation_price'] > 0 ) ) {
70
  $provided_parameters['provided_price'] = (float)$_POST['donation_price'];
71
  }
72
- //exit();
73
  $parameters = array_merge( $default_parameters, (array)$provided_parameters );
74
 
75
  $state = $wpsc_cart->set_item( $product_id, $parameters );
@@ -310,7 +308,6 @@ if ( isset( $_REQUEST['wpsc_update_quantity'] ) && ($_REQUEST['wpsc_update_quant
310
 
311
  function wpsc_update_product_rating() {
312
  global $wpdb;
313
- //exit("<pre>".print_r($_POST, true)."</pre>");
314
  $nowtime = time();
315
  $product_id = absint( $_POST['product_id'] );
316
  $ip_number = $wpdb->escape( $_SERVER['REMOTE_ADDR'] );
@@ -397,7 +394,6 @@ function wpsc_update_product_price() {
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
 
@@ -469,12 +465,9 @@ function wpsc_update_location() {
469
  $wpsc_cart->update_location();
470
  $wpsc_cart->get_shipping_method();
471
  $wpsc_cart->get_shipping_option();
472
- //echo $wpsc_cart->shipping_method;
473
  if ( $wpsc_cart->selected_shipping_method != '' ) {
474
  $wpsc_cart->update_shipping( $wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option );
475
  }
476
- //echo "<pre>".print_r($wpsc_cart, true)."</pre>";
477
- //exit();
478
 
479
  if ( isset( $_GET['ajax'] ) && $_GET['ajax'] == 'true' ) {
480
  exit();
@@ -547,7 +540,7 @@ function wpsc_submit_checkout() {
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' );
552
  $is_valid = false;
553
  }
@@ -765,15 +758,11 @@ function wpsc_change_tax() {
765
 
766
  ob_end_clean();
767
 
768
- //exit("/*<pre>".print_r($wpsc_cart,true)."</pre>*/");
769
  $output = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $output ) );
770
  if ( get_option( 'lock_tax' ) == 1 ) {
771
- //echo "jQuery('#region').val(".$_SESSION['wpsc_delivery_region']."); \n";
772
  echo "jQuery('#current_country').val('" . $_SESSION['wpsc_delivery_country'] . "'); \n";
773
  if ( $_SESSION['wpsc_delivery_country'] == 'US' && get_option( 'lock_tax' ) == 1 ) {
774
- //exit('<pre>'.print_r($_SESSION, true).'</pre>');
775
  $output = wpsc_shipping_region_list( $_SESSION['wpsc_delivery_country'], $_SESSION['wpsc_delivery_region'] );
776
- // echo 'jQuery("#change_country").append(\''.$output.'\');\n\r';
777
  $output = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $output ) );
778
  echo "jQuery('#region').remove();\n\r";
779
  echo "jQuery('#change_country').append(\"" . $output . "\");\n\r";
@@ -865,7 +854,6 @@ function wpsc_change_tax() {
865
  }
866
  echo "jQuery('#checkout_tax').html(\"<span class='pricedisplay'>" . wpsc_cart_tax() . "</span>\");\n\r";
867
  echo "jQuery('#checkout_total').html(\"<span class='pricedisplay'>{$total}</span><input id='shopping_cart_total_price' type='hidden' value='{$total}' />\");\n\r";
868
- //echo "\n\r/*\n\r{$wpsc_cart->tax_percentage}\n\r*/\n\r";
869
  exit();
870
  }
871
 
@@ -927,7 +915,6 @@ function wpsc_scale_image() {
927
  $generate_thumbnail = false;
928
  }
929
  }
930
- //header("Location: ".$cache_url.$cache_filename.$extension);
931
  }
932
 
933
  if ( $generate_thumbnail == true ) {
@@ -938,9 +925,6 @@ function wpsc_scale_image() {
938
  $intermediate_image_data = image_get_intermediate_size( $attachment_id, $intermediate_size );
939
  }
940
 
941
- //
942
- //echo "<pre>".print_r((int)$generate_thumbnail,true)."</pre>";
943
- //echo "<pre>".print_r($intermediate_image_data,true)."</pre>";
944
  /// if we are serving the page using SSL, we have to use for the image too.
945
  if ( is_ssl ( ) ) {
946
  $output_url = str_replace( "http://", "https://", $intermediate_image_data['url'] );
@@ -983,8 +967,7 @@ function wpsc_download_file() {
983
  }
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{
@@ -1038,13 +1021,10 @@ function wpsc_download_file() {
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' );
11
  function wpsc_special_widget() {
12
  global $wpdb;
13
  wpsc_add_to_cart();
 
14
  }
15
 
16
  if ( isset( $_REQUEST['wpsc_ajax_action'] ) && ($_REQUEST['wpsc_ajax_action'] == 'special_widget' || $_REQUEST['wpsc_ajax_action'] == 'donations_widget') ) {
68
  if ( ((float)$_POST['donation_price'] > 0 ) ) {
69
  $provided_parameters['provided_price'] = (float)$_POST['donation_price'];
70
  }
 
71
  $parameters = array_merge( $default_parameters, (array)$provided_parameters );
72
 
73
  $state = $wpsc_cart->set_item( $product_id, $parameters );
308
 
309
  function wpsc_update_product_rating() {
310
  global $wpdb;
 
311
  $nowtime = time();
312
  $product_id = absint( $_POST['product_id'] );
313
  $ip_number = $wpdb->escape( $_SERVER['REMOTE_ADDR'] );
394
  $from = apply_filters('wpsc_product_variation_text',$from);
395
  }
396
  }
 
397
  do_action( 'wpsc_update_variation_product', (int)$_POST['product_id'], $variations );
398
  $pm = $_POST['pm'];
399
 
465
  $wpsc_cart->update_location();
466
  $wpsc_cart->get_shipping_method();
467
  $wpsc_cart->get_shipping_option();
 
468
  if ( $wpsc_cart->selected_shipping_method != '' ) {
469
  $wpsc_cart->update_shipping( $wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option );
470
  }
 
 
471
 
472
  if ( isset( $_GET['ajax'] ) && $_GET['ajax'] == 'true' ) {
473
  exit();
540
  $is_valid = false;
541
 
542
  if ( (get_option( 'do_not_use_shipping' ) != 1) && (in_array( 'ups', (array)$options )) && $_SESSION['wpsc_zipcode'] == '' ) {
543
+ if ( $num_items != $disregard_shipping ) {
544
  $_SESSION['categoryAndShippingCountryConflict'] = __( 'Please enter a Zipcode and click calculate to proceed' );
545
  $is_valid = false;
546
  }
758
 
759
  ob_end_clean();
760
 
 
761
  $output = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $output ) );
762
  if ( get_option( 'lock_tax' ) == 1 ) {
 
763
  echo "jQuery('#current_country').val('" . $_SESSION['wpsc_delivery_country'] . "'); \n";
764
  if ( $_SESSION['wpsc_delivery_country'] == 'US' && get_option( 'lock_tax' ) == 1 ) {
 
765
  $output = wpsc_shipping_region_list( $_SESSION['wpsc_delivery_country'], $_SESSION['wpsc_delivery_region'] );
 
766
  $output = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $output ) );
767
  echo "jQuery('#region').remove();\n\r";
768
  echo "jQuery('#change_country').append(\"" . $output . "\");\n\r";
854
  }
855
  echo "jQuery('#checkout_tax').html(\"<span class='pricedisplay'>" . wpsc_cart_tax() . "</span>\");\n\r";
856
  echo "jQuery('#checkout_total').html(\"<span class='pricedisplay'>{$total}</span><input id='shopping_cart_total_price' type='hidden' value='{$total}' />\");\n\r";
 
857
  exit();
858
  }
859
 
915
  $generate_thumbnail = false;
916
  }
917
  }
 
918
  }
919
 
920
  if ( $generate_thumbnail == true ) {
925
  $intermediate_image_data = image_get_intermediate_size( $attachment_id, $intermediate_size );
926
  }
927
 
 
 
 
928
  /// if we are serving the page using SSL, we have to use for the image too.
929
  if ( is_ssl ( ) ) {
930
  $output_url = str_replace( "http://", "https://", $intermediate_image_data['url'] );
967
  }
968
 
969
  $file_id = $download_data['fileid'];
970
+ $file_data = wpsc_get_downloadable_files($download_data['product_id']);
 
971
  if(($count =count($file_data)) >= 1){
972
  $file_data = $file_data[$count-1];
973
  }else{
1021
  if(!empty($file_name))
1022
  $file_path = WPSC_FILE_DIR . basename( $file_hash );
1023
  $file_path = WPSC_FILE_DIR . $file_data->post_name;
 
1024
  }
1025
 
1026
  if ( is_file( $file_path ) ) {
1027
+ set_time_limit(0);
 
 
1028
  header( 'Content-Type: ' . $file_data->post_mime_type );
1029
  header( 'Content-Length: ' . filesize( $file_path ) );
1030
  header( 'Content-Transfer-Encoding: binary' );
wpsc-includes/breadcrumbs.class.php CHANGED
@@ -157,7 +157,6 @@ class wpsc_breadcrumbs {
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'),
@@ -213,12 +212,8 @@ class wpsc_breadcrumbs {
213
  if ($this->current_breadcrumb + 1 < $this->breadcrumb_count) {
214
  return true;
215
  } else if ($this->current_breadcrumb + 1 == $this->breadcrumb_count && $this->breadcrumb_count > 0) {
216
- //do_action('wpsc_loop_end');
217
- // Do some cleaning up after the loop,
218
  $this->rewind_breadcrumbs();
219
  }
220
-
221
- //$this->in_the_loop = false;
222
  return false;
223
  }
224
 
157
  } else {
158
  $term_data = get_term_by('slug', 'uncategorized', 'wpsc_product_category');
159
  }
 
160
  if( $term_data != false) {
161
  $this->breadcrumbs[] = array(
162
  'name' => htmlentities( $term_data->name, ENT_QUOTES, 'UTF-8'),
212
  if ($this->current_breadcrumb + 1 < $this->breadcrumb_count) {
213
  return true;
214
  } else if ($this->current_breadcrumb + 1 == $this->breadcrumb_count && $this->breadcrumb_count > 0) {
 
 
215
  $this->rewind_breadcrumbs();
216
  }
 
 
217
  return false;
218
  }
219
 
wpsc-includes/cart.class.php CHANGED
@@ -71,7 +71,6 @@ function wpsc_cart_total($forDisplay=true) {
71
  $total = 0;
72
  }
73
  if($forDisplay){
74
- // exit('abksd'.get_option('add_plustax'));
75
  return $wpsc_cart->process_as_currency($total);
76
  }else{
77
  return $total;
@@ -165,7 +164,6 @@ function wpsc_cart_tax($forDisplay = true) {
165
  */
166
  function wpsc_cart_show_plus_postage() {
167
  global $wpsc_cart;
168
- // exit($_SESSION['wpsc_has_been_to_checkout'] ."get_option('add_plustax')".get_option('add_plustax'));
169
  if(($_SESSION['wpsc_has_been_to_checkout'] == null ) && (get_option('add_plustax') == 1)) {
170
 
171
  return true;
@@ -287,7 +285,6 @@ function wpsc_cart_item_quantity() {
287
 
288
  function wpsc_cart_item_quantity_single_prod($id) {
289
  global $wpsc_cart;
290
- //exit('<pre>'.print_r($wpsc_cart, true).'</pre>');
291
  return $wpsc_cart;
292
  }
293
  /**
@@ -296,7 +293,6 @@ function wpsc_cart_item_quantity_single_prod($id) {
296
  */
297
  function wpsc_cart_item_price($forDisplay = true) {
298
  global $wpsc_cart;
299
- /* exit('<pre>'.print_r($wpsc_cart,1).'</pre>'); */
300
  if($forDisplay){
301
  return $wpsc_cart->process_as_currency($wpsc_cart->cart_item->total_price);
302
  }else{
@@ -371,7 +367,6 @@ function wpsc_strleft($s1, $s2) {
371
  }
372
  function wpsc_google_checkout(){
373
  $currpage = wpsc_selfURL();
374
- //exit('<pre>'.print_r(get_option('custom_gateway_options'), true).'</pre>');
375
  if (array_search("google",(array)get_option('custom_gateway_options')) !== false && $currpage != get_option('shopping_cart_url')) {
376
  global $nzshpcrt_gateways;
377
  foreach($nzshpcrt_gateways as $gateway) {
@@ -458,7 +453,6 @@ function wpsc_shipping_quote_name() {
458
  */
459
  function wpsc_shipping_quote_value($numeric = false) {
460
  global $wpsc_cart;
461
- //echo 'Shipping value'.$wpsc_cart->shipping_quote['value'];
462
  if($numeric == true) {
463
  return $wpsc_cart->shipping_quote['value'];
464
  } else {
@@ -511,7 +505,6 @@ function wpsc_have_morethanone_shipping_methods_and_quotes(){
511
  global $wpsc_cart;
512
 
513
  if(count($wpsc_cart->shipping_quotes) > 1 || count($wpsc_cart->shipping_methods) > 1 || count($wpsc_cart->shipping_quotes) == $wpsc_cart->shipping_quote_count){
514
- //$wpsc_cart->update_shipping($wpsc_cart->shipping_method, $wpsc_cart->selected_shipping_option);
515
  return true;
516
  }else{
517
  return false;
@@ -531,14 +524,12 @@ function wpsc_have_shipping_quote(){
531
  }
532
  function wpsc_update_shipping_single_method(){
533
  global $wpsc_cart;
534
- //exit('<pre>'.print_r($wpsc_cart->shipping_method, true).'</pre>');
535
  if(!empty($wpsc_cart->shipping_method)) {
536
  $wpsc_cart->update_shipping($wpsc_cart->shipping_method, $wpsc_cart->selected_shipping_option);
537
  }
538
  }
539
  function wpsc_update_shipping_multiple_methods(){
540
  global $wpsc_cart;
541
- //exit('<pre>'.print_r($wpsc_cart->shipping_method, true).'</pre>'.$wpsc_cart->shipping_methods[0]);
542
  if(!empty($wpsc_cart->selected_shipping_method)) {
543
  $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
544
  }
@@ -554,7 +545,6 @@ class wpsc_cart {
554
  var $selected_region;
555
 
556
  var $selected_shipping_method = null;
557
- // var $shipping_quotes = null;
558
  var $selected_shipping_option = null;
559
 
560
  var $coupon;
@@ -602,12 +592,7 @@ class wpsc_cart {
602
  function wpsc_cart() {
603
  global $wpdb, $wpsc_shipping_modules;
604
  $coupon = 'percentage';
605
- // this is here to stop extremely bizzare errors with $wpsc_cart somehow not ending up as a global variable, yet certain code being run from it that eventually expects it to be one
606
- if(!is_object($GLOBALS['wpsc_cart'])) {
607
- // $GLOBALS['wpsc_cart'] =& $this;
608
- }
609
  $this->update_location();
610
- //$this->get_tax_rate(); // replaced with wpec_taxes use wpsc_refresh_cart_items to refresh the cart
611
  $this->wpsc_refresh_cart_items();
612
  $this->unique_id = sha1(uniqid(rand(), true));
613
 
@@ -642,8 +627,6 @@ class wpsc_cart {
642
  $this->delivery_region =& $_SESSION['wpsc_delivery_region'];
643
  $this->selected_region =& $_SESSION['wpsc_selected_region'];
644
 
645
-
646
- //$this->get_tax_rate();
647
  //adding refresh item
648
  $this->wpsc_refresh_cart_items();
649
 
@@ -690,10 +673,6 @@ class wpsc_cart {
690
  $this->shipping_method_count = count($this->shipping_methods);
691
 
692
  if((get_option('do_not_use_shipping') != 1) && (count($this->shipping_methods) > 0) ) {
693
- if(array_search($this->selected_shipping_method, (array)$this->shipping_methods) === false) {
694
- //unset($this->selected_shipping_method);
695
- }
696
-
697
  $shipping_quotes = null;
698
  if($this->selected_shipping_method != null) {
699
  // use the selected shipping module
@@ -715,8 +694,6 @@ class wpsc_cart {
715
 
716
  }
717
  }
718
-
719
- //echo('<pre>'.print_r($custom_shipping,true).'</pre>');
720
  }
721
 
722
  /**
@@ -751,9 +728,8 @@ class wpsc_cart {
751
  global $wpdb, $wpsc_shipping_modules;
752
  $this->selected_shipping_method = $method;
753
 
754
- $this->shipping_quotes = $wpsc_shipping_modules[$method]->getQuote();
755
 
756
- //exit('<pre>'.print_r($this->shipping_quotes,true).'</pre> quotes');
757
  $this->selected_shipping_option = $option;
758
 
759
  foreach($this->cart_items as $key => $cart_item) {
@@ -851,7 +827,6 @@ class wpsc_cart {
851
 
852
  $add_item = true;
853
  $edit_item = false;
854
- //exit('hello<pre>'.print_r($new_cart_item,true).'</pre>');
855
  if((count($this->cart_items) > 0) && ($new_cart_item->is_donation != 1)) {
856
  //loop through each cart item
857
  foreach($this->cart_items as $key => $cart_item) {
@@ -878,11 +853,8 @@ class wpsc_cart {
878
  if($add_item === true) {
879
  $this->cart_items[] = $new_cart_item;
880
  }
881
- } else {
882
- //$errors[] = new WP_Error('no_stock_available', __(__('This product has no available stock', 'wpsc')));
883
  }
884
 
885
-
886
  // if some action was performed, return true, otherwise, return false;
887
  $status = false;
888
  if(($add_item == true) || ($edit_item == true)) {
@@ -911,8 +883,6 @@ class wpsc_cart {
911
  }
912
  $this->cart_items[$key]->refresh_item();
913
  $this->clear_cache();
914
- } else {
915
- //$errors[] = new WP_Error('no_stock_available', __(__('This product has no available stock', 'wpsc')));
916
  }
917
  return true;
918
  } else {
@@ -1016,11 +986,6 @@ class wpsc_cart {
1016
  */
1017
  function empty_cart($fromwidget = true) {
1018
  global $wpdb;
1019
-
1020
- if(isset($_SESSION['wpsc_sessionid']) && !($fromwidget)){
1021
- // exit('google triggered');
1022
- ///wpsc_empty_google_logs();
1023
- }
1024
  $wpdb->query($wpdb->prepare("DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` IN ('%s');", $this->unique_id));
1025
 
1026
  $this->cart_items = array();
@@ -1061,7 +1026,6 @@ class wpsc_cart {
1061
  */
1062
  function submit_stock_claims($purchase_log_id) {
1063
  global $wpdb;
1064
- //exit($wpdb->prepare("UPDATE `".WPSC_TABLE_CLAIMED_STOCK."` SET `cart_id` = '%d', `cart_submitted` = '1' WHERE `cart_id` IN('%s')", $purchase_log_id, $this->unique_id));
1065
  $wpdb->query($wpdb->prepare("UPDATE `".WPSC_TABLE_CLAIMED_STOCK."` SET `cart_id` = '%d', `cart_submitted` = '1' WHERE `cart_id` IN('%s')", $purchase_log_id, $this->unique_id));
1066
  }
1067
 
@@ -1073,7 +1037,6 @@ class wpsc_cart {
1073
  */
1074
  function cleanup() {
1075
  global $wpdb;
1076
- //echo $wpdb->prepare("DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` IN ('%s')", $this->unique_id);
1077
  $wpdb->query($wpdb->prepare("DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` IN ('%s')", $this->unique_id));
1078
  }
1079
 
@@ -1092,7 +1055,6 @@ class wpsc_cart {
1092
  }
1093
  $total -= $this->coupons_amount;
1094
  $this->total_price = $total;
1095
- //exit($this->coupons_amount);
1096
  } else {
1097
  $total = $this->total_price;
1098
  }
@@ -1143,8 +1105,6 @@ class wpsc_cart {
1143
  function calculate_total_tax()
1144
  {
1145
  //uses new wpec_taxes functionality
1146
- //if(!isset($this->total_tax) || empty($this->total_tax))
1147
- //{
1148
  $wpec_taxes_controller = new wpec_taxes_controller();
1149
  $taxes_total = $wpec_taxes_controller->wpec_taxes_calculate_total();
1150
  $this->total_tax = $taxes_total['total'];
@@ -1152,36 +1112,8 @@ class wpsc_cart {
1152
  {
1153
  $this->tax_percentage = $taxes_total['rate'];
1154
  }// if
1155
- //}// if
1156
 
1157
  return $this->total_tax;
1158
-
1159
- /* OLD CODE PRESERVED
1160
- global $wpdb, $wpsc_cart;
1161
- $total = 0;
1162
- if(wpsc_tax_isincluded() == false){
1163
- if($this->total_tax == null) {
1164
- foreach($this->cart_items as $key => $cart_item) {
1165
- $total += $cart_item->tax;
1166
- }
1167
- $this->total_tax = $total;
1168
- } else {
1169
- $total = $this->total_tax;
1170
- }
1171
- }else{
1172
- if($this->total_tax == null) {
1173
- foreach($this->cart_items as $key => $cart_item) {
1174
- $total += $cart_item->taxable_price/(100+$wpsc_cart->tax_percentage)*$wpsc_cart->tax_percentage;
1175
- }
1176
- $this->total_tax = $total;
1177
- } else {
1178
- $total = $this->total_tax;
1179
- }
1180
-
1181
-
1182
- }
1183
- return $total;
1184
- */
1185
  }// calculate_total_tax
1186
 
1187
 
@@ -1308,7 +1240,6 @@ class wpsc_cart {
1308
  if($method == $this->selected_shipping_method) {
1309
  $this->total_item_shipping = $total;
1310
  }
1311
- //echo("<pre>".print_r($method." ".$total,true)."</pre>");
1312
  return $total;
1313
  }
1314
 
@@ -1473,22 +1404,16 @@ class wpsc_cart {
1473
  function get_shipping_quotes() {
1474
  global $wpdb, $wpsc_shipping_modules;
1475
  $this->shipping_quotes = array();
1476
- // exit('<pre>'.print_r($this, true).'</pre>');
1477
  if($this->shipping_method == null){
1478
  $this->get_shipping_method();
1479
  }
1480
- //echo "<pre>".print_r($this->shipping_method,true)."<pre>";
1481
- //echo "<pre>".print_r($wpsc_shipping_modules,true)."<pre>";
1482
  if(is_callable(array($wpsc_shipping_modules[$this->shipping_method], "getQuote" ))) {
1483
  $unprocessed_shipping_quotes = $wpsc_shipping_modules[$this->shipping_method]->getQuote();
1484
 
1485
  }
1486
- // exit('<pre>'.print_r($unprocessed_shipping_quotes,true).'</pre>');
1487
  $num = 0;
1488
  foreach((array)$unprocessed_shipping_quotes as $shipping_key => $shipping_value) {
1489
- //$this->calculate_per_item_shipping();
1490
- $per_item_shipping = $this->calculate_per_item_shipping($this->shipping_method);
1491
- //echo('<pre>'.print_r($unprocessed_shipping_quotes,true).'</pre>');
1492
  $this->shipping_quotes[$num]['name'] = $shipping_key;
1493
  $this->shipping_quotes[$num]['value'] = (float)$shipping_value+(float)$per_item_shipping;
1494
  $num++;
@@ -1500,13 +1425,8 @@ class wpsc_cart {
1500
  global $wpsc_shipping_modules;
1501
  $shipping_quote_count = 0;
1502
  $custom_shipping = get_option('custom_shipping_options');
1503
- if(array_search($this->selected_shipping_method, (array)$this->shipping_methods) === false) {
1504
- //unset($this->selected_shipping_method);
1505
- }
1506
-
1507
  $shipping_quotes = null;
1508
  if($this->selected_shipping_method != null) {
1509
- // exit('here');
1510
  $this->shipping_quotes = $wpsc_shipping_modules[$this->selected_shipping_method]->getQuote();
1511
  // use the selected shipping module
1512
  if ( is_callable( array( $wpsc_shipping_modules[$this->selected_shipping_method], "getQuote" ) ) ) {
@@ -1514,8 +1434,6 @@ class wpsc_cart {
1514
  $this->shipping_quotes = $wpsc_shipping_modules[$this->selected_shipping_method]->getQuote();
1515
  }
1516
  } else {
1517
-
1518
- //exit('here');
1519
  // otherwise select the first one with any quotes
1520
  foreach((array)$custom_shipping as $shipping_module) {
1521
 
@@ -1657,7 +1575,6 @@ class wpsc_cart_item {
1657
  if(($parameters['is_customisable'] == true) && ($parameters['file_data'] != null)) {
1658
  $this->save_provided_file($this->file_data);
1659
  }
1660
- //$this->meta = $meta;
1661
  $this->refresh_item();
1662
  }
1663
 
@@ -1759,7 +1676,6 @@ class wpsc_cart_item {
1759
  $taxes = $wpec_taxes_controller->wpec_taxes_calculate_included_tax($this);
1760
  $this->tax_rate = $taxes['rate'];
1761
  $this->tax = $taxes['tax'];
1762
- //$this->total_price += $this->tax;
1763
  }
1764
 
1765
  $this->product_url = wpsc_product_url($product_id);
@@ -1824,13 +1740,10 @@ class wpsc_cart_item {
1824
  }
1825
  if(method_exists( $wpsc_shipping_modules[$method], "get_item_shipping" )) {
1826
  $shipping = $wpsc_shipping_modules[$method]->get_item_shipping($this);
1827
- //echo("<pre>".print_r($shipping,true)."</pre>");
1828
  }
1829
  if($method == $this->cart->selected_shipping_method) {
1830
  $this->shipping = $shipping;
1831
  }
1832
- // echo "<pre>".print_r($wpsc_cart->cart_item)."</pre>";
1833
-
1834
  return $shipping;
1835
  }
1836
 
@@ -1849,14 +1762,12 @@ class wpsc_cart_item {
1849
 
1850
  $accepted_file_types['mime'][] = 'image/pjpeg'; // Added for IE compatibility
1851
  $accepted_file_types['mime'][] = 'image/x-png'; // Added for IE compatibility
1852
- //$accepted_file_types['mime'][] = 'image/svg+xml';
1853
 
1854
 
1855
  $accepted_file_types['ext'][] = 'jpeg';
1856
  $accepted_file_types['ext'][] = 'jpg';
1857
  $accepted_file_types['ext'][] = 'gif';
1858
  $accepted_file_types['ext'][] = 'png';
1859
- //$accepted_file_types['ext'][] = 'svg';
1860
 
1861
 
1862
  $can_have_uploaded_image = get_product_meta($this->product_id,'product_metadata',true);
71
  $total = 0;
72
  }
73
  if($forDisplay){
 
74
  return $wpsc_cart->process_as_currency($total);
75
  }else{
76
  return $total;
164
  */
165
  function wpsc_cart_show_plus_postage() {
166
  global $wpsc_cart;
 
167
  if(($_SESSION['wpsc_has_been_to_checkout'] == null ) && (get_option('add_plustax') == 1)) {
168
 
169
  return true;
285
 
286
  function wpsc_cart_item_quantity_single_prod($id) {
287
  global $wpsc_cart;
 
288
  return $wpsc_cart;
289
  }
290
  /**
293
  */
294
  function wpsc_cart_item_price($forDisplay = true) {
295
  global $wpsc_cart;
 
296
  if($forDisplay){
297
  return $wpsc_cart->process_as_currency($wpsc_cart->cart_item->total_price);
298
  }else{
367
  }
368
  function wpsc_google_checkout(){
369
  $currpage = wpsc_selfURL();
 
370
  if (array_search("google",(array)get_option('custom_gateway_options')) !== false && $currpage != get_option('shopping_cart_url')) {
371
  global $nzshpcrt_gateways;
372
  foreach($nzshpcrt_gateways as $gateway) {
453
  */
454
  function wpsc_shipping_quote_value($numeric = false) {
455
  global $wpsc_cart;
 
456
  if($numeric == true) {
457
  return $wpsc_cart->shipping_quote['value'];
458
  } else {
505
  global $wpsc_cart;
506
 
507
  if(count($wpsc_cart->shipping_quotes) > 1 || count($wpsc_cart->shipping_methods) > 1 || count($wpsc_cart->shipping_quotes) == $wpsc_cart->shipping_quote_count){
 
508
  return true;
509
  }else{
510
  return false;
524
  }
525
  function wpsc_update_shipping_single_method(){
526
  global $wpsc_cart;
 
527
  if(!empty($wpsc_cart->shipping_method)) {
528
  $wpsc_cart->update_shipping($wpsc_cart->shipping_method, $wpsc_cart->selected_shipping_option);
529
  }
530
  }
531
  function wpsc_update_shipping_multiple_methods(){
532
  global $wpsc_cart;
 
533
  if(!empty($wpsc_cart->selected_shipping_method)) {
534
  $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
535
  }
545
  var $selected_region;
546
 
547
  var $selected_shipping_method = null;
 
548
  var $selected_shipping_option = null;
549
 
550
  var $coupon;
592
  function wpsc_cart() {
593
  global $wpdb, $wpsc_shipping_modules;
594
  $coupon = 'percentage';
 
 
 
 
595
  $this->update_location();
 
596
  $this->wpsc_refresh_cart_items();
597
  $this->unique_id = sha1(uniqid(rand(), true));
598
 
627
  $this->delivery_region =& $_SESSION['wpsc_delivery_region'];
628
  $this->selected_region =& $_SESSION['wpsc_selected_region'];
629
 
 
 
630
  //adding refresh item
631
  $this->wpsc_refresh_cart_items();
632
 
673
  $this->shipping_method_count = count($this->shipping_methods);
674
 
675
  if((get_option('do_not_use_shipping') != 1) && (count($this->shipping_methods) > 0) ) {
 
 
 
 
676
  $shipping_quotes = null;
677
  if($this->selected_shipping_method != null) {
678
  // use the selected shipping module
694
 
695
  }
696
  }
 
 
697
  }
698
 
699
  /**
728
  global $wpdb, $wpsc_shipping_modules;
729
  $this->selected_shipping_method = $method;
730
 
731
+ $this->shipping_quotes = $wpsc_shipping_modules[$method]->getQuote();
732
 
 
733
  $this->selected_shipping_option = $option;
734
 
735
  foreach($this->cart_items as $key => $cart_item) {
827
 
828
  $add_item = true;
829
  $edit_item = false;
 
830
  if((count($this->cart_items) > 0) && ($new_cart_item->is_donation != 1)) {
831
  //loop through each cart item
832
  foreach($this->cart_items as $key => $cart_item) {
853
  if($add_item === true) {
854
  $this->cart_items[] = $new_cart_item;
855
  }
 
 
856
  }
857
 
 
858
  // if some action was performed, return true, otherwise, return false;
859
  $status = false;
860
  if(($add_item == true) || ($edit_item == true)) {
883
  }
884
  $this->cart_items[$key]->refresh_item();
885
  $this->clear_cache();
 
 
886
  }
887
  return true;
888
  } else {
986
  */
987
  function empty_cart($fromwidget = true) {
988
  global $wpdb;
 
 
 
 
 
989
  $wpdb->query($wpdb->prepare("DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` IN ('%s');", $this->unique_id));
990
 
991
  $this->cart_items = array();
1026
  */
1027
  function submit_stock_claims($purchase_log_id) {
1028
  global $wpdb;
 
1029
  $wpdb->query($wpdb->prepare("UPDATE `".WPSC_TABLE_CLAIMED_STOCK."` SET `cart_id` = '%d', `cart_submitted` = '1' WHERE `cart_id` IN('%s')", $purchase_log_id, $this->unique_id));
1030
  }
1031
 
1037
  */
1038
  function cleanup() {
1039
  global $wpdb;
 
1040
  $wpdb->query($wpdb->prepare("DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` IN ('%s')", $this->unique_id));
1041
  }
1042
 
1055
  }
1056
  $total -= $this->coupons_amount;
1057
  $this->total_price = $total;
 
1058
  } else {
1059
  $total = $this->total_price;
1060
  }
1105
  function calculate_total_tax()
1106
  {
1107
  //uses new wpec_taxes functionality
 
 
1108
  $wpec_taxes_controller = new wpec_taxes_controller();
1109
  $taxes_total = $wpec_taxes_controller->wpec_taxes_calculate_total();
1110
  $this->total_tax = $taxes_total['total'];
1112
  {
1113
  $this->tax_percentage = $taxes_total['rate'];
1114
  }// if
 
1115
 
1116
  return $this->total_tax;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1117
  }// calculate_total_tax
1118
 
1119
 
1240
  if($method == $this->selected_shipping_method) {
1241
  $this->total_item_shipping = $total;
1242
  }
 
1243
  return $total;
1244
  }
1245
 
1404
  function get_shipping_quotes() {
1405
  global $wpdb, $wpsc_shipping_modules;
1406
  $this->shipping_quotes = array();
 
1407
  if($this->shipping_method == null){
1408
  $this->get_shipping_method();
1409
  }
 
 
1410
  if(is_callable(array($wpsc_shipping_modules[$this->shipping_method], "getQuote" ))) {
1411
  $unprocessed_shipping_quotes = $wpsc_shipping_modules[$this->shipping_method]->getQuote();
1412
 
1413
  }
 
1414
  $num = 0;
1415
  foreach((array)$unprocessed_shipping_quotes as $shipping_key => $shipping_value) {
1416
+ $per_item_shipping = $this->calculate_per_item_shipping($this->shipping_method);
 
 
1417
  $this->shipping_quotes[$num]['name'] = $shipping_key;
1418
  $this->shipping_quotes[$num]['value'] = (float)$shipping_value+(float)$per_item_shipping;
1419
  $num++;
1425
  global $wpsc_shipping_modules;
1426
  $shipping_quote_count = 0;
1427
  $custom_shipping = get_option('custom_shipping_options');
 
 
 
 
1428
  $shipping_quotes = null;
1429
  if($this->selected_shipping_method != null) {
 
1430
  $this->shipping_quotes = $wpsc_shipping_modules[$this->selected_shipping_method]->getQuote();
1431
  // use the selected shipping module
1432
  if ( is_callable( array( $wpsc_shipping_modules[$this->selected_shipping_method], "getQuote" ) ) ) {
1434
  $this->shipping_quotes = $wpsc_shipping_modules[$this->selected_shipping_method]->getQuote();
1435
  }
1436
  } else {
 
 
1437
  // otherwise select the first one with any quotes
1438
  foreach((array)$custom_shipping as $shipping_module) {
1439
 
1575
  if(($parameters['is_customisable'] == true) && ($parameters['file_data'] != null)) {
1576
  $this->save_provided_file($this->file_data);
1577
  }
 
1578
  $this->refresh_item();
1579
  }
1580
 
1676
  $taxes = $wpec_taxes_controller->wpec_taxes_calculate_included_tax($this);
1677
  $this->tax_rate = $taxes['rate'];
1678
  $this->tax = $taxes['tax'];
 
1679
  }
1680
 
1681
  $this->product_url = wpsc_product_url($product_id);
1740
  }
1741
  if(method_exists( $wpsc_shipping_modules[$method], "get_item_shipping" )) {
1742
  $shipping = $wpsc_shipping_modules[$method]->get_item_shipping($this);
 
1743
  }
1744
  if($method == $this->cart->selected_shipping_method) {
1745
  $this->shipping = $shipping;
1746
  }
 
 
1747
  return $shipping;
1748
  }
1749
 
1762
 
1763
  $accepted_file_types['mime'][] = 'image/pjpeg'; // Added for IE compatibility
1764
  $accepted_file_types['mime'][] = 'image/x-png'; // Added for IE compatibility
 
1765
 
1766
 
1767
  $accepted_file_types['ext'][] = 'jpeg';
1768
  $accepted_file_types['ext'][] = 'jpg';
1769
  $accepted_file_types['ext'][] = 'gif';
1770
  $accepted_file_types['ext'][] = 'png';
 
1771
 
1772
 
1773
  $can_have_uploaded_image = get_product_meta($this->product_id,'product_metadata',true);
wpsc-includes/category.functions.php CHANGED
@@ -177,46 +177,11 @@ function wpsc_end_category_query() {
177
  function wpsc_display_category_loop($query, $category_html, &$category_branch = null){
178
  static $category_count_data = array(); // the array tree is stored in this
179
  global $wpdb, $wpsc_query;
180
- /*
181
- $category_sql_segments = array();
182
-
183
- $category_sql_segments[] = "`active`='1'";
184
- if(is_numeric($query['category_group']) ) {
185
- $category_group = absint($query['category_group']);
186
- $category_sql_segments[] = "`group_id`='$category_group'";
187
- } elseif($query['category_group']=='all' || $query['category_group']=='all+list') {
188
- $category_group = 1;
189
- }
190
-
191
-
192
- /// select by parent category
193
- $category_sql_segments[] = "`category_parent` = '".absint($query['parent_category_id'])."'";
194
-
195
- // order by what in which direction
196
- if(!isset($query['order_by'])) {
197
- $query['order_by'] = array("column" => 'name', "direction" =>'asc');
198
- }
199
-
200
- $column = $wpdb->escape($query['order_by']['column']);
201
-
202
- if(strtolower($query['order_by']['direction']) == "desc") {
203
- $order = "DESC";
204
- } else {
205
- $order = "ASC";
206
- }
207
-
208
- // filter for other plugins
209
- $category_sql_segments = apply_filters('wpsc_display_category_loop_category_sql_segments', $category_sql_segments);
210
- $category_data = $wpdb->get_results("SELECT `id`, `name`, `nice-name`, `description`, `image` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE ".implode(" AND ", $category_sql_segments)." ORDER BY `{$column}` $order",ARRAY_A);
211
- //*/
212
 
213
 
214
  $category_id = absint($query['parent_category_id']);
215
 
216
-
217
- //exit("<pre>".print_r($category_data,true)."</pre>");
218
  $category_data = get_terms('wpsc_product_category','hide_empty=0&parent='.$category_id, OBJECT, 'display');
219
- //print("<pre>".print_r($category_data,true)."</pre>");
220
  $output ='';
221
 
222
  // if the category branch is identical to null, make it a reference to $category_count_data
@@ -224,8 +189,6 @@ function wpsc_display_category_loop($query, $category_html, &$category_branch =
224
  $category_branch =& $category_count_data;
225
  }
226
 
227
-
228
- //$current_category_level = array();
229
  foreach((array)$category_data as $category_row) {
230
 
231
  // modifys the query for the next round
@@ -262,7 +225,6 @@ function wpsc_display_category_loop($query, $category_html, &$category_branch =
262
  // grab the product count from the subcategories
263
  foreach((array)$category_branch[$category_row->term_id]['children'] as $child_category) {
264
  $category_branch[$category_row->term_id]['count'] += (int)$child_category['count'];
265
- //echo "<pre>".print_r($child_category, true)."</pre>";
266
  }
267
 
268
  // stick the category count array together here
@@ -330,12 +292,6 @@ function wpsc_display_category_loop($query, $category_html, &$category_branch =
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);
332
  }
333
-
334
- if($_GET['debug'] == 'true') {
335
- //echo "<pre>".print_r($category_count_data,true)."</pre>";
336
- //phpinfo();
337
- }
338
-
339
  return $output;
340
  }
341
 
@@ -351,7 +307,6 @@ function wpsc_place_category_image($category_id, $query) {
351
  global $wpsc_query, $wpdb;
352
  $width = $query['image_size']['width'];
353
  $height = $query['image_size']['height'];
354
- //echo "<pre>".print_r($query, true)."</pre>";
355
  $image_url = "index.php?wpsc_request_image=true&category_id=".$category_id."&width=".$width."&height=".$height;
356
  return htmlspecialchars($image_url);
357
  }
177
  function wpsc_display_category_loop($query, $category_html, &$category_branch = null){
178
  static $category_count_data = array(); // the array tree is stored in this
179
  global $wpdb, $wpsc_query;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
 
181
 
182
  $category_id = absint($query['parent_category_id']);
183
 
 
 
184
  $category_data = get_terms('wpsc_product_category','hide_empty=0&parent='.$category_id, OBJECT, 'display');
 
185
  $output ='';
186
 
187
  // if the category branch is identical to null, make it a reference to $category_count_data
189
  $category_branch =& $category_count_data;
190
  }
191
 
 
 
192
  foreach((array)$category_data as $category_row) {
193
 
194
  // modifys the query for the next round
225
  // grab the product count from the subcategories
226
  foreach((array)$category_branch[$category_row->term_id]['children'] as $child_category) {
227
  $category_branch[$category_row->term_id]['count'] += (int)$child_category['count'];
 
228
  }
229
 
230
  // stick the category count array together here
292
  // Stick all the category html together and concatenate it to the previously generated HTML
293
  $output .= str_replace($tags_to_replace, $content_to_place ,$category_html);
294
  }
 
 
 
 
 
 
295
  return $output;
296
  }
297
 
307
  global $wpsc_query, $wpdb;
308
  $width = $query['image_size']['width'];
309
  $height = $query['image_size']['height'];
 
310
  $image_url = "index.php?wpsc_request_image=true&category_id=".$category_id."&width=".$width."&height=".$height;
311
  return htmlspecialchars($image_url);
312
  }
wpsc-includes/checkout.class.php CHANGED
@@ -108,12 +108,9 @@ function wpsc_google_checkout_submit() {
108
  global $wpdb, $wpsc_cart, $current_user;
109
  $wpsc_checkout = new wpsc_checkout();
110
  $purchase_log_id = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` IN('" . $_SESSION['wpsc_sessionid'] . "') LIMIT 1" );
111
- //$purchase_log_id = 1;
112
  get_currentuserinfo();
113
- // exit('<pre>'.print_r($current_user, true).'</pre>');
114
  if ( $current_user->display_name != '' ) {
115
  foreach ( $wpsc_checkout->checkout_items as $checkoutfield ) {
116
- // exit(print_r($checkoutfield,true));
117
  if ( $checkoutfield->unique_name == 'billingfirstname' ) {
118
  $checkoutfield->value = $current_user->display_name;
119
  }
@@ -121,7 +118,6 @@ function wpsc_google_checkout_submit() {
121
  }
122
  if ( $current_user->user_email != '' ) {
123
  foreach ( $wpsc_checkout->checkout_items as $checkoutfield ) {
124
- // exit(print_r($checkoutfield,true));
125
  if ( $checkoutfield->unique_name == 'billingemail' ) {
126
  $checkoutfield->value = $current_user->user_email;
127
  }
@@ -372,10 +368,8 @@ function wpsc_the_checkout_item_error() {
372
 
373
  function wpsc_the_checkout_CC_validation() {
374
  $output = '';
375
- //exit('<pre>'.print_r($_SESSION['wpsc_gateway_error_messages'],true).'</pre>');
376
  if ( $_SESSION['wpsc_gateway_error_messages']['card_number'] != '' ) {
377
  $output = $_SESSION['wpsc_gateway_error_messages']['card_number'];
378
- // $_SESSION['wpsc_gateway_error_messages']['card_number'] = '';
379
  }
380
  return $output;
381
  }
@@ -400,7 +394,6 @@ function wpsc_the_checkout_CCexpiry_validation() {
400
  $output = '';
401
  if ( $_SESSION['wpsc_gateway_error_messages']['expdate'] != '' ) {
402
  $output = $_SESSION['wpsc_gateway_error_messages']['expdate'];
403
- // $_SESSION['wpsc_gateway_error_messages']['expdate'] = '';
404
  }
405
  return $output;
406
  }
@@ -417,7 +410,6 @@ function wpsc_the_checkout_CCcvv_validation() {
417
  $output = '';
418
  if ( $_SESSION['wpsc_gateway_error_messages']['card_code'] != '' ) {
419
  $output = $_SESSION['wpsc_gateway_error_messages']['card_code'];
420
- // $_SESSION['wpsc_gateway_error_messages']['card_code'] = '';
421
  }
422
  return $output;
423
  }
@@ -434,7 +426,6 @@ function wpsc_the_checkout_CCtype_validation() {
434
  $output = '';
435
  if ( $_SESSION['wpsc_gateway_error_messages']['cctype'] != '' ) {
436
  $output = $_SESSION['wpsc_gateway_error_messages']['cctype'];
437
- //$_SESSION['wpsc_gateway_error_messages']['cctype'] ='';
438
  }
439
  return $output;
440
  }
@@ -467,7 +458,6 @@ function wpsc_checkout_form_field() {
467
  function wpsc_shipping_region_list( $selected_country, $selected_region, $shippingdetails = false ) {
468
  global $wpdb;
469
  $output = '';
470
- //$region_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_REGION_TAX."` WHERE country_id='136'",ARRAY_A);
471
  $region_data = $wpdb->get_results( "SELECT `regions`.* FROM `" . WPSC_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('" . $wpdb->escape( $selected_country ) . "')", ARRAY_A );
472
  $js = '';
473
  if ( !$shippingdetails ) {
@@ -664,32 +654,23 @@ class wpsc_checkout {
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() )
@@ -738,7 +719,6 @@ class wpsc_checkout {
738
  }
739
  $output .="</select>";
740
  }
741
- //echo ('<pre>'.print_r($output, true).'</pre>');
742
  break;
743
  case "radio":
744
  $options = $this->get_checkout_options( $this->checkout_item->id );
@@ -929,18 +909,14 @@ class wpsc_checkout {
929
  global $wpdb;
930
 
931
  $count = $this->get_count_checkout_fields() + 1;
932
- //exit($count.'<pre>'.print_r($this->checkout_items, true).'</pre>');
933
  $i = 0;
934
  foreach ( $this->checkout_items as $form_data ) {
935
-
936
- // $value = wpsc_kill_xss($_POST['collected_data'][$form_data->id]);
937
  $value = $_POST['collected_data'][$form_data->id];
938
  if ( $value == '' ) {
939
  $value = $form_data->value;
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
 
@@ -953,8 +929,6 @@ class wpsc_checkout {
953
  } else {
954
  $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 ) );
955
  }
956
-
957
- //echo "INSERT INTO `".WPSC_TABLE_SUBMITED_FORM_DATA."` ( `log_id` , `form_id` , `value` ) VALUES ( '{$purchase_id}', '".(int)$form_data->id."', '".$value."');<br />";
958
  }
959
  if ( $i > $count ) {
960
  break;
108
  global $wpdb, $wpsc_cart, $current_user;
109
  $wpsc_checkout = new wpsc_checkout();
110
  $purchase_log_id = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` IN('" . $_SESSION['wpsc_sessionid'] . "') LIMIT 1" );
 
111
  get_currentuserinfo();
 
112
  if ( $current_user->display_name != '' ) {
113
  foreach ( $wpsc_checkout->checkout_items as $checkoutfield ) {
 
114
  if ( $checkoutfield->unique_name == 'billingfirstname' ) {
115
  $checkoutfield->value = $current_user->display_name;
116
  }
118
  }
119
  if ( $current_user->user_email != '' ) {
120
  foreach ( $wpsc_checkout->checkout_items as $checkoutfield ) {
 
121
  if ( $checkoutfield->unique_name == 'billingemail' ) {
122
  $checkoutfield->value = $current_user->user_email;
123
  }
368
 
369
  function wpsc_the_checkout_CC_validation() {
370
  $output = '';
 
371
  if ( $_SESSION['wpsc_gateway_error_messages']['card_number'] != '' ) {
372
  $output = $_SESSION['wpsc_gateway_error_messages']['card_number'];
 
373
  }
374
  return $output;
375
  }
394
  $output = '';
395
  if ( $_SESSION['wpsc_gateway_error_messages']['expdate'] != '' ) {
396
  $output = $_SESSION['wpsc_gateway_error_messages']['expdate'];
 
397
  }
398
  return $output;
399
  }
410
  $output = '';
411
  if ( $_SESSION['wpsc_gateway_error_messages']['card_code'] != '' ) {
412
  $output = $_SESSION['wpsc_gateway_error_messages']['card_code'];
 
413
  }
414
  return $output;
415
  }
426
  $output = '';
427
  if ( $_SESSION['wpsc_gateway_error_messages']['cctype'] != '' ) {
428
  $output = $_SESSION['wpsc_gateway_error_messages']['cctype'];
 
429
  }
430
  return $output;
431
  }
458
  function wpsc_shipping_region_list( $selected_country, $selected_region, $shippingdetails = false ) {
459
  global $wpdb;
460
  $output = '';
 
461
  $region_data = $wpdb->get_results( "SELECT `regions`.* FROM `" . WPSC_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('" . $wpdb->escape( $selected_country ) . "')", ARRAY_A );
462
  $js = '';
463
  if ( !$shippingdetails ) {
654
  global $wpdb, $user_ID;
655
  if ( ($user_ID > 0) ){
656
  $_SESSION['wpsc_checkout_saved_values'] = get_user_meta( $user_ID, 'wpshpcrt_usr_profile',1 );
657
+
658
  $delivery_country_id = wpsc_get_country_form_id_by_type('delivery_country');
659
+ $billing_country_id = wpsc_get_country_form_id_by_type('country');
660
+ if(($this->checkout_item->id == $delivery_country_id) || ($this->checkout_item->id == $billing_country_id)){
661
  if( is_array($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id])
662
  && count($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]) > 1){
663
 
664
  $_SESSION['wpsc_delivery_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][0];
665
  $_SESSION['wpsc_delivery_region'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][1];
666
+ } elseif(is_array($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id])) {
 
667
  $_SESSION['wpsc_delivery_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][0];
668
+ }else{
669
+ $_SESSION['wpsc_delivery_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id];
 
 
 
 
 
 
 
 
 
 
670
  }
671
  }
672
  }
673
+ $saved_form_data = @htmlentities( stripslashes( (string)$_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id] ), ENT_QUOTES );
674
  $an_array = '';
675
  if ( function_exists( 'wpsc_get_ticket_checkout_set' ) ) {
676
  if ( $this->checkout_item->checkout_set == wpsc_get_ticket_checkout_set() )
719
  }
720
  $output .="</select>";
721
  }
 
722
  break;
723
  case "radio":
724
  $options = $this->get_checkout_options( $this->checkout_item->id );
909
  global $wpdb;
910
 
911
  $count = $this->get_count_checkout_fields() + 1;
 
912
  $i = 0;
913
  foreach ( $this->checkout_items as $form_data ) {
 
 
914
  $value = $_POST['collected_data'][$form_data->id];
915
  if ( $value == '' ) {
916
  $value = $form_data->value;
917
  }
918
 
919
  if ( $form_data->type != 'heading' ) {
 
920
  if ( is_array( $value ) && ($form_data->unique_name == 'billingcountry' || $form_data->unique_name == 'shippingcountry') ) {
921
  $value = $value[0];
922
 
929
  } else {
930
  $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 ) );
931
  }
 
 
932
  }
933
  if ( $i > $count ) {
934
  break;
wpsc-includes/coupons.class.php CHANGED
@@ -10,14 +10,12 @@ function wpsc_uses_coupons() {
10
  $wpsc_coupons = new wpsc_coupons();
11
  }
12
  if(is_object($wpsc_coupons)) {
13
- // exit('<pre>'.print_r($wpsc_coupons,true).'</pre>');
14
  return $wpsc_coupons->uses_coupons();
15
  }
16
  return false;
17
  }
18
  function wpsc_coupons_error(){
19
  global $wpsc_coupons;
20
- //exit('<pre>'.print_r($wpsc_coupons, true).'</pre>');
21
  if(isset($wpsc_coupons->errormsg) && $wpsc_coupons->errormsg == false){
22
  return true;
23
  }else{
@@ -143,14 +141,6 @@ class wpsc_coupons {
143
 
144
  //Loop throught all products in the shopping cart, apply coupons on the ones match the conditions.
145
  $cart =& $wpsc_cart->have_cart_items();
146
- // exit('<pre>'.print_r($cart->, true).'</pre>');
147
- /*
148
- foreach($wpsc_cart->cart_items as $key => $cart_item) {
149
- echo '<pre>'.print_r($cart_item, true).'</pre>';
150
- }
151
- */
152
- //exit('<pre>'.print_r($this, true).'</pre>');
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}'");
@@ -184,7 +174,6 @@ foreach($wpsc_cart->cart_items as $key => $cart_item) {
184
  if($this->every_product == 1){
185
  $return += $item->discount;
186
  }else{
187
- //exit('<pre>'.print_r($this,true).'</pre>');
188
  return $item->discount;
189
  }
190
  }
@@ -306,7 +295,6 @@ foreach($wpsc_cart->cart_items as $key => $cart_item) {
306
  return false;
307
  }
308
  } else if ($c['property'] == 'total_quantity'){
309
- // exit('<pre>'.print_r($product_obj, true).'</pre>');
310
  $total_quantity = $product_obj->quantity;
311
  switch($c['logic']) {
312
  case 'equal'://Checks if the quantity of products in the cart equals condition value
@@ -330,7 +318,6 @@ foreach($wpsc_cart->cart_items as $key => $cart_item) {
330
 
331
  } else if ($c['property'] == 'subtotal_amount'){
332
  $subtotal = wpsc_cart_total(false);
333
- //exit('<pre>'.print_r($subtotal,true).'</pre>');
334
  switch($c['logic']) {
335
  case 'equal'://Checks if the subtotal of products in the cart equals condition value
336
  if ($subtotal == $c['value'])
@@ -338,14 +325,12 @@ foreach($wpsc_cart->cart_items as $key => $cart_item) {
338
  break;
339
 
340
  case 'greater'://Checks if the subtotal of the cart is greater than the condition value
341
- // exit('triggered here'.$subtotal.'>'.$c['value']);
342
  if ($subtotal > $c['value'])
343
  return true;
344
  break;
345
 
346
  case 'less'://Checks if the subtotal of the cart is less than the condition value
347
  if ($subtotal < $c['value']){
348
- //exit('<pre>'.print_r($product_obj->cart->subtotal, true).'</pre>cValue'.$c['value']);
349
  return true;
350
  }else{
351
  return false;
10
  $wpsc_coupons = new wpsc_coupons();
11
  }
12
  if(is_object($wpsc_coupons)) {
 
13
  return $wpsc_coupons->uses_coupons();
14
  }
15
  return false;
16
  }
17
  function wpsc_coupons_error(){
18
  global $wpsc_coupons;
 
19
  if(isset($wpsc_coupons->errormsg) && $wpsc_coupons->errormsg == false){
20
  return true;
21
  }else{
141
 
142
  //Loop throught all products in the shopping cart, apply coupons on the ones match the conditions.
143
  $cart =& $wpsc_cart->have_cart_items();
 
 
 
 
 
 
 
 
144
  foreach ($wpsc_cart->cart_items as $key => $item) {
145
 
146
  $product_data = $wpdb->get_results("SELECT * FROM ". $wpdb->posts ." WHERE id='{$item->product_id}'");
174
  if($this->every_product == 1){
175
  $return += $item->discount;
176
  }else{
 
177
  return $item->discount;
178
  }
179
  }
295
  return false;
296
  }
297
  } else if ($c['property'] == 'total_quantity'){
 
298
  $total_quantity = $product_obj->quantity;
299
  switch($c['logic']) {
300
  case 'equal'://Checks if the quantity of products in the cart equals condition value
318
 
319
  } else if ($c['property'] == 'subtotal_amount'){
320
  $subtotal = wpsc_cart_total(false);
 
321
  switch($c['logic']) {
322
  case 'equal'://Checks if the subtotal of products in the cart equals condition value
323
  if ($subtotal == $c['value'])
325
  break;
326
 
327
  case 'greater'://Checks if the subtotal of the cart is greater than the condition value
 
328
  if ($subtotal > $c['value'])
329
  return true;
330
  break;
331
 
332
  case 'less'://Checks if the subtotal of the cart is less than the condition value
333
  if ($subtotal < $c['value']){
 
334
  return true;
335
  }else{
336
  return false;
wpsc-includes/currency_converter.inc.php CHANGED
@@ -39,7 +39,6 @@
39
  if(!empty($from))
40
  $this->_from=$from;
41
 
42
- //$host="www.iraqidinar.org";
43
  $host="www.xe.com";
44
  $fp = @fsockopen($host, 80, $errno, $errstr, 30);
45
  if (!$fp)
@@ -49,9 +48,7 @@
49
  }
50
  else
51
  {
52
- //$file="/conversiontool2.asp";
53
  $file="/ucc/convert.cgi";
54
- //$str = "?amount=".$this->_amt."&ConvertFrom=".$this->_from."&ConvertTo=".$this->_to;
55
  $str = "?language=xe&Amount=".$this->_amt."&From=".$this->_from."&To=".$this->_to;
56
  $out = "GET ".$file.$str." HTTP/1.0\r\n";
57
  $out .= "Host: $host\r\n";
39
  if(!empty($from))
40
  $this->_from=$from;
41
 
 
42
  $host="www.xe.com";
43
  $fp = @fsockopen($host, 80, $errno, $errstr, 30);
44
  if (!$fp)
48
  }
49
  else
50
  {
 
51
  $file="/ucc/convert.cgi";
 
52
  $str = "?language=xe&Amount=".$this->_amt."&From=".$this->_from."&To=".$this->_to;
53
  $out = "GET ".$file.$str." HTTP/1.0\r\n";
54
  $out .= "Host: $host\r\n";
wpsc-includes/display.functions.php CHANGED
@@ -83,7 +83,6 @@ function wpsc_also_bought( $product_id ) {
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 ) {
@@ -211,7 +210,6 @@ function wpsc_product_image_html( $image_name, $product_id ) {
211
  $use_thumbnail_image = 'true';
212
  }
213
 
214
- //list($category['height'], $category['width']) =
215
  if ( $category_id > 0 ) {
216
  $category = $wpdb->get_row( "SELECT `image_height` AS `height`, `image_width` AS `width` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `id` IN ('{$category_id}') LIMIT 1", ARRAY_A );
217
  }
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
  $output .= "<div class='wpsc_also_bought_item' style='width: " . $element_widths . "px;'>";
87
  if ( get_option( 'show_thumbnails' ) == 1 ) {
88
  if ( $also_bought_data['image'] != null ) {
210
  $use_thumbnail_image = 'true';
211
  }
212
 
 
213
  if ( $category_id > 0 ) {
214
  $category = $wpdb->get_row( "SELECT `image_height` AS `height`, `image_width` AS `width` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `id` IN ('{$category_id}') LIMIT 1", ARRAY_A );
215
  }
wpsc-includes/form-display.functions.php CHANGED
@@ -40,8 +40,6 @@ function nzshpcrt_region_list( $selected_country = null, $selected_region = null
40
 
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
  }
@@ -160,7 +158,6 @@ function wpsc_uploaded_files() {
160
  // JS - For 3.8, function re-worked to only show files attached to product, separate thickbox with all products, to be associated with product.
161
  function wpsc_select_product_file( $product_id = null ) {
162
  global $wpdb;
163
- //return false;
164
  $product_id = absint( $product_id );
165
  $file_list = wpsc_uploaded_files();
166
 
@@ -205,8 +202,6 @@ function wpsc_select_product_file( $product_id = null ) {
205
 
206
  function wpsc_select_variation_file( $file_id, $variation_ids, $variation_combination_id = null ) {
207
  global $wpdb;
208
-
209
- //return false;
210
  $file_list = wpsc_uploaded_files();
211
  $unique_id_component = ((int)$variation_combination_id) . "_" . str_replace( ",", "_", $variation_ids );
212
 
40
 
41
  $output .= "<option value='" . $region['id'] . "' $selected>" . $region['name'] . "</option>\n\r";
42
  }
 
 
43
  } else {
44
  $output .= "<select name='base_region' disabled='true'><option value=''>None</option></select>\n\r";
45
  }
158
  // JS - For 3.8, function re-worked to only show files attached to product, separate thickbox with all products, to be associated with product.
159
  function wpsc_select_product_file( $product_id = null ) {
160
  global $wpdb;
 
161
  $product_id = absint( $product_id );
162
  $file_list = wpsc_uploaded_files();
163
 
202
 
203
  function wpsc_select_variation_file( $file_id, $variation_ids, $variation_combination_id = null ) {
204
  global $wpdb;
 
 
205
  $file_list = wpsc_uploaded_files();
206
  $unique_id_component = ((int)$variation_combination_id) . "_" . str_replace( ",", "_", $variation_ids );
207
 
wpsc-includes/image_processing.php CHANGED
@@ -8,22 +8,17 @@ global $wpdb;
8
  if(file_exists($image_input) && is_numeric($height) && is_numeric($width) && function_exists('imagecreatefrompng') && (($height != $imagetype[1]) && ($width != $imagetype[0]))) {
9
  switch($imagetype[2]) {
10
  case IMAGETYPE_JPEG:
11
- //$extension = ".jpg";
12
  $src_img = imagecreatefromjpeg($image_input);
13
  $pass_imgtype = true;
14
  break;
15
 
16
  case IMAGETYPE_GIF:
17
- //$extension = ".gif";
18
  $src_img = imagecreatefromgif($image_input);
19
  $pass_imgtype = true;
20
  break;
21
 
22
  case IMAGETYPE_PNG:
23
- //$extension = ".png";
24
  $src_img = imagecreatefrompng($image_input);
25
- // imagesavealpha($src_img,true);
26
- // ImageAlphaBlending($src_img, false);
27
  $pass_imgtype = true;
28
  break;
29
 
@@ -49,13 +44,11 @@ global $wpdb;
49
  } else {
50
  $temp_w = ($height / $source_h) * $source_w;
51
  }
52
- //$temp_w = ($height / $source_h) * $source_w;
53
  } else {
54
  $temp_h = ($width / $source_w) * $source_h;
55
  }
56
 
57
  // Create temp resized image
58
- // exit(get_option('product_image_height'));
59
  $temp_img = ImageCreateTrueColor( $temp_w, $temp_h );
60
  $bgcolor = ImageColorAllocate( $temp_img, 255, 255, 255 );
61
  ImageFilledRectangle( $temp_img, 0, 0, $width, $height, $bgcolor );
@@ -98,11 +91,9 @@ global $wpdb;
98
 
99
 
100
  // Final thumbnail cropped from the center out.
101
- //ImageCopyResampled( $dst_img, $temp_img, 0, 0, $w1, $h1, $width, $height, $width, $height );
102
  if(!isset($h1))
103
  $h1 = 0;
104
  ImageCopy( $dst_img, $temp_img, $w1, $h1, 0, 0, $temp_w, $temp_h );
105
- //mail('thomas.howard@gmail.com','lolwut',"ImageCopy( $dst_img, $temp_img, $w1, $h1, 0, 0, $temp_w, $temp_h );");
106
 
107
  $image_quality = wpsc_image_quality();
108
 
8
  if(file_exists($image_input) && is_numeric($height) && is_numeric($width) && function_exists('imagecreatefrompng') && (($height != $imagetype[1]) && ($width != $imagetype[0]))) {
9
  switch($imagetype[2]) {
10
  case IMAGETYPE_JPEG:
 
11
  $src_img = imagecreatefromjpeg($image_input);
12
  $pass_imgtype = true;
13
  break;
14
 
15
  case IMAGETYPE_GIF:
 
16
  $src_img = imagecreatefromgif($image_input);
17
  $pass_imgtype = true;
18
  break;
19
 
20
  case IMAGETYPE_PNG:
 
21
  $src_img = imagecreatefrompng($image_input);
 
 
22
  $pass_imgtype = true;
23
  break;
24
 
44
  } else {
45
  $temp_w = ($height / $source_h) * $source_w;
46
  }
 
47
  } else {
48
  $temp_h = ($width / $source_w) * $source_h;
49
  }
50
 
51
  // Create temp resized image
 
52
  $temp_img = ImageCreateTrueColor( $temp_w, $temp_h );
53
  $bgcolor = ImageColorAllocate( $temp_img, 255, 255, 255 );
54
  ImageFilledRectangle( $temp_img, 0, 0, $width, $height, $bgcolor );
91
 
92
 
93
  // Final thumbnail cropped from the center out.
 
94
  if(!isset($h1))
95
  $h1 = 0;
96
  ImageCopy( $dst_img, $temp_img, $w1, $h1, 0, 0, $temp_w, $temp_h );
 
97
 
98
  $image_quality = wpsc_image_quality();
99
 
wpsc-includes/merchant.class.php CHANGED
@@ -62,7 +62,6 @@ class wpsc_merchant {
62
  */
63
  function __construct( $purchase_id = null, $is_receiving = false ) {
64
  global $wpdb;
65
- //$purchase_logs = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id` = {$purchase_id} LIMIT 1") ;
66
  if ( ($purchase_id == null) && ($is_receiving == true) ) {
67
  $this->is_receiving = true;
68
  $this->parse_gateway_notification();
@@ -170,7 +169,6 @@ class wpsc_merchant {
170
 
171
  $this->cart_data = array(
172
  'software_name' => 'WP e-Commerce/' . WPSC_PRESENTABLE_VERSION . '',
173
- // 'store_name' => '', /// is this useful or needed?
174
  'store_location' => get_option( 'base_country' ),
175
  'store_currency' => $currency_code,
176
  'is_subscription' => false,
@@ -201,8 +199,6 @@ class wpsc_merchant {
201
  global $wpdb;
202
  $purchase_id = & $this->purchase_id;
203
  $original_cart_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = {$purchase_id}", ARRAY_A );
204
- //print_r($original_cart_data);
205
- //return;
206
 
207
  foreach ( $original_cart_data as $cart_row ) {
208
  $is_downloadable = false;
@@ -306,7 +302,6 @@ class wpsc_merchant {
306
 
307
  $transaction_id = $wpdb->escape( $transaction_id );
308
  $wpdb->query( "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed` = '" . absint( $status ) . "', `transactid` ='{$transaction_id}' WHERE `id` = " . absint( $this->purchase_id ) . " LIMIT 1" );
309
- //exit("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `processed` = '".absint($status)."', `transactid` ='{$transaction_id}' WHERE `id` IN ('".absint($this->purchase_id)."') LIMIT 1");
310
  }
311
 
312
  /**
62
  */
63
  function __construct( $purchase_id = null, $is_receiving = false ) {
64
  global $wpdb;
 
65
  if ( ($purchase_id == null) && ($is_receiving == true) ) {
66
  $this->is_receiving = true;
67
  $this->parse_gateway_notification();
169
 
170
  $this->cart_data = array(
171
  'software_name' => 'WP e-Commerce/' . WPSC_PRESENTABLE_VERSION . '',
 
172
  'store_location' => get_option( 'base_country' ),
173
  'store_currency' => $currency_code,
174
  'is_subscription' => false,
199
  global $wpdb;
200
  $purchase_id = & $this->purchase_id;
201
  $original_cart_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = {$purchase_id}", ARRAY_A );
 
 
202
 
203
  foreach ( $original_cart_data as $cart_row ) {
204
  $is_downloadable = false;
302
 
303
  $transaction_id = $wpdb->escape( $transaction_id );
304
  $wpdb->query( "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed` = '" . absint( $status ) . "', `transactid` ='{$transaction_id}' WHERE `id` = " . absint( $this->purchase_id ) . " LIMIT 1" );
 
305
  }
306
 
307
  /**
wpsc-includes/meta.functions.php CHANGED
@@ -23,7 +23,6 @@ function wpsc_get_meta( $object_id = 0, $meta_key, $type) {
23
  $meta_tuple = compact( 'object_type', 'object_id', 'meta_key', 'meta_value', 'type' );
24
  $meta_tuple = apply_filters( 'wpsc_update_meta', $meta_tuple );
25
  extract( $meta_tuple, EXTR_OVERWRITE );
26
- /* echo "SELECT `meta_value` FROM `".WPSC_TABLE_META."` WHERE `object_type` = ".$object_type." AND `object_id` = ".$object_id." AND `meta_key` = ".$meta_key; */
27
  $meta_value = $wpdb->get_var( $wpdb->prepare( "SELECT `meta_value` FROM `".WPSC_TABLE_META."` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s", $object_type, $object_id, $meta_key ) );
28
  $meta_value = maybe_unserialize( $meta_value );
29
  return $meta_value;
@@ -261,12 +260,10 @@ class wpsc_custom_meta {
261
 
262
  function the_custom_meta() {
263
  $this->custom_meta_values = $this->next_custom_meta();
264
- //echo "<pre>".print_r($this,true)."</pre>";
265
  return $this->custom_meta_values;
266
  }
267
 
268
  function rewind_custom_meta() {
269
- //$this->current_custom_meta = -1;
270
  if ($this->custom_meta_count > 0) {
271
  $this->custom_meta_values = $this->custom_meta[0];
272
  }
23
  $meta_tuple = compact( 'object_type', 'object_id', 'meta_key', 'meta_value', 'type' );
24
  $meta_tuple = apply_filters( 'wpsc_update_meta', $meta_tuple );
25
  extract( $meta_tuple, EXTR_OVERWRITE );
 
26
  $meta_value = $wpdb->get_var( $wpdb->prepare( "SELECT `meta_value` FROM `".WPSC_TABLE_META."` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s", $object_type, $object_id, $meta_key ) );
27
  $meta_value = maybe_unserialize( $meta_value );
28
  return $meta_value;
260
 
261
  function the_custom_meta() {
262
  $this->custom_meta_values = $this->next_custom_meta();
 
263
  return $this->custom_meta_values;
264
  }
265
 
266
  function rewind_custom_meta() {
 
267
  if ($this->custom_meta_count > 0) {
268
  $this->custom_meta_values = $this->custom_meta[0];
269
  }
wpsc-includes/misc.functions.php CHANGED
@@ -156,7 +156,6 @@ function wpsc_change_canonical_url( $url ) {
156
  }
157
  }
158
  }
159
- //echo "<pre>".print_r($wpsc_query->is_single,true)."</pre>";
160
  return $url;
161
  }
162
 
@@ -175,7 +174,6 @@ function wpsc_canonical_url() {
175
  }
176
  }
177
 
178
- //add_action( 'template_redirect', 'wpsc_canonical_url' );
179
  // check for all in one SEO pack and the is_static_front_page function
180
  if ( is_callable( array( "All_in_One_SEO_Pack", 'is_static_front_page' ) ) ) {
181
 
@@ -193,7 +191,6 @@ if ( is_callable( array( "All_in_One_SEO_Pack", 'is_static_front_page' ) ) ) {
193
  }
194
 
195
  add_filter( 'aioseop_home_page_title', 'wpsc_change_aioseop_home_title' );
196
- //add_filter('aioseop_title_page', 'wpsc_change_aioseop_home_title');
197
  }
198
 
199
  function wpsc_set_aioseop_description( $data ) {
@@ -236,7 +233,6 @@ add_filter( 'aioseop_keywords', 'wpsc_set_aioseop_keywords' );
236
  */
237
  function wpsc_populate_also_bought_list() {
238
  global $wpdb, $wpsc_cart, $wpsc_coupons;
239
- //exit("<pre>".print_r($variations,true)."</pre>");
240
  $new_also_bought_data = array( );
241
  foreach ( $wpsc_cart->cart_items as $outer_cart_item ) {
242
  $new_also_bought_data[$outer_cart_item->product_id] = array( );
@@ -273,7 +269,6 @@ function wpsc_populate_also_bought_list() {
273
  if ( count( $insert_statement_parts ) > 0 ) {
274
  $insert_statement = "INSERT INTO `" . WPSC_TABLE_ALSO_BOUGHT . "` (`selected_product`, `associated_product`, `quantity`) VALUES " . implode( ",\n ", $insert_statement_parts );
275
  $wpdb->query( $insert_statement );
276
- //echo $insert_statement;
277
  }
278
  }
279
 
@@ -338,8 +333,6 @@ function nzshpcrt_display_preview_image() {
338
  } else {
339
  $cache_filename = basename( "product_img_{$image_id}_{$height}x{$width}" );
340
  }
341
- //echo "<pre>".print_r($_GET, true)."</pre>";
342
- //exit($cache_filename);
343
  $imagetype = @getimagesize( $imagepath );
344
  $use_cache = false;
345
  switch ( $imagetype[2] ) {
@@ -373,19 +366,16 @@ function nzshpcrt_display_preview_image() {
373
  } else {
374
  switch ( $imagetype[2] ) {
375
  case IMAGETYPE_JPEG:
376
- //$extension = ".jpg";
377
  $src_img = imagecreatefromjpeg( $imagepath );
378
  $pass_imgtype = true;
379
  break;
380
 
381
  case IMAGETYPE_GIF:
382
- //$extension = ".gif";
383
  $src_img = imagecreatefromgif( $imagepath );
384
  $pass_imgtype = true;
385
  break;
386
 
387
  case IMAGETYPE_PNG:
388
- //$extension = ".png";
389
  $src_img = imagecreatefrompng( $imagepath );
390
  $pass_imgtype = true;
391
  break;
@@ -406,7 +396,6 @@ function nzshpcrt_display_preview_image() {
406
  // select our scaling method
407
  $scaling_method = 'cropping';
408
 
409
- //list($source_h, $source_w) = array($source_w, $source_h);
410
  // set both offsets to zero
411
  $offset_x = $offset_y = 0;
412
 
@@ -446,9 +435,6 @@ function nzshpcrt_display_preview_image() {
446
  $bgcolor = ImageColorAllocate( $dst_img, 255, 255, 255 );
447
  ImageFilledRectangle( $dst_img, 0, 0, $width, $height, $bgcolor );
448
  ImageAlphaBlending( $dst_img, TRUE );
449
- if ( ($imagetype[2] == IMAGETYPE_PNG) || ($imagetype[2] == IMAGETYPE_GIF) ) {
450
- //imagecolortransparent($dst_img, $bgcolor);
451
- }
452
 
453
  // X & Y Offset to crop image properly
454
  if ( $temp_w < $width ) {
@@ -708,7 +694,6 @@ function wp_set_product_categories( $product_id, $post_categories = array( ) ) {
708
  $product_id = (int)$product_id;
709
  // If $post_categories isn't already an array, make it one:
710
  if ( !is_array( $post_categories ) || 0 == count( $post_categories ) || empty( $post_categories ) ) {
711
- //$post_categories = array(get_option('default_category'));
712
  return;
713
  } else if ( 1 == count( $post_categories ) && '' == $post_categories[0] ) {
714
  return true;
156
  }
157
  }
158
  }
 
159
  return $url;
160
  }
161
 
174
  }
175
  }
176
 
 
177
  // check for all in one SEO pack and the is_static_front_page function
178
  if ( is_callable( array( "All_in_One_SEO_Pack", 'is_static_front_page' ) ) ) {
179
 
191
  }
192
 
193
  add_filter( 'aioseop_home_page_title', 'wpsc_change_aioseop_home_title' );
 
194
  }
195
 
196
  function wpsc_set_aioseop_description( $data ) {
233
  */
234
  function wpsc_populate_also_bought_list() {
235
  global $wpdb, $wpsc_cart, $wpsc_coupons;
 
236
  $new_also_bought_data = array( );
237
  foreach ( $wpsc_cart->cart_items as $outer_cart_item ) {
238
  $new_also_bought_data[$outer_cart_item->product_id] = array( );
269
  if ( count( $insert_statement_parts ) > 0 ) {
270
  $insert_statement = "INSERT INTO `" . WPSC_TABLE_ALSO_BOUGHT . "` (`selected_product`, `associated_product`, `quantity`) VALUES " . implode( ",\n ", $insert_statement_parts );
271
  $wpdb->query( $insert_statement );
 
272
  }
273
  }
274
 
333
  } else {
334
  $cache_filename = basename( "product_img_{$image_id}_{$height}x{$width}" );
335
  }
 
 
336
  $imagetype = @getimagesize( $imagepath );
337
  $use_cache = false;
338
  switch ( $imagetype[2] ) {
366
  } else {
367
  switch ( $imagetype[2] ) {
368
  case IMAGETYPE_JPEG:
 
369
  $src_img = imagecreatefromjpeg( $imagepath );
370
  $pass_imgtype = true;
371
  break;
372
 
373
  case IMAGETYPE_GIF:
 
374
  $src_img = imagecreatefromgif( $imagepath );
375
  $pass_imgtype = true;
376
  break;
377
 
378
  case IMAGETYPE_PNG:
 
379
  $src_img = imagecreatefrompng( $imagepath );
380
  $pass_imgtype = true;
381
  break;
396
  // select our scaling method
397
  $scaling_method = 'cropping';
398
 
 
399
  // set both offsets to zero
400
  $offset_x = $offset_y = 0;
401
 
435
  $bgcolor = ImageColorAllocate( $dst_img, 255, 255, 255 );
436
  ImageFilledRectangle( $dst_img, 0, 0, $width, $height, $bgcolor );
437
  ImageAlphaBlending( $dst_img, TRUE );
 
 
 
438
 
439
  // X & Y Offset to crop image properly
440
  if ( $temp_w < $width ) {
694
  $product_id = (int)$product_id;
695
  // If $post_categories isn't already an array, make it one:
696
  if ( !is_array( $post_categories ) || 0 == count( $post_categories ) || empty( $post_categories ) ) {
 
697
  return;
698
  } else if ( 1 == count( $post_categories ) && '' == $post_categories[0] ) {
699
  return true;
wpsc-includes/processing.functions.php CHANGED
@@ -139,25 +139,6 @@ function wpsc_get_currency_symbol(){
139
  return $wpsc_currency_data;
140
  }
141
 
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
  /**
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.
@@ -217,8 +198,6 @@ function wpsc_convert_weights($weight, $unit) {
217
  return $weight;
218
  }
219
 
220
-
221
-
222
  function wpsc_convert_weight($in_weight, $in_unit, $out_unit = 'gram') {
223
  if (isset($weight) && is_array($weight)) {
224
  $weight = $weight['weight'];
@@ -314,17 +293,43 @@ function wpsc_check_stock($state, $product) {
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);
319
- // only do anything if the quantity is limited.
320
- if(($stock_count === '0')) // otherwise, use the stock from the products list table
321
- $out_of_stock = true;
322
-
323
- if($out_of_stock === true) {
324
- $state['state'] = true;
325
- $state['messages'][] = __('This product has no available stock', 'wpsc');
326
- }
327
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  return array('state' => $state['state'], 'messages' => $state['messages']);
329
  }
330
 
@@ -381,12 +386,7 @@ add_filter('wpsc_product_alert', 'wpsc_check_weight', 10, 2);
381
  * @return (int) The image quality.
382
  */
383
  function wpsc_image_quality( $quality = 75 ) {
384
-
385
  $quality = apply_filters( 'jpeg_quality', $quality );
386
  return apply_filters( 'wpsc_jpeg_quality', $quality );
387
-
388
  }
389
-
390
-
391
-
392
  ?>
139
  return $wpsc_currency_data;
140
  }
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  /**
143
  * All the code below here needs commenting and looking at to see if it needs to be altered or disposed of.
144
  * 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.
198
  return $weight;
199
  }
200
 
 
 
201
  function wpsc_convert_weight($in_weight, $in_unit, $out_unit = 'gram') {
202
  if (isset($weight) && is_array($weight)) {
203
  $weight = $weight['weight'];
293
  $state['state'] = false;
294
  $state['messages'] = array();
295
  $out_of_stock = false;
296
+ $is_parent = wpsc_product_has_children($product->ID);
297
+ if(!$is_parent){
298
+ $stock_count = get_product_meta($product->ID, 'stock',true);
299
+ // only do anything if the quantity is limited.
300
+ if(($stock_count === '0')) // otherwise, use the stock from the products list table
301
+ $out_of_stock = true;
 
 
 
 
302
 
303
+ if($out_of_stock === true) {
304
+ $state['state'] = true;
305
+ $state['messages'][] = __('This product has no available stock', 'wpsc');
306
+ }
307
+ }else{
308
+ $no_stock = $wpdb->get_col('
309
+ SELECT
310
+ `pm`.`post_id`
311
+ FROM
312
+ `' . $wpdb->postmeta . '` `pm`
313
+ JOIN
314
+ `' . $wpdb->posts . '` `p`
315
+ ON
316
+ `pm`.`post_id` = `p`.`id`
317
+ WHERE
318
+ `p`.`post_type`= "wpsc-product"
319
+ AND
320
+ `p`.`post_parent` = ' . $product->ID . '
321
+ AND
322
+ `pm`.`meta_key` = "_wpsc_stock"
323
+ AND
324
+ `pm`.`meta_value` = "0"
325
+ ');
326
+ if(!empty($no_stock)){
327
+ $state['state'] = true;
328
+ $state['messages'][] = __('One or more of this products variations are out of stock.', 'wpsc');
329
+ }
330
+
331
+
332
+ }
333
  return array('state' => $state['state'], 'messages' => $state['messages']);
334
  }
335
 
386
  * @return (int) The image quality.
387
  */
388
  function wpsc_image_quality( $quality = 75 ) {
 
389
  $quality = apply_filters( 'jpeg_quality', $quality );
390
  return apply_filters( 'wpsc_jpeg_quality', $quality );
 
391
  }
 
 
 
392
  ?>
wpsc-includes/product-template.php CHANGED
@@ -162,8 +162,6 @@ function wpsc_pagination($totalpages = '', $per_page = '', $current_page = '', $
162
  }
163
  $count ++;
164
  }
165
-
166
-
167
  }
168
 
169
  if($current_page < $totalpages) {
@@ -221,7 +219,6 @@ function wpsc_product_image( $attachment_id = 0, $width = null, $height = null )
221
 
222
 
223
  $attachment_metadata = $image_meta['_wp_attachment_metadata'];
224
- //echo '<br style="clear:both" /><pre>'.print_r($image_meta,1).'</pre>';
225
  // Determine if we already have an image of this size
226
  if ( isset( $attachment_metadata['sizes'] ) && (count( $attachment_metadata['sizes'] ) > 0) && ( isset( $attachment_metadata['sizes'][$intermediate_size] ) ) ) {
227
  $intermediate_image_data = image_get_intermediate_size( $attachment_id, $intermediate_size );
@@ -344,8 +341,6 @@ function wpsc_calculate_price( $product_id, $variations = null, $special = true
344
  */
345
  function wpsc_display_categories() {
346
  global $wp_query;
347
-
348
- //_deprecated_function( __FUNCTION__, '3.8', 'the updated '.__FUNCTION__.'' );
349
  $output = false;
350
  if ( !is_numeric( get_option( 'wpsc_default_category' ) ) ) {
351
 
@@ -395,15 +390,12 @@ function wpsc_display_products() {
395
  * @return string - the URL of the current page
396
  */
397
  function wpsc_this_page_url() {
398
- //_deprecated_function( __FUNCTION__, '3.8', 'the updated '.__FUNCTION__.'' );
399
  global $wpsc_query, $wp_query;
400
- //echo "<pr".print_r($wpsc_query->category,true)."</pre>";
401
  if ( $wpsc_query->is_single === true ) {
402
  $output = wpsc_product_url( $wp_query->post->ID );
403
  } else if ( isset( $wpsc_query->category ) && $wpsc_query->category != null ) {
404
  $output = wpsc_category_url( $wpsc_query->category );
405
  if ( $wpsc_query->query_vars['page'] > 1 ) {
406
- //
407
  if ( get_option( 'permalink_structure' ) ) {
408
  $output .= "page/{$wpsc_query->query_vars['page']}/";
409
  } else {
@@ -424,7 +416,6 @@ function wpsc_this_page_url() {
424
  */
425
  function wpsc_is_single_product() {
426
  global $wp_query;
427
- //echo "<pre>".print_r($wpsc_query->is_single,true)."</pre>";
428
  if ( $wp_query->is_single === 1 )
429
  $state = true;
430
  else
@@ -438,7 +429,6 @@ function wpsc_is_single_product() {
438
  * @return string - the class of the selected category
439
  */
440
  function wpsc_category_class() {
441
- //_deprecated_function( __FUNCTION__, '3.8', 'the updated '.__FUNCTION__.'' );
442
  global $wpdb, $wp_query;
443
 
444
  $category_nice_name = '';
@@ -452,13 +442,11 @@ function wpsc_category_class() {
452
  }
453
 
454
  if ( (int)$catid > 0 ){
455
- //exit($catid);
456
  $term = get_term($catid, 'wpsc_product_category');
457
  $category_nice_name = $term->slug;
458
  }else if ( $catid == 'all' ){
459
  $category_nice_name = 'all-categories';
460
  }
461
- //exit("<pre>".print_r(get_option('wpsc_default_category'),true)."</pre>");
462
  return $category_nice_name;
463
  }
464
 
@@ -470,7 +458,7 @@ function wpsc_current_category_name() {
470
  global $wp_query;
471
  $term_data = get_term( $wp_query->post->term_id, 'wpsc_product_category' );
472
 
473
- return $term_data->name; //$wpsc_query->product['category'];
474
  }
475
 
476
  /**
@@ -730,7 +718,6 @@ function wpsc_check_variation_stock_availability( $product_id, $variations ) {
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
 
@@ -927,7 +914,6 @@ function wpsc_product_postage_and_packaging() {
927
  $id = get_the_ID();
928
 
929
  $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
930
- //echo "<pre>".print_r($product_meta, true)."</pre>";
931
  if ( is_array( $product_meta['shipping'] ) && 1 != $product_meta['no_shipping'])
932
  return wpsc_currency_display( $product_meta['shipping']['local'] );
933
  else
@@ -1135,8 +1121,6 @@ function wpsc_product_comment_link() {
1135
  * @return string - javascript for the intensedebate comments
1136
  */
1137
  function wpsc_product_comments() {
1138
- //Commenting out deprecated functions - they aren't used properly, they need to specify the function that should be used.
1139
- // _deprecated_function( __FUNCTION__, '3.8', 'the updated '.__FUNCTION__.'' );
1140
  global $wpsc_query;
1141
  $output = '';
1142
  // add the product comments
@@ -1298,7 +1282,6 @@ function wpsc_vargrp_id() {
1298
  */
1299
  function wpsc_the_variation_name() {
1300
  global $wpsc_variations;
1301
- //exit('<pre>'.print_r($wpsc_variations,1).'</pre>');
1302
  return stripslashes( $wpsc_variations->variation->name );
1303
  }
1304
 
@@ -1416,10 +1399,7 @@ function wpsc_product_new_rating( $product_id ) {
1416
  if ( $vote_id > 0 )
1417
  $previous_vote = $wpdb->get_var( "SELECT `rated` FROM `" . WPSC_TABLE_PRODUCT_RATING . "` WHERE `id`='" . $vote_id . "' LIMIT 1" );
1418
 
1419
- //print("<pre>".print_r($previous_vote, true)."</pre>");
1420
- //print("<pre>".print_r(func_get_args(), true)."</pre>");
1421
  $output = "<form class='wpsc_product_rating' method='post'>\n";
1422
- //$output .= " <input type='hidden' name='product_id' value='{$product_id}' />\n";
1423
  $output .= " <input type='hidden' name='wpsc_ajax_action' value='rate_product' />\n";
1424
  $output .= " <input type='hidden' class='wpsc_rating_product_id' name='product_id' value='{$product_id}' />\n";
1425
  $output .= " <select class='wpsc_select_product_rating' name='product_rating'>\n";
@@ -1452,7 +1432,6 @@ function wpsc_currency_sign() {
1452
  * @return boolean - true if we have pages
1453
  */
1454
  function wpsc_has_pages() {
1455
- // _deprecated_function( __FUNCTION__, '3.8', 'the updated '.__FUNCTION__.'' );
1456
  if(1 == get_option('use_pagination'))
1457
  return true;
1458
  else
@@ -1549,7 +1528,6 @@ function wpsc_the_variation_price( $return_as_numeric = false ) {
1549
  'post_type' => 'wpsc-product',
1550
  'post_parent' => $product_id );
1551
  $query = new WP_Query( $wpq );
1552
- // exit('<pre>'.print_r($query,true).'</pre>');
1553
  // Should never happen
1554
  if ( $query->post_count != 1 )
1555
  return false;
@@ -1558,8 +1536,6 @@ function wpsc_the_variation_price( $return_as_numeric = false ) {
1558
 
1559
  $price = get_product_meta( $variation_product_id, "price",true );
1560
  $special_price = get_product_meta( $variation_product_id, "special_price", true );
1561
- //exit($price .'<<<price');
1562
- // $price = $price[0];
1563
  if($special_price < $price && $special_price > 0)
1564
  $price = $special_price;
1565
  if ( !$return_as_numeric ) {
162
  }
163
  $count ++;
164
  }
 
 
165
  }
166
 
167
  if($current_page < $totalpages) {
219
 
220
 
221
  $attachment_metadata = $image_meta['_wp_attachment_metadata'];
 
222
  // Determine if we already have an image of this size
223
  if ( isset( $attachment_metadata['sizes'] ) && (count( $attachment_metadata['sizes'] ) > 0) && ( isset( $attachment_metadata['sizes'][$intermediate_size] ) ) ) {
224
  $intermediate_image_data = image_get_intermediate_size( $attachment_id, $intermediate_size );
341
  */
342
  function wpsc_display_categories() {
343
  global $wp_query;
 
 
344
  $output = false;
345
  if ( !is_numeric( get_option( 'wpsc_default_category' ) ) ) {
346
 
390
  * @return string - the URL of the current page
391
  */
392
  function wpsc_this_page_url() {
 
393
  global $wpsc_query, $wp_query;
 
394
  if ( $wpsc_query->is_single === true ) {
395
  $output = wpsc_product_url( $wp_query->post->ID );
396
  } else if ( isset( $wpsc_query->category ) && $wpsc_query->category != null ) {
397
  $output = wpsc_category_url( $wpsc_query->category );
398
  if ( $wpsc_query->query_vars['page'] > 1 ) {
 
399
  if ( get_option( 'permalink_structure' ) ) {
400
  $output .= "page/{$wpsc_query->query_vars['page']}/";
401
  } else {
416
  */
417
  function wpsc_is_single_product() {
418
  global $wp_query;
 
419
  if ( $wp_query->is_single === 1 )
420
  $state = true;
421
  else
429
  * @return string - the class of the selected category
430
  */
431
  function wpsc_category_class() {
 
432
  global $wpdb, $wp_query;
433
 
434
  $category_nice_name = '';
442
  }
443
 
444
  if ( (int)$catid > 0 ){
 
445
  $term = get_term($catid, 'wpsc_product_category');
446
  $category_nice_name = $term->slug;
447
  }else if ( $catid == 'all' ){
448
  $category_nice_name = 'all-categories';
449
  }
 
450
  return $category_nice_name;
451
  }
452
 
458
  global $wp_query;
459
  $term_data = get_term( $wp_query->post->term_id, 'wpsc_product_category' );
460
 
461
+ return $term_data->name;
462
  }
463
 
464
  /**
718
  }
719
 
720
  if ( wpsc_product_has_stock( $the_selected_product ) ) {
 
721
  $stock = get_product_meta( $the_selected_product, "stock", true );
722
  $stock = apply_filters( 'wpsc_product_variation_stock', $stock, $id );
723
 
914
  $id = get_the_ID();
915
 
916
  $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
 
917
  if ( is_array( $product_meta['shipping'] ) && 1 != $product_meta['no_shipping'])
918
  return wpsc_currency_display( $product_meta['shipping']['local'] );
919
  else
1121
  * @return string - javascript for the intensedebate comments
1122
  */
1123
  function wpsc_product_comments() {
 
 
1124
  global $wpsc_query;
1125
  $output = '';
1126
  // add the product comments
1282
  */
1283
  function wpsc_the_variation_name() {
1284
  global $wpsc_variations;
 
1285
  return stripslashes( $wpsc_variations->variation->name );
1286
  }
1287
 
1399
  if ( $vote_id > 0 )
1400
  $previous_vote = $wpdb->get_var( "SELECT `rated` FROM `" . WPSC_TABLE_PRODUCT_RATING . "` WHERE `id`='" . $vote_id . "' LIMIT 1" );
1401
 
 
 
1402
  $output = "<form class='wpsc_product_rating' method='post'>\n";
 
1403
  $output .= " <input type='hidden' name='wpsc_ajax_action' value='rate_product' />\n";
1404
  $output .= " <input type='hidden' class='wpsc_rating_product_id' name='product_id' value='{$product_id}' />\n";
1405
  $output .= " <select class='wpsc_select_product_rating' name='product_rating'>\n";
1432
  * @return boolean - true if we have pages
1433
  */
1434
  function wpsc_has_pages() {
 
1435
  if(1 == get_option('use_pagination'))
1436
  return true;
1437
  else
1528
  'post_type' => 'wpsc-product',
1529
  'post_parent' => $product_id );
1530
  $query = new WP_Query( $wpq );
 
1531
  // Should never happen
1532
  if ( $query->post_count != 1 )
1533
  return false;
1536
 
1537
  $price = get_product_meta( $variation_product_id, "price",true );
1538
  $special_price = get_product_meta( $variation_product_id, "special_price", true );
 
 
1539
  if($special_price < $price && $special_price > 0)
1540
  $price = $special_price;
1541
  if ( !$return_as_numeric ) {
wpsc-includes/productfeed.php CHANGED
@@ -75,8 +75,8 @@ function wpsc_generate_product_feed() {
75
  $output .= " <channel>\n\r";
76
  $output .= " <title><![CDATA[".get_option('blogname')." Products]]></title>\n\r";
77
  $output .= " <link>".get_option('siteurl')."/wp-admin/admin.php?page=".WPSC_DIR_NAME."/display-log.php</link>\n\r";
78
- $output .= " <description>This is the WP E-Commerce Product List RSS feed</description>\n\r";
79
- $output .= " <generator>WP E-Commerce Plugin</generator>\n\r";
80
  $output .= " <atom:link href='$self' rel='self' type='application/rss+xml' />\n\r";
81
 
82
  foreach ($products as $post) {
@@ -168,12 +168,7 @@ function wpsc_generate_product_feed() {
168
 
169
  $output .= " </channel>\n\r";
170
  $output .= "</rss>";
171
-
172
  echo $output;
173
-
174
  exit();
175
-
176
  }
177
-
178
-
179
- ?>
75
  $output .= " <channel>\n\r";
76
  $output .= " <title><![CDATA[".get_option('blogname')." Products]]></title>\n\r";
77
  $output .= " <link>".get_option('siteurl')."/wp-admin/admin.php?page=".WPSC_DIR_NAME."/display-log.php</link>\n\r";
78
+ $output .= " <description>This is the WP e-Commerce Product List RSS feed</description>\n\r";
79
+ $output .= " <generator>WP e-Commerce Plugin</generator>\n\r";
80
  $output .= " <atom:link href='$self' rel='self' type='application/rss+xml' />\n\r";
81
 
82
  foreach ($products as $post) {
168
 
169
  $output .= " </channel>\n\r";
170
  $output .= "</rss>";
 
171
  echo $output;
 
172
  exit();
 
173
  }
174
+ ?>
 
 
wpsc-includes/purchaselogs.class.php CHANGED
@@ -32,15 +32,12 @@ function wpsc_display_purchlog_display_howtheyfoundus() {
32
  return true;
33
  else
34
  return false;
35
-
36
- // exit('<pre>'.print_r($purchlogitem, true).'</pre>');
37
  }
38
 
39
  function wpsc_check_uniquenames() {
40
  global $wpdb;
41
  $sql = 'SELECT COUNT(`id`) FROM `' . WPSC_TABLE_CHECKOUT_FORMS . '` WHERE unique_name != "" ';
42
  $check_unique_names = $wpdb->get_var( $sql );
43
- // exit($check_unique_names);
44
  if ( $check_unique_names > 0 ) {
45
  return false;
46
  } else {
@@ -50,7 +47,6 @@ function wpsc_check_uniquenames() {
50
 
51
  function wpsc_purchlogs_has_tracking() {
52
  global $wpdb, $wpsc_shipping_modules, $purchlogitem;
53
- //exit('<pre>'.print_r($purchlogitem, true).'</pre>');
54
  $custom_shipping = get_option( 'custom_shipping_options' );
55
  if ( in_array( 'nzpost', (array)$custom_shipping ) && $purchlogitem->extrainfo->track_id != '' ) {
56
  return true;
@@ -79,21 +75,17 @@ function wpsc_purchlogitem_trackhistory() {
79
  $output = '<ul>';
80
  foreach ( (array)$_SESSION['wpsc_nzpost_parsed'][0]['children'][0]['children'][1]['children'] as $history ) {
81
  $outputs[] = '<li>' . $history['children'][0]['tagData'] . " : " . $history['children'][1]['tagData'] . " </li>";
82
- // exit('<pre>'.print_r($history,true).'</pre>');
83
  }
84
  $outputs = array_reverse( $outputs );
85
  foreach ( $outputs as $o ) {
86
  $output .= $o;
87
  }
88
  $output .='</ul>';
89
- // exit('<pre>'.print_r($_SESSION['wpsc_nzpost_parsed'][0]['children'][0]['children'][1]['children'],true).'</pre>');
90
- // exit('<pre>'.print_r($_SESSION['wpsc_nzpost_parsed'],true).'</pre>');
91
  return $output;
92
  }
93
 
94
  function wpsc_purchlogs_has_customfields( $id = '' ) {
95
  global $purchlogitem;
96
- //return true;
97
  if ( $id == '' ) {
98
  foreach ( (array)$purchlogitem->allcartcontent as $cartitem ) {
99
  if ( $cartitem->files != 'N;' || $cartitem->custom_message != '' ) {
@@ -116,16 +108,13 @@ function wpsc_purchlogs_has_customfields( $id = '' ) {
116
  function wpsc_trackingid_value() {
117
  global $purchlogs;
118
  return $purchlogs->purchitem->track_id;
119
- // exit('<pre>'.print_r($purchlogs, true).'</pre>');
120
  }
121
 
122
  function wpsc_purchlogs_custommessages() {
123
  global $purchlogitem;
124
  foreach ( $purchlogitem->allcartcontent as $cartitem ) {
125
  if ( $cartitem->custom_message != '' ) {
126
- //exit('<pre>'.print_r($cartitem,true).'</pre>');
127
  $messages[] = $cartitem->name . ' :<br />' . $cartitem->custom_message;
128
- //return true;
129
  }
130
  }
131
  return $messages;
@@ -134,7 +123,6 @@ function wpsc_purchlogs_custommessages() {
134
  function wpsc_purchlogs_customfiles() {
135
  global $purchlogitem;
136
  $files = array( );
137
- //exit('<pre>'.print_r($purchlogitem->allcartcontent,true).'</pre>');
138
  foreach ( $purchlogitem->allcartcontent as $cartitem ) {
139
  if ( $cartitem->files != 'N;' ) {
140
  $file = unserialize( $cartitem->files );
@@ -147,8 +135,6 @@ function wpsc_purchlogs_customfiles() {
147
  } else {
148
  $files[] = $cartitem->name . ' :<br />' . $file['file_name'];
149
  }
150
-
151
- //return true;
152
  }
153
  }
154
  return $files;
@@ -184,7 +170,6 @@ function wpsc_the_purch_item() {
184
 
185
  function wpsc_the_purch_item_price() {
186
  global $purchlogs;
187
- // exit('<pre>'.print_r($purchlogs->purchitem, true).'</pre>');
188
  if ( $purchlogs->purchitem->processed > 1 && $purchlogs->purchitem->processed != 5 ) {
189
  $purchlogs->totalAmount += $purchlogs->purchitem->totalprice;
190
  }
@@ -193,7 +178,6 @@ function wpsc_the_purch_item_price() {
193
 
194
  function wpsc_the_purch_item_id() {
195
  global $purchlogs;
196
- //exit('<pre>'.print_r($purchlogs->purchitem,true).'</pre>');
197
  return $purchlogs->purchitem->id;
198
  }
199
 
@@ -204,7 +188,6 @@ function wpsc_the_purch_item_date() {
204
 
205
  function wpsc_the_purch_item_name() {
206
  global $purchlogs;
207
- //exit('<pre>'.print_r($purchlogs->the_purch_item_name(), true).'</pre>');
208
  if ( wpsc_purchlogs_has_customfields( wpsc_the_purch_item_id() ) ) {
209
  return $purchlogs->the_purch_item_name() . '<img src="' . WPSC_CORE_IMAGES_URL . '/info_icon.jpg" title="This Purchase has custom user content" alt="exclamation icon" />';
210
  } else {
@@ -241,7 +224,6 @@ function wpsc_the_purch_item_status() {
241
 
242
  function wpsc_the_purch_status_id() {
243
  global $purchlogs;
244
- //exit(print_r($purchlogs->purchstatus));
245
  return $purchlogs->purchstatus['order'];
246
  }
247
 
@@ -253,7 +235,6 @@ function wpsc_is_checked_status() {
253
 
254
  function wpsc_the_purch_status_name() {
255
  global $purchlogs;
256
- //exit(print_r($purchlogs->purchstatus, true));
257
  if ( isset( $purchlogs->purchstatus['label'] ) ) {
258
  return $purchlogs->purchstatus['label'];
259
  }
@@ -272,13 +253,11 @@ function wpsc_purchlogs_getfirstdates() {
272
  }
273
  $fDate .= "<option value='{$value}' {$is_selected}>" . $cleanDate . "</option>";
274
  }
275
- // exit($i);
276
  return $fDate;
277
  }
278
 
279
  function wpsc_change_purchlog_view( $viewby, $status='' ) {
280
  global $purchlogs;
281
- // exit('<pre>'.print_r($status,true).'</pre>');
282
  if ( $viewby == 'all' ) {
283
  $dates = $purchlogs->getdates();
284
  $purchaselogs = $purchlogs->get_purchlogs( $dates, $status );
@@ -290,12 +269,9 @@ function wpsc_change_purchlog_view( $viewby, $status='' ) {
290
  $dates = array_slice( $dates, 0, 3 );
291
  $purchlogs->current_start_timestamp = $dates[2]['start'];
292
  $purchlogs->current_end_timestamp = $dates[0]['end'];
293
- // exit('<pre>'.print_r($dates,true).'</pre>');
294
  $newlogs = $purchlogs->get_purchlogs( $dates, $status );
295
  $_SESSION['newlogs'] = $newlogs;
296
- //exit('<pre>'.print_r($newlogs, true).'</pre>');
297
  $purchlogs->allpurchaselogs = $newlogs;
298
- //exit(print_r($date, true)."".$purchlogs->current_timestamp);
299
  } else {
300
 
301
  $dates = explode( '_', $viewby );
@@ -304,12 +280,9 @@ function wpsc_change_purchlog_view( $viewby, $status='' ) {
304
  $purchlogs->current_start_timestamp = $dates[0];
305
  $purchlogs->current_end_timestamp = $dates[1];
306
  $newlogs = $purchlogs->get_purchlogs( $date, $status );
307
- //exit('<pre>'.print_r($newlogs, true).'</pre>');
308
  $_SESSION['newlogs'] = $newlogs;
309
  $purchlogs->allpurchaselogs = $newlogs;
310
  }
311
-
312
- //exit('View by <pre>'.print_r($purchlogs,true).'</pre>');
313
  }
314
 
315
  function wpsc_search_purchlog_view( $search ) {
@@ -362,13 +335,11 @@ function wpsc_purchaselog_details_quantity() {
362
 
363
  function wpsc_purchaselog_details_price() {
364
  global $purchlogitem;
365
- // exit('<pre>'.print_r($purchlogitem->purchitem, true).'</pre>');
366
  return $purchlogitem->purchitem->price;
367
  }
368
 
369
  function wpsc_purchaselog_details_shipping() {
370
  global $purchlogitem;
371
- // exit('<pre>'.print_r($purchlogitem->purchitem, true).'</pre>');
372
  return $purchlogitem->purchitem->pnp;
373
  }
374
 
@@ -376,48 +347,15 @@ function wpsc_purchaselog_details_tax() {
376
  global $purchlogitem, $wpsc_cart;
377
 
378
  return $purchlogitem->purchitem->tax_charged;
379
- /* OLD CODE PRESERVED
380
- // exit('<pre>'.print_r($purchlogitem->purchitem, true).'</pre>');
381
- if(wpsc_tax_isincluded() == false){
382
- return wpsc_currency_display( $purchlogitem->purchitem->tax_charged, array( 'display_as_html' => false ) );
383
- }else{
384
- //exit('<pre>'.print_r($purchlogitem,true).'</pre>');
385
- if($purchlogitem->purchitem->notax == 0){
386
- if($purchlogitem->purchitem->price == null && $id != null){
387
- foreach((array)$purchlogitem->allcartcontent as $cartcontent){
388
- //exit('<pre>'.print_r($cartcontent, true).'</pre>');
389
- if(($cartcontent->prodid == $id) && ($cartcontent->notax == 1)){
390
- return '-';
391
- }
392
- }
393
- $price = $id;
394
- }else{
395
- $price = $purchlogitem->purchitem->price;
396
- }
397
- $tax = ($price/(100+$wpsc_cart->tax_percentage)*$wpsc_cart->tax_percentage);
398
- $tax = $wpsc_cart->process_as_currency($tax);
399
- return $tax.' ('.$wpsc_cart->tax_percentage.'%)';
400
- }else{
401
- // $tax = 0;
402
- return '-';
403
- }
404
-
405
-
406
- }
407
- */
408
  }
409
 
410
- // wpsc_purchaselog_details_tax
411
-
412
  function wpsc_purchaselog_details_discount() {
413
  global $purchlogitem;
414
- // exit('<pre>'.print_r($purchlogitem->extrainfo, true).'</pre>');
415
  return $purchlogitem->extrainfo->discount_value;
416
  }
417
 
418
  function wpsc_purchaselog_details_date() {
419
  global $purchlogitem;
420
- // exit('<pre>'.print_r($purchlogitem->extrainfo, true).'</pre>');
421
  return date( 'jS M Y', $purchlogitem->extrainfo->date );
422
  }
423
 
@@ -426,16 +364,12 @@ function wpsc_purchaselog_details_total() {
426
  $total = 0;
427
  $total += ( $purchlogitem->purchitem->price * $purchlogitem->purchitem->quantity);
428
  $total += ( $purchlogitem->purchitem->pnp * $purchlogitem->purchitem->quantity);
429
- //$total += wpsc_purchaselog_details_tax(); //do not calculate tax into total
430
- //$total += ($purchlogitem->purchitem->tax_charged * $purchlogitem->purchitem->quantity);
431
- //$total -= $purchlogitem->extrainfo->discount_value;
432
  $purchlogitem->totalAmount += $total;
433
  return $total;
434
  }
435
 
436
  function wpsc_purchaselog_details_purchnumber() {
437
  global $purchlogitem;
438
- //exit('<pre>'.print_r($purchlogitem->extrainfo, true).'</pre>');
439
  return $purchlogitem->extrainfo->id;
440
  }
441
 
@@ -509,7 +443,6 @@ function wpsc_display_purchlog_totalprice() {
509
  $purchlogitem->totalAmount -= wpsc_display_purchlog_discount( true );
510
  $purchlogitem->totalAmount += wpsc_display_purchlog_shipping( true );
511
  $purchlogitem->totalAmount += wpec_display_purchlog_taxes( true );
512
- //$purchlogitem->totalAmount += $purchlogitem->extrainfo->base_shipping;
513
  return wpsc_currency_display( $purchlogitem->totalAmount,array( 'display_as_html' => false ) );
514
  }
515
 
@@ -520,7 +453,6 @@ function wpsc_display_purchlog_buyers_name() {
520
 
521
  function wpsc_display_purchlog_buyers_email() {
522
  global $purchlogitem;
523
- //exit('<pre>'.print_r($purchlogitem->userinfo,true).'</pre>');
524
  return htmlentities( stripslashes( $purchlogitem->userinfo['billingemail']['value'] ), ENT_QUOTES );
525
  }
526
 
@@ -531,7 +463,6 @@ function wpsc_display_purchlog_buyers_address() {
531
 
532
  function wpsc_display_purchlog_buyers_phone() {
533
  global $purchlogitem;
534
- //exit('<pre>'.print_r($purchlogitem->userinfo,true).'</pre>');
535
  return htmlentities( stripslashes( $purchlogitem->userinfo['billingphone']['value'] ), ENT_QUOTES );
536
  }
537
 
@@ -542,23 +473,19 @@ function wpsc_display_purchlog_shipping_name() {
542
 
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() {
550
  global $purchlogitem;
551
- // exit('<pre>'.print_r($purchlogitem->shippinginfo,true).'</pre>');
552
  return htmlentities( stripslashes( $purchlogitem->shippinginfo['shippingcity']['value'] ), ENT_QUOTES );
553
  }
554
 
555
  function wpsc_display_purchlog_shipping_state_and_postcode() {
556
  global $purchlogitem;
557
- //exit('<pre>'.print_r($purchlogitem->shippinginfo,true).'</pre>');
558
  if ( !empty( $purchlogitem->shippinginfo['shippingstate']['value'] ) && !empty( $purchlogitem->shippinginfo['shippingpostcode']['value'] ) ) {
559
  return $purchlogitem->shippingstate( $purchlogitem->shippinginfo['shippingstate']['value'] ) . ', ' . $purchlogitem->shippinginfo['shippingpostcode']['value'];
560
  }
561
- //return $purchlogitem->shippinginfo['shippingstate']['value'].', '.$purchlogitem->shippinginfo['shippingpostcode']['value'];
562
  }
563
 
564
  function wpsc_display_purchlog_shipping_country() {
@@ -568,13 +495,11 @@ function wpsc_display_purchlog_shipping_country() {
568
 
569
  function wpsc_display_purchlog_shipping_method() {
570
  global $purchlogitem;
571
- // exit('<pre>'.print_r($purchlogitem->extrainfo, true).'</pre>');
572
  return $purchlogitem->extrainfo->shipping_method;
573
  }
574
 
575
  function wpsc_display_purchlog_shipping_option() {
576
  global $purchlogitem;
577
- // exit('<pre>'.print_r($purchlogitem->extrainfo, true).'</pre>');
578
  return $purchlogitem->extrainfo->shipping_option;
579
  }
580
 
@@ -597,7 +522,6 @@ function wpsc_display_purchlog_paymentmethod() {
597
 
598
  function wpsc_has_purchlog_shipping() {
599
  global $purchlogitem;
600
- //exit('<pre>'.print_r($purchlogitem, true).'</pre>');
601
  if ( $purchlogitem->shippinginfo['shippingfirstname']['value'] != '' ) {
602
  return true;
603
  } else {
@@ -607,14 +531,12 @@ function wpsc_has_purchlog_shipping() {
607
 
608
  function wpsc_purchlog_is_checked_status() {
609
  global $purchlogitem, $purchlogs;
610
- // exit('<pre>'.print_r($purchlogs->purchstatus['order'],true).'</pre>');
611
 
612
  if ( $purchlogs->purchstatus['order'] == $purchlogitem->extrainfo->processed ) {
613
  return 'selected="selected"';
614
  } else {
615
  return '';
616
  }
617
- // exit('<pre>'.print_r($purchlogitem,true).'</pre>');
618
  }
619
 
620
  function wpsc_purchlogs_have_downloads_locked() {
@@ -681,7 +603,6 @@ class wpsc_purchaselogs {
681
  $dates = $this->getdates();
682
  if ( isset( $_SESSION['newlogs'] ) ) {
683
  $purchaselogs = $_SESSION['newlogs'];
684
- //unset($_SESSION['newlogs']);
685
  } else {
686
  $firstDates[] = $dates[0];
687
  $purchaselogs = $this->get_purchlogs( $firstDates );
@@ -691,7 +612,6 @@ class wpsc_purchaselogs {
691
  } else {
692
  $this->getdates();
693
  if ( isset( $_GET['view_purchlogs_by'] ) && isset( $_GET['view_purchlogs_by_status'] ) ) {
694
- //exit('Sorted');
695
  $status = $_GET['view_purchlogs_by_status'];
696
  $viewby = $_GET['view_purchlogs_by'];
697
  if ( $viewby == 'all' ) {
@@ -705,12 +625,9 @@ class wpsc_purchaselogs {
705
  $dates = array_slice( $dates, 0, 3 );
706
  $this->current_start_timestamp = $dates[2]['start'];
707
  $this->current_end_timestamp = $dates[0]['end'];
708
- // exit('<pre>'.print_r($dates,true).'</pre>');
709
  $newlogs = $this->get_purchlogs( $dates, $status );
710
  $_SESSION['newlogs'] = $newlogs;
711
- //exit('<pre>'.print_r($newlogs, true).'</pre>');
712
  $this->allpurchaselogs = $newlogs;
713
- //exit(print_r($date, true)."".$this->current_timestamp);
714
  } else {
715
 
716
  $dates = explode( '_', $viewby );
@@ -719,7 +636,6 @@ class wpsc_purchaselogs {
719
  $this->current_start_timestamp = $dates[0];
720
  $this->current_end_timestamp = $dates[1];
721
  $newlogs = $this->get_purchlogs( $date, $status );
722
- //exit('<pre>'.print_r($newlogs, true).'</pre>');
723
  $_SESSION['newlogs'] = $newlogs;
724
  $this->allpurchaselogs = $newlogs;
725
  }
@@ -737,7 +653,6 @@ class wpsc_purchaselogs {
737
 
738
  function get_purchlogs( $dates, $status='' ) {
739
  global $wpdb;
740
- //echo "".print_r($dates, true)." $status";
741
  $purchlog2 = array( );
742
  if ( $status == '' || $status == '-1' ) {
743
  foreach ( (array)$dates as $date_pair ) {
@@ -751,7 +666,6 @@ class wpsc_purchaselogs {
751
  foreach ( (array)$dates as $date_pair ) {
752
  if ( ($date_pair['end'] >= $this->earliest_timestamp) && ($date_pair['start'] <= $this->current_timestamp) ) {
753
  $sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '" . $date_pair['start'] . "' AND '" . $date_pair['end'] . "' AND `processed`='" . $status . "' ORDER BY `date` DESC";
754
- //exit($sql);
755
  $purchase_logs = $wpdb->get_results( $sql );
756
  array_push( $purchlog2, $purchase_logs );
757
  }
@@ -768,7 +682,6 @@ class wpsc_purchaselogs {
768
  exit( 'Else :' . print_r( $purch ) );
769
  }
770
  }
771
- // exit('<pre>'.print_r($newarray,true).'<pre>');
772
  $this->allpurchaselogs = $newarray;
773
  $this->purch_item_count = count( $this->allpurchaselogs );
774
  return $newarray;
@@ -815,8 +728,6 @@ class wpsc_purchaselogs {
815
  $purchlogs->current_start_timestamp = $purchlogs->earliest_timestamp;
816
  $purchlogs->current_end_timestamp = $purchlogs->current_timestamp;
817
  }
818
- //exit('<pre>'.print_r($date_list, true).'<pre>');
819
-
820
  return $date_list;
821
  }
822
 
@@ -843,9 +754,7 @@ class wpsc_purchaselogs {
843
  }
844
 
845
  function the_purch_item() {
846
-
847
  $this->purchitem = $this->next_purch_item();
848
- //if ( $this->currentitem == 0 ) // loop has just started
849
  }
850
 
851
  function have_purch_items() {
@@ -881,7 +790,6 @@ class wpsc_purchaselogs {
881
 
882
  function the_purch_status() {
883
  $this->purchstatus = $this->next_purch_status();
884
- //if ( $this->currentitem == 0 ) // loop has just started
885
  }
886
 
887
  function have_purch_status() {
@@ -909,14 +817,6 @@ class wpsc_purchaselogs {
909
  }
910
  }
911
 
912
- /*
913
- function the_purch_item_status(){
914
- //exit('Purchlog status'.$this->purchitem->processed);
915
- return $this->purchitem->processed;
916
- }
917
-
918
- */
919
-
920
  function the_purch_item_name() {
921
  global $wpdb;
922
  $i = 0;
@@ -936,26 +836,17 @@ class wpsc_purchaselogs {
936
  $i++;
937
  }
938
 
939
- //$values = array();
940
  $sql = "SELECT value FROM " . WPSC_TABLE_SUBMITED_FORM_DATA . " WHERE log_id=" . $this->purchitem->id . " AND form_id=" . $emailformid;
941
  $email = $wpdb->get_var( $sql );
942
  $sql = "SELECT value FROM " . WPSC_TABLE_SUBMITED_FORM_DATA . " WHERE log_id=" . $this->purchitem->id . " AND form_id=" . $fNameformid;
943
  $fname = $wpdb->get_var( $sql );
944
- if ( !$fname ) {
945
- // exit($sql);
946
- }
947
  $sql = "SELECT value FROM " . WPSC_TABLE_SUBMITED_FORM_DATA . " WHERE log_id=" . $this->purchitem->id . " AND form_id=" . $lNameformid;
948
  $lname = $wpdb->get_var( $sql );
949
  $namestring = $fname . ' ' . $lname . ' (<a href="mailto:' . $email . '?subject=Message From ' . get_option( 'siteurl' ) . '">' . $email . '</a>) ';
950
  if ( $fname == '' && $lname == '' && $email == '' ) {
951
  $namestring = 'N/A';
952
  }
953
- //exit($fname.' '.$lname.' ('.$email.') ');
954
  return $namestring;
955
- /*
956
-
957
- exit('<pre>'.print_r($this->form_data, true).'</pre>');
958
- */
959
  }
960
 
961
  function the_purch_item_details() {
@@ -1013,19 +904,14 @@ class wpsc_purchaselogs_items {
1013
 
1014
  $cartcontent = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $this->purchlogid . "" );
1015
 
1016
-
1017
- //echo $cartsql;
1018
  $this->allcartcontent = $cartcontent;
1019
- //exit('<pre>'.print_r($cartcontent, true).'</pre>');
1020
  $sql = "SELECT DISTINCT `" . WPSC_TABLE_PURCHASE_LOGS . "` . * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` LEFT JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` ON `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`log_id` = `" . WPSC_TABLE_PURCHASE_LOGS . "`.`id` WHERE `" . WPSC_TABLE_PURCHASE_LOGS . "`.`id`=" . $this->purchlogid;
1021
  $extrainfo = $wpdb->get_results( $sql );
1022
 
1023
  $this->extrainfo = $extrainfo[0];
1024
 
1025
  $usersql = "SELECT `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`value`, `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`name`, `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`unique_name` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` LEFT JOIN `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` ON `" . WPSC_TABLE_CHECKOUT_FORMS . "`.id = `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`form_id` WHERE `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`log_id`=" . $this->purchlogid . " ORDER BY `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`order`";
1026
- //exit($usersql);
1027
  $userinfo = $wpdb->get_results( $usersql, ARRAY_A );
1028
- //exit('<pre>'.print_r($userinfo, true).'</pre>');
1029
  foreach ( (array)$userinfo as $input_row ) {
1030
  if ( stristr( $input_row['unique_name'], 'shipping' ) ) {
1031
  $shippinginfo[$input_row['unique_name']] = $input_row;
@@ -1041,7 +927,6 @@ class wpsc_purchaselogs_items {
1041
  $this->customcheckoutfields = $additionaldetails;
1042
  }
1043
  $this->purch_item_count = count( $cartcontent );
1044
- // exit('<pre>'.print_r($cartcontent, true).'</pre>');
1045
  }
1046
 
1047
  function next_purch_item() {
@@ -1052,7 +937,6 @@ class wpsc_purchaselogs_items {
1052
 
1053
  function the_purch_item() {
1054
  $this->purchitem = $this->next_purch_item();
1055
- //if ( $this->currentitem == 0 ) // loop has just started
1056
  }
1057
 
1058
  function have_purch_item() {
32
  return true;
33
  else
34
  return false;
 
 
35
  }
36
 
37
  function wpsc_check_uniquenames() {
38
  global $wpdb;
39
  $sql = 'SELECT COUNT(`id`) FROM `' . WPSC_TABLE_CHECKOUT_FORMS . '` WHERE unique_name != "" ';
40
  $check_unique_names = $wpdb->get_var( $sql );
 
41
  if ( $check_unique_names > 0 ) {
42
  return false;
43
  } else {
47
 
48
  function wpsc_purchlogs_has_tracking() {
49
  global $wpdb, $wpsc_shipping_modules, $purchlogitem;
 
50
  $custom_shipping = get_option( 'custom_shipping_options' );
51
  if ( in_array( 'nzpost', (array)$custom_shipping ) && $purchlogitem->extrainfo->track_id != '' ) {
52
  return true;
75
  $output = '<ul>';
76
  foreach ( (array)$_SESSION['wpsc_nzpost_parsed'][0]['children'][0]['children'][1]['children'] as $history ) {
77
  $outputs[] = '<li>' . $history['children'][0]['tagData'] . " : " . $history['children'][1]['tagData'] . " </li>";
 
78
  }
79
  $outputs = array_reverse( $outputs );
80
  foreach ( $outputs as $o ) {
81
  $output .= $o;
82
  }
83
  $output .='</ul>';
 
 
84
  return $output;
85
  }
86
 
87
  function wpsc_purchlogs_has_customfields( $id = '' ) {
88
  global $purchlogitem;
 
89
  if ( $id == '' ) {
90
  foreach ( (array)$purchlogitem->allcartcontent as $cartitem ) {
91
  if ( $cartitem->files != 'N;' || $cartitem->custom_message != '' ) {
108
  function wpsc_trackingid_value() {
109
  global $purchlogs;
110
  return $purchlogs->purchitem->track_id;
 
111
  }
112
 
113
  function wpsc_purchlogs_custommessages() {
114
  global $purchlogitem;
115
  foreach ( $purchlogitem->allcartcontent as $cartitem ) {
116
  if ( $cartitem->custom_message != '' ) {
 
117
  $messages[] = $cartitem->name . ' :<br />' . $cartitem->custom_message;
 
118
  }
119
  }
120
  return $messages;
123
  function wpsc_purchlogs_customfiles() {
124
  global $purchlogitem;
125
  $files = array( );
 
126
  foreach ( $purchlogitem->allcartcontent as $cartitem ) {
127
  if ( $cartitem->files != 'N;' ) {
128
  $file = unserialize( $cartitem->files );
135
  } else {
136
  $files[] = $cartitem->name . ' :<br />' . $file['file_name'];
137
  }
 
 
138
  }
139
  }
140
  return $files;
170
 
171
  function wpsc_the_purch_item_price() {
172
  global $purchlogs;
 
173
  if ( $purchlogs->purchitem->processed > 1 && $purchlogs->purchitem->processed != 5 ) {
174
  $purchlogs->totalAmount += $purchlogs->purchitem->totalprice;
175
  }
178
 
179
  function wpsc_the_purch_item_id() {
180
  global $purchlogs;
 
181
  return $purchlogs->purchitem->id;
182
  }
183
 
188
 
189
  function wpsc_the_purch_item_name() {
190
  global $purchlogs;
 
191
  if ( wpsc_purchlogs_has_customfields( wpsc_the_purch_item_id() ) ) {
192
  return $purchlogs->the_purch_item_name() . '<img src="' . WPSC_CORE_IMAGES_URL . '/info_icon.jpg" title="This Purchase has custom user content" alt="exclamation icon" />';
193
  } else {
224
 
225
  function wpsc_the_purch_status_id() {
226
  global $purchlogs;
 
227
  return $purchlogs->purchstatus['order'];
228
  }
229
 
235
 
236
  function wpsc_the_purch_status_name() {
237
  global $purchlogs;
 
238
  if ( isset( $purchlogs->purchstatus['label'] ) ) {
239
  return $purchlogs->purchstatus['label'];
240
  }
253
  }
254
  $fDate .= "<option value='{$value}' {$is_selected}>" . $cleanDate . "</option>";
255
  }
 
256
  return $fDate;
257
  }
258
 
259
  function wpsc_change_purchlog_view( $viewby, $status='' ) {
260
  global $purchlogs;
 
261
  if ( $viewby == 'all' ) {
262
  $dates = $purchlogs->getdates();
263
  $purchaselogs = $purchlogs->get_purchlogs( $dates, $status );
269
  $dates = array_slice( $dates, 0, 3 );
270
  $purchlogs->current_start_timestamp = $dates[2]['start'];
271
  $purchlogs->current_end_timestamp = $dates[0]['end'];
 
272
  $newlogs = $purchlogs->get_purchlogs( $dates, $status );
273
  $_SESSION['newlogs'] = $newlogs;
 
274
  $purchlogs->allpurchaselogs = $newlogs;
 
275
  } else {
276
 
277
  $dates = explode( '_', $viewby );
280
  $purchlogs->current_start_timestamp = $dates[0];
281
  $purchlogs->current_end_timestamp = $dates[1];
282
  $newlogs = $purchlogs->get_purchlogs( $date, $status );
 
283
  $_SESSION['newlogs'] = $newlogs;
284
  $purchlogs->allpurchaselogs = $newlogs;
285
  }
 
 
286
  }
287
 
288
  function wpsc_search_purchlog_view( $search ) {
335
 
336
  function wpsc_purchaselog_details_price() {
337
  global $purchlogitem;
 
338
  return $purchlogitem->purchitem->price;
339
  }
340
 
341
  function wpsc_purchaselog_details_shipping() {
342
  global $purchlogitem;
 
343
  return $purchlogitem->purchitem->pnp;
344
  }
345
 
347
  global $purchlogitem, $wpsc_cart;
348
 
349
  return $purchlogitem->purchitem->tax_charged;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  }
351
 
 
 
352
  function wpsc_purchaselog_details_discount() {
353
  global $purchlogitem;
 
354
  return $purchlogitem->extrainfo->discount_value;
355
  }
356
 
357
  function wpsc_purchaselog_details_date() {
358
  global $purchlogitem;
 
359
  return date( 'jS M Y', $purchlogitem->extrainfo->date );
360
  }
361
 
364
  $total = 0;
365
  $total += ( $purchlogitem->purchitem->price * $purchlogitem->purchitem->quantity);
366
  $total += ( $purchlogitem->purchitem->pnp * $purchlogitem->purchitem->quantity);
 
 
 
367
  $purchlogitem->totalAmount += $total;
368
  return $total;
369
  }
370
 
371
  function wpsc_purchaselog_details_purchnumber() {
372
  global $purchlogitem;
 
373
  return $purchlogitem->extrainfo->id;
374
  }
375
 
443
  $purchlogitem->totalAmount -= wpsc_display_purchlog_discount( true );
444
  $purchlogitem->totalAmount += wpsc_display_purchlog_shipping( true );
445
  $purchlogitem->totalAmount += wpec_display_purchlog_taxes( true );
 
446
  return wpsc_currency_display( $purchlogitem->totalAmount,array( 'display_as_html' => false ) );
447
  }
448
 
453
 
454
  function wpsc_display_purchlog_buyers_email() {
455
  global $purchlogitem;
 
456
  return htmlentities( stripslashes( $purchlogitem->userinfo['billingemail']['value'] ), ENT_QUOTES );
457
  }
458
 
463
 
464
  function wpsc_display_purchlog_buyers_phone() {
465
  global $purchlogitem;
 
466
  return htmlentities( stripslashes( $purchlogitem->userinfo['billingphone']['value'] ), ENT_QUOTES );
467
  }
468
 
473
 
474
  function wpsc_display_purchlog_shipping_address() {
475
  global $purchlogitem;
 
476
  return nl2br(trim(htmlentities( stripslashes( $purchlogitem->shippinginfo['shippingaddress']['value'] ), ENT_QUOTES ), "\n\r"));
477
  }
478
 
479
  function wpsc_display_purchlog_shipping_city() {
480
  global $purchlogitem;
 
481
  return htmlentities( stripslashes( $purchlogitem->shippinginfo['shippingcity']['value'] ), ENT_QUOTES );
482
  }
483
 
484
  function wpsc_display_purchlog_shipping_state_and_postcode() {
485
  global $purchlogitem;
 
486
  if ( !empty( $purchlogitem->shippinginfo['shippingstate']['value'] ) && !empty( $purchlogitem->shippinginfo['shippingpostcode']['value'] ) ) {
487
  return $purchlogitem->shippingstate( $purchlogitem->shippinginfo['shippingstate']['value'] ) . ', ' . $purchlogitem->shippinginfo['shippingpostcode']['value'];
488
  }
 
489
  }
490
 
491
  function wpsc_display_purchlog_shipping_country() {
495
 
496
  function wpsc_display_purchlog_shipping_method() {
497
  global $purchlogitem;
 
498
  return $purchlogitem->extrainfo->shipping_method;
499
  }
500
 
501
  function wpsc_display_purchlog_shipping_option() {
502
  global $purchlogitem;
 
503
  return $purchlogitem->extrainfo->shipping_option;
504
  }
505
 
522
 
523
  function wpsc_has_purchlog_shipping() {
524
  global $purchlogitem;
 
525
  if ( $purchlogitem->shippinginfo['shippingfirstname']['value'] != '' ) {
526
  return true;
527
  } else {
531
 
532
  function wpsc_purchlog_is_checked_status() {
533
  global $purchlogitem, $purchlogs;
 
534
 
535
  if ( $purchlogs->purchstatus['order'] == $purchlogitem->extrainfo->processed ) {
536
  return 'selected="selected"';
537
  } else {
538
  return '';
539
  }
 
540
  }
541
 
542
  function wpsc_purchlogs_have_downloads_locked() {
603
  $dates = $this->getdates();
604
  if ( isset( $_SESSION['newlogs'] ) ) {
605
  $purchaselogs = $_SESSION['newlogs'];
 
606
  } else {
607
  $firstDates[] = $dates[0];
608
  $purchaselogs = $this->get_purchlogs( $firstDates );
612
  } else {
613
  $this->getdates();
614
  if ( isset( $_GET['view_purchlogs_by'] ) && isset( $_GET['view_purchlogs_by_status'] ) ) {
 
615
  $status = $_GET['view_purchlogs_by_status'];
616
  $viewby = $_GET['view_purchlogs_by'];
617
  if ( $viewby == 'all' ) {
625
  $dates = array_slice( $dates, 0, 3 );
626
  $this->current_start_timestamp = $dates[2]['start'];
627
  $this->current_end_timestamp = $dates[0]['end'];
 
628
  $newlogs = $this->get_purchlogs( $dates, $status );
629
  $_SESSION['newlogs'] = $newlogs;
 
630
  $this->allpurchaselogs = $newlogs;
 
631
  } else {
632
 
633
  $dates = explode( '_', $viewby );
636
  $this->current_start_timestamp = $dates[0];
637
  $this->current_end_timestamp = $dates[1];
638
  $newlogs = $this->get_purchlogs( $date, $status );
 
639
  $_SESSION['newlogs'] = $newlogs;
640
  $this->allpurchaselogs = $newlogs;
641
  }
653
 
654
  function get_purchlogs( $dates, $status='' ) {
655
  global $wpdb;
 
656
  $purchlog2 = array( );
657
  if ( $status == '' || $status == '-1' ) {
658
  foreach ( (array)$dates as $date_pair ) {
666
  foreach ( (array)$dates as $date_pair ) {
667
  if ( ($date_pair['end'] >= $this->earliest_timestamp) && ($date_pair['start'] <= $this->current_timestamp) ) {
668
  $sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '" . $date_pair['start'] . "' AND '" . $date_pair['end'] . "' AND `processed`='" . $status . "' ORDER BY `date` DESC";
 
669
  $purchase_logs = $wpdb->get_results( $sql );
670
  array_push( $purchlog2, $purchase_logs );
671
  }
682
  exit( 'Else :' . print_r( $purch ) );
683
  }
684
  }
 
685
  $this->allpurchaselogs = $newarray;
686
  $this->purch_item_count = count( $this->allpurchaselogs );
687
  return $newarray;
728
  $purchlogs->current_start_timestamp = $purchlogs->earliest_timestamp;
729
  $purchlogs->current_end_timestamp = $purchlogs->current_timestamp;
730
  }
 
 
731
  return $date_list;
732
  }
733
 
754
  }
755
 
756
  function the_purch_item() {
 
757
  $this->purchitem = $this->next_purch_item();
 
758
  }
759
 
760
  function have_purch_items() {
790
 
791
  function the_purch_status() {
792
  $this->purchstatus = $this->next_purch_status();
 
793
  }
794
 
795
  function have_purch_status() {
817
  }
818
  }
819
 
 
 
 
 
 
 
 
 
820
  function the_purch_item_name() {
821
  global $wpdb;
822
  $i = 0;
836
  $i++;
837
  }
838
 
 
839
  $sql = "SELECT value FROM " . WPSC_TABLE_SUBMITED_FORM_DATA . " WHERE log_id=" . $this->purchitem->id . " AND form_id=" . $emailformid;
840
  $email = $wpdb->get_var( $sql );
841
  $sql = "SELECT value FROM " . WPSC_TABLE_SUBMITED_FORM_DATA . " WHERE log_id=" . $this->purchitem->id . " AND form_id=" . $fNameformid;
842
  $fname = $wpdb->get_var( $sql );
 
 
 
843
  $sql = "SELECT value FROM " . WPSC_TABLE_SUBMITED_FORM_DATA . " WHERE log_id=" . $this->purchitem->id . " AND form_id=" . $lNameformid;
844
  $lname = $wpdb->get_var( $sql );
845
  $namestring = $fname . ' ' . $lname . ' (<a href="mailto:' . $email . '?subject=Message From ' . get_option( 'siteurl' ) . '">' . $email . '</a>) ';
846
  if ( $fname == '' && $lname == '' && $email == '' ) {
847
  $namestring = 'N/A';
848
  }
 
849
  return $namestring;
 
 
 
 
850
  }
851
 
852
  function the_purch_item_details() {
904
 
905
  $cartcontent = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $this->purchlogid . "" );
906
 
 
 
907
  $this->allcartcontent = $cartcontent;
 
908
  $sql = "SELECT DISTINCT `" . WPSC_TABLE_PURCHASE_LOGS . "` . * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` LEFT JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` ON `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`log_id` = `" . WPSC_TABLE_PURCHASE_LOGS . "`.`id` WHERE `" . WPSC_TABLE_PURCHASE_LOGS . "`.`id`=" . $this->purchlogid;
909
  $extrainfo = $wpdb->get_results( $sql );
910
 
911
  $this->extrainfo = $extrainfo[0];
912
 
913
  $usersql = "SELECT `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`value`, `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`name`, `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`unique_name` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` LEFT JOIN `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` ON `" . WPSC_TABLE_CHECKOUT_FORMS . "`.id = `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`form_id` WHERE `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`log_id`=" . $this->purchlogid . " ORDER BY `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`order`";
 
914
  $userinfo = $wpdb->get_results( $usersql, ARRAY_A );
 
915
  foreach ( (array)$userinfo as $input_row ) {
916
  if ( stristr( $input_row['unique_name'], 'shipping' ) ) {
917
  $shippinginfo[$input_row['unique_name']] = $input_row;
927
  $this->customcheckoutfields = $additionaldetails;
928
  }
929
  $this->purch_item_count = count( $cartcontent );
 
930
  }
931
 
932
  function next_purch_item() {
937
 
938
  function the_purch_item() {
939
  $this->purchitem = $this->next_purch_item();
 
940
  }
941
 
942
  function have_purch_item() {
wpsc-includes/rss_template.php CHANGED
@@ -13,7 +13,6 @@
13
  <description><![CDATA[<?php echo wpsc_category_description(); ?>]]></description>
14
  <pubDate><![CDATA[<?php echo wpsc_product_creation_time('D, d M Y H:i:s +0000'); ?>]]></pubDate>
15
  <guid><![CDATA[<?php echo wpsc_the_product_permalink(); ?>]]></guid>
16
- <?php //<enclosure url='image url' length='".filesize($image_path)."' type='".$image_data['mime']."' width='".$image_data[0]."' height='".$image_data[1]."' /> ?>
17
  <g:price><![CDATA[<?php echo wpsc_product_normal_price(); ?>]]></g:price>
18
  <g:image_link><![CDATA[<?php echo wpsc_the_product_thumbnail(); ?>]]></g:image_link>
19
  </item>
13
  <description><![CDATA[<?php echo wpsc_category_description(); ?>]]></description>
14
  <pubDate><![CDATA[<?php echo wpsc_product_creation_time('D, d M Y H:i:s +0000'); ?>]]></pubDate>
15
  <guid><![CDATA[<?php echo wpsc_the_product_permalink(); ?>]]></guid>
 
16
  <g:price><![CDATA[<?php echo wpsc_product_normal_price(); ?>]]></g:price>
17
  <g:image_link><![CDATA[<?php echo wpsc_the_product_thumbnail(); ?>]]></g:image_link>
18
  </item>
wpsc-includes/share-this.php CHANGED
@@ -110,10 +110,6 @@ $social_sites = array(
110
  @define('AK_WPROOT', '../../../');
111
  @define('wpsc_akst_FILEPATH', WPSC_URL.'/wpsc-includes/share-this.php');
112
 
113
- // if (function_exists('load_plugin_textdomain')) {
114
- // load_plugin_textdomain('wpsc');
115
- // }
116
-
117
  $wpsc_akst_action = '';
118
 
119
  if (!function_exists('ak_check_email_address')) {
@@ -440,12 +436,10 @@ function wpsc_akst_share_link($action = 'print') {
440
  } else {
441
  $product_link = get_permalink(absint($_REQUEST['product_id']));
442
  }
443
- // exit("<pre>".print_r($product_link,true)."</pre>");
444
  $onclick = 'onclick="wpsc_akst_share(\''.$post->ID.'\', \''.urlencode($product_link).'\', \''.urlencode(get_the_title()).'\'); return false;"';
445
  }
446
  global $post;
447
  ob_start();
448
- /*<?php bloginfo('siteurl'); ?>/?p=<?php print($post->ID); ?>&amp;wpsc_akst_action=share-this */
449
  ?>
450
  <a href="#" <?php print($onclick); ?> title="<?php _e('E-mail this, post to del.icio.us, etc.', 'wpsc'); ?>" id="wpsc_akst_link_<?php print($post->ID); ?>" class="wpsc_akst_share_link" rel="nofollow"><img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/social_networking/share-this-product.gif' title='Share This' alt='Share This' /></a>
451
  <?php
@@ -474,8 +468,6 @@ function wpsc_akst_add_share_link_to_content($content) {
474
  }
475
  return $content;
476
  }
477
- //add_action('the_content', 'wpsc_akst_add_share_link_to_content');
478
- //add_action('the_content_rss', 'wpsc_akst_add_share_link_to_content');
479
 
480
  function wpsc_akst_share_form() {
481
  global $post, $social_sites, $current_user, $wp_query, $wpdb;
@@ -563,7 +555,6 @@ if (wpsc_akst_ADDTOFOOTER) {
563
 
564
  function wpsc_akst_send_mail() {
565
  global $wpdb, $wp_query;
566
- //exit("<pre>".print_r($_REQUEST,true)."</pre>");
567
  $post_id = '';
568
  $to = '';
569
  $name = '';
@@ -622,7 +613,6 @@ function wpsc_akst_send_mail() {
622
  wp_die(__('Click your <strong>back button</strong> and make sure those e-mail addresses are valid then try again.', 'wpsc'));
623
  }
624
 
625
- // $post = &get_post($post_id);
626
  $headers = "MIME-Version: 1.0\n" .
627
  'From: "'.$name.'" <'.$email.'>'."\n"
628
  .'Reply-To: "'.$name.'" <'.$email.'>'."\n"
@@ -636,7 +626,6 @@ function wpsc_akst_send_mail() {
636
  $permalink = get_option('product_list_url');
637
  $message .= __('Greetings--', 'wpsc')."\n\n";
638
  $message .= $name.__(' thinks this will be of interest to you:', 'wpsc')."\n\n";
639
- //$message .= ak_decode_entities(get_the_title($post_id))."\n\n";
640
  if($wp_query->query_vars['product_url_name'] != '') {
641
  $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 `product_id` DESC LIMIT 1");
642
  $message .= get_permalink($product_id);
110
  @define('AK_WPROOT', '../../../');
111
  @define('wpsc_akst_FILEPATH', WPSC_URL.'/wpsc-includes/share-this.php');
112
 
 
 
 
 
113
  $wpsc_akst_action = '';
114
 
115
  if (!function_exists('ak_check_email_address')) {
436
  } else {
437
  $product_link = get_permalink(absint($_REQUEST['product_id']));
438
  }
 
439
  $onclick = 'onclick="wpsc_akst_share(\''.$post->ID.'\', \''.urlencode($product_link).'\', \''.urlencode(get_the_title()).'\'); return false;"';
440
  }
441
  global $post;
442
  ob_start();
 
443
  ?>
444
  <a href="#" <?php print($onclick); ?> title="<?php _e('E-mail this, post to del.icio.us, etc.', 'wpsc'); ?>" id="wpsc_akst_link_<?php print($post->ID); ?>" class="wpsc_akst_share_link" rel="nofollow"><img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/social_networking/share-this-product.gif' title='Share This' alt='Share This' /></a>
445
  <?php
468
  }
469
  return $content;
470
  }
 
 
471
 
472
  function wpsc_akst_share_form() {
473
  global $post, $social_sites, $current_user, $wp_query, $wpdb;
555
 
556
  function wpsc_akst_send_mail() {
557
  global $wpdb, $wp_query;
 
558
  $post_id = '';
559
  $to = '';
560
  $name = '';
613
  wp_die(__('Click your <strong>back button</strong> and make sure those e-mail addresses are valid then try again.', 'wpsc'));
614
  }
615
 
 
616
  $headers = "MIME-Version: 1.0\n" .
617
  'From: "'.$name.'" <'.$email.'>'."\n"
618
  .'Reply-To: "'.$name.'" <'.$email.'>'."\n"
626
  $permalink = get_option('product_list_url');
627
  $message .= __('Greetings--', 'wpsc')."\n\n";
628
  $message .= $name.__(' thinks this will be of interest to you:', 'wpsc')."\n\n";
 
629
  if($wp_query->query_vars['product_url_name'] != '') {
630
  $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 `product_id` DESC LIMIT 1");
631
  $message .= get_permalink($product_id);
wpsc-includes/shopping_cart_functions.php CHANGED
@@ -40,7 +40,6 @@ function wpsc_shopping_cart( $input = null, $override_state = null ) {
40
  $cart = $_SESSION['nzshpcrt_cart'];
41
  }
42
  if ( $state == 4 ) {
43
- #echo $input;
44
  echo "<div id='widgetshoppingcart'>";
45
  echo "<h3>" . __( 'Shopping Cart' ) . "$fancy_collapser</h3>";
46
  echo " <div id='shoppingcartcontents'>";
@@ -142,7 +141,6 @@ function wpsc_country_region_list( $form_id = null, $ajax = false, $selected_cou
142
 
143
  if ( $checkoutfields ) {
144
  $namevalue = "name='collected_data[" . $region_form_id . "]'";
145
- // $namevalue = "name='collected_data[".$form_id."][1]'";
146
  $js = "onchange='set_shipping_country(\"$html_form_id\", \"$form_id\");'";
147
  $title = 'shippingstate';
148
  } else {
@@ -151,11 +149,9 @@ function wpsc_country_region_list( $form_id = null, $ajax = false, $selected_cou
151
  $title = 'billingstate';
152
  }
153
 
154
- // exit('Not here? >'.$region_form_id.' ' .$sql);
155
  $output .= "<div id='region_select_$form_id'>";
156
  if ( $region_list != null ) {
157
  $output .= "<select title='$title' " . $namevalue . " class='current_region' " . $js . ">\n\r";
158
- //$output .= "<option value=''>None</option>";
159
  foreach ( $region_list as $region ) {
160
  if ( $selected_region == $region['id'] ) {
161
  $selected = "selected='selected'";
40
  $cart = $_SESSION['nzshpcrt_cart'];
41
  }
42
  if ( $state == 4 ) {
 
43
  echo "<div id='widgetshoppingcart'>";
44
  echo "<h3>" . __( 'Shopping Cart' ) . "$fancy_collapser</h3>";
45
  echo " <div id='shoppingcartcontents'>";
141
 
142
  if ( $checkoutfields ) {
143
  $namevalue = "name='collected_data[" . $region_form_id . "]'";
 
144
  $js = "onchange='set_shipping_country(\"$html_form_id\", \"$form_id\");'";
145
  $title = 'shippingstate';
146
  } else {
149
  $title = 'billingstate';
150
  }
151
 
 
152
  $output .= "<div id='region_select_$form_id'>";
153
  if ( $region_list != null ) {
154
  $output .= "<select title='$title' " . $namevalue . " class='current_region' " . $js . ">\n\r";
 
155
  foreach ( $region_list as $region ) {
156
  if ( $selected_region == $region['id'] ) {
157
  $selected = "selected='selected'";
wpsc-includes/shortcode.functions.php CHANGED
@@ -17,20 +17,19 @@
17
  */
18
  function wpsc_products_shorttag($atts) {
19
  $query = shortcode_atts(array(
20
- 'product_id' => 0, //done
21
  'product_url_name' => null,
22
- 'product_name' => null, //done
23
- 'category_id' => 0, //done
24
- 'category_url_name' => null, //done
25
- 'tag' => null, //done
26
- 'price' => 0, //done + if price = 'sale' it shows all sale products
27
- 'limit_of_items' => 0, //done
28
  'sort_order' => null, // author,date,title,modified,parent,ID,rand,comment_count
29
  'order' => 'ASC', // ASC or DESC
30
- 'number_per_page' => 0, //done
31
- 'page' => 0, //done
32
  ), $atts);
33
- //exit('Query <pre>'.print_r($query,true).'</pre>');
34
  $post_id_array = explode(',',$query['product_id']);
35
  $cat_id_array = explode(',',$query['category_id']);
36
  if(!empty($post_id_array) && count($post_id_array) > 1)
@@ -43,17 +42,11 @@ function wpsc_products_shorttag($atts) {
43
  return wpsc_display_products_page($query);
44
  }
45
  add_shortcode('wpsc_products', 'wpsc_products_shorttag');
46
- //add_shortcode('productspage', 'wpsc_products_shorttag');
47
-
48
 
49
  function wpsc_buy_now_shortcode($atts){
50
  $output = wpsc_buy_now_button( $atts['product_id'], true );
51
  return $output;
52
  }
53
 
54
-
55
  add_shortcode('buy_now_button', 'wpsc_buy_now_shortcode');
56
-
57
-
58
-
59
  ?>
17
  */
18
  function wpsc_products_shorttag($atts) {
19
  $query = shortcode_atts(array(
20
+ 'product_id' => 0,
21
  'product_url_name' => null,
22
+ 'product_name' => null,
23
+ 'category_id' => 0,
24
+ 'category_url_name' => null,
25
+ 'tag' => null,
26
+ 'price' => 0, //if price = 'sale' it shows all sale products
27
+ 'limit_of_items' => 0,
28
  'sort_order' => null, // author,date,title,modified,parent,ID,rand,comment_count
29
  'order' => 'ASC', // ASC or DESC
30
+ 'number_per_page' => 0,
31
+ 'page' => 0,
32
  ), $atts);
 
33
  $post_id_array = explode(',',$query['product_id']);
34
  $cat_id_array = explode(',',$query['category_id']);
35
  if(!empty($post_id_array) && count($post_id_array) > 1)
42
  return wpsc_display_products_page($query);
43
  }
44
  add_shortcode('wpsc_products', 'wpsc_products_shorttag');
 
 
45
 
46
  function wpsc_buy_now_shortcode($atts){
47
  $output = wpsc_buy_now_button( $atts['product_id'], true );
48
  return $output;
49
  }
50
 
 
51
  add_shortcode('buy_now_button', 'wpsc_buy_now_shortcode');
 
 
 
52
  ?>
wpsc-includes/theme.functions.php CHANGED
@@ -178,6 +178,19 @@ function wpsc_theme_upgrade_notice() { ?>
178
  }
179
  if ( !get_option('wpsc_ignore_theme') )
180
  add_action( 'admin_notices', 'wpsc_theme_upgrade_notice' );
 
 
 
 
 
 
 
 
 
 
 
 
 
181
 
182
  if ( isset( $_REQUEST['wpsc_notices'] ) && $_REQUEST['wpsc_notices'] == 'theme_ignore' ) {
183
  update_option( 'wpsc_ignore_theme', true );
@@ -367,8 +380,6 @@ function wpsc_single_template( $content ) {
367
 
368
  if ( isset( $_SESSION['wpsc_display_type'] ) )
369
  $display_type = $_SESSION['wpsc_display_type'];
370
-
371
-
372
  ob_start();
373
  wpsc_include_products_page_template($display_type);
374
  $content = ob_get_contents();
@@ -416,7 +427,6 @@ function wpsc_the_category_title($title, $id){
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
@@ -505,7 +515,6 @@ function wpsc_enqueue_user_script_and_css() {
505
  * end of added by xiligroup.dev to be compatible with touchshop
506
  */
507
  $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
508
- //$version_identifier = '';
509
  $category_id = '';
510
  if (isset( $wp_query ) && isset( $wp_query->query_vars['taxonomy'] ) && ('wpsc_product_category' == $wp_query->query_vars['taxonomy'] ) || is_numeric( get_option( 'wpsc_default_category' ) )
511
  ) {
@@ -815,7 +824,6 @@ function wpsc_display_products_page( $query ) {
815
  $args['pagename'] = $query['product_name'];
816
  }
817
  if(!empty($query['category_id'])){
818
- //unset($args['post_type']);
819
 
820
  $term = get_term($query['category_id'],'wpsc_product_category');
821
  $id = wpsc_get_meta($query['category_id'], 'category_id','wpsc_old_category');
@@ -849,7 +857,6 @@ function wpsc_display_products_page( $query ) {
849
 
850
  $temp_wpsc_query = new WP_Query($args);
851
  }
852
- // exit('<pre>'.print_r($temp_wpsc_query,1).'</pre>');
853
  // swap the wpsc_query objects
854
  list( $wp_query, $temp_wpsc_query ) = array( $temp_wpsc_query, $wp_query );
855
  $GLOBALS['nzshpcrt_activateshpcrt'] = true;
@@ -918,8 +925,6 @@ function wpsc_include_products_page_template($display_type = 'default'){
918
  case "list":
919
  include( wpsc_get_template_file_path( 'wpsc-list_view.php' ) );
920
  break; // only break if we have the file;
921
-
922
- case "default": // this may be redundant :D
923
  default:
924
  include( wpsc_get_template_file_path( 'wpsc-products_page.php' ) );
925
  break;
@@ -932,9 +937,7 @@ function wpsc_products_page( $content = '' ) {
932
  global $wpdb, $wp_query, $wpsc_query, $wpsc_query_vars;
933
  $output = '';
934
  remove_filter( 'the_content', 'wpautop' );
935
- //exit($content.'<pre>'.print_r($wp_query,true).'</pre>');
936
  if ( preg_match( "/\[productspage\]/", $content ) ) {
937
- // remove_filter( 'the_content', 'wpsc_products_page' );
938
  list($wp_query, $wpsc_query) = array( $wpsc_query, $wp_query ); // swap the wpsc_query object
939
  $GLOBALS['nzshpcrt_activateshpcrt'] = true;
940
 
@@ -1077,7 +1080,6 @@ function wpec_remap_shop_subpages($vars) {
1077
  }
1078
  }
1079
  }
1080
- // echo '<pre>'.print_r($vars,true).'</pre>';
1081
  return $vars;
1082
  }
1083
 
@@ -1112,7 +1114,6 @@ function wpsc_remove_page_from_query_string($query_string)
1112
  unset( $query_string['term'] );
1113
  unset( $query_string['taxonomy'] );
1114
  }
1115
- // echo '2<pre>'.print_r($query_string,true).'</pre>';
1116
  return $query_string;
1117
  }
1118
  add_filter('request', 'wpsc_remove_page_from_query_string');
@@ -1264,7 +1265,6 @@ function wpsc_the_sticky_image( $product_id ) {
1264
  */
1265
  function wpsc_display_featured_products_page() {
1266
  global $wpdb, $wpsc_query,$wp_query;
1267
- // echo('<pre>'.print_r($wp_query,true).'</pre>');
1268
  $sticky_array = get_option( 'sticky_products' );
1269
  if ( (is_front_page() || is_home()) && !empty( $sticky_array ) && $wp_query->post_count > 1) {
1270
  $query = get_posts( array(
178
  }
179
  if ( !get_option('wpsc_ignore_theme') )
180
  add_action( 'admin_notices', 'wpsc_theme_upgrade_notice' );
181
+ function wpsc_turn_on_wp_register() {?>
182
+
183
+ <div id="message" class="updated fade">
184
+ <p><?php printf( __( '<strong>Store Settings</strong>: You have set \'users must register before checkout\', for this to work you need to check \'Anyone can register\' in your WordPress <a href="%1s">General Settings</a>.', 'wpsc' ), admin_url( 'options-general.php' ) ) ?></p>
185
+ </div>
186
+
187
+ <?php
188
+
189
+
190
+ }
191
+
192
+ if ( 1 == get_option( 'require_register' ) && 1 != get_option( 'users_can_register' ))
193
+ add_action( 'admin_notices', 'wpsc_turn_on_wp_register' );
194
 
195
  if ( isset( $_REQUEST['wpsc_notices'] ) && $_REQUEST['wpsc_notices'] == 'theme_ignore' ) {
196
  update_option( 'wpsc_ignore_theme', true );
380
 
381
  if ( isset( $_SESSION['wpsc_display_type'] ) )
382
  $display_type = $_SESSION['wpsc_display_type'];
 
 
383
  ob_start();
384
  wpsc_include_products_page_template($display_type);
385
  $content = ob_get_contents();
427
  $category->name = $wp_query->query_vars['term'];
428
 
429
  }
 
430
  if(!empty($category->name))
431
  return $category->name;
432
  else
515
  * end of added by xiligroup.dev to be compatible with touchshop
516
  */
517
  $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
 
518
  $category_id = '';
519
  if (isset( $wp_query ) && isset( $wp_query->query_vars['taxonomy'] ) && ('wpsc_product_category' == $wp_query->query_vars['taxonomy'] ) || is_numeric( get_option( 'wpsc_default_category' ) )
520
  ) {
824
  $args['pagename'] = $query['product_name'];
825
  }
826
  if(!empty($query['category_id'])){
 
827
 
828
  $term = get_term($query['category_id'],'wpsc_product_category');
829
  $id = wpsc_get_meta($query['category_id'], 'category_id','wpsc_old_category');
857
 
858
  $temp_wpsc_query = new WP_Query($args);
859
  }
 
860
  // swap the wpsc_query objects
861
  list( $wp_query, $temp_wpsc_query ) = array( $temp_wpsc_query, $wp_query );
862
  $GLOBALS['nzshpcrt_activateshpcrt'] = true;
925
  case "list":
926
  include( wpsc_get_template_file_path( 'wpsc-list_view.php' ) );
927
  break; // only break if we have the file;
 
 
928
  default:
929
  include( wpsc_get_template_file_path( 'wpsc-products_page.php' ) );
930
  break;
937
  global $wpdb, $wp_query, $wpsc_query, $wpsc_query_vars;
938
  $output = '';
939
  remove_filter( 'the_content', 'wpautop' );
 
940
  if ( preg_match( "/\[productspage\]/", $content ) ) {
 
941
  list($wp_query, $wpsc_query) = array( $wpsc_query, $wp_query ); // swap the wpsc_query object
942
  $GLOBALS['nzshpcrt_activateshpcrt'] = true;
943
 
1080
  }
1081
  }
1082
  }
 
1083
  return $vars;
1084
  }
1085
 
1114
  unset( $query_string['term'] );
1115
  unset( $query_string['taxonomy'] );
1116
  }
 
1117
  return $query_string;
1118
  }
1119
  add_filter('request', 'wpsc_remove_page_from_query_string');
1265
  */
1266
  function wpsc_display_featured_products_page() {
1267
  global $wpdb, $wpsc_query,$wp_query;
 
1268
  $sticky_array = get_option( 'sticky_products' );
1269
  if ( (is_front_page() || is_home()) && !empty( $sticky_array ) && $wp_query->post_count > 1) {
1270
  $query = get_posts( array(
wpsc-includes/theming.class.php CHANGED
@@ -121,7 +121,6 @@ class wpsc_theming {
121
  @mkdir( $dst );
122
 
123
  while ( false !== ( $file = readdir( $dir )) ) {
124
- //exit($src.'<br /><pre>'.print_r($this->templates_to_move,true).'</pre>');
125
  if ( in_array( $file, $this->templates_to_move ) ) {
126
  if ( is_dir( $src . '/' . $file ) )
127
  $this->recursive_copy( $src . '/' . $file, $dst . '/' . $file );
121
  @mkdir( $dst );
122
 
123
  while ( false !== ( $file = readdir( $dir )) ) {
 
124
  if ( in_array( $file, $this->templates_to_move ) ) {
125
  if ( is_dir( $src . '/' . $file ) )
126
  $this->recursive_copy( $src . '/' . $file, $dst . '/' . $file );
wpsc-includes/variations.class.php CHANGED
@@ -43,11 +43,9 @@ class wpsc_variations {
43
  $this->variation_groups[] = $product_term;
44
  }
45
  }
46
- //exit('<pre>'.print_r($this->all_associated_variations,1).'</pre>');
47
 
48
  foreach((array)$this->variation_groups as $variation_group) {
49
  $variation_id = $variation_group->term_id;
50
- //$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);
51
  $this->first_variations[] = $this->all_associated_variations[$variation_id][0]->term_id;
52
  }
53
 
@@ -60,7 +58,6 @@ class wpsc_variations {
60
  */
61
  function get_variation_groups() {
62
  global $wpdb;
63
- //$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);
64
  $this->variation_group_count = count($this->variation_groups);
65
  $this->get_first_variations();
66
  }
@@ -102,11 +99,8 @@ class wpsc_variations {
102
 
103
  function get_variations() {
104
  global $wpdb;
105
- //$this->variations = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id` = '$value_id' ORDER BY `id` ASC",ARRAY_A);
106
-
107
  $this->variations = $this->all_associated_variations[$this->variation_group->term_id];
108
  $this->variation_count = count($this->variations);
109
- //echo "<pre>".print_r($this->all_associated_variations,true)."</pre>";
110
  }
111
 
112
 
@@ -125,12 +119,9 @@ class wpsc_variations {
125
  if ($this->current_variation + 1 < $this->variation_count) {
126
  return true;
127
  } else if ($this->current_variation + 1 == $this->variation_count && $this->variation_count > 0) {
128
- //do_action('wpsc_loop_end');
129
  // Do some cleaning up after the loop,
130
  $this->rewind_variations();
131
  }
132
-
133
- //$this->in_the_loop = false;
134
  return false;
135
  }
136
 
@@ -147,8 +138,6 @@ class wpsc_variations {
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
@@ -228,7 +217,6 @@ function wpsc_get_child_object_in_terms($parent_id, $terms, $taxonomies, $args =
228
  ) = {$term_count}
229
  GROUP BY tr.object_id
230
  HAVING `count` = {$term_count}";
231
- //echo $object_sql;
232
  $object_ids = $wpdb->get_row($object_sql, ARRAY_A);
233
  if (count($object_ids) > 0) {
234
  return $object_ids['object_id'];
@@ -295,7 +283,6 @@ function wpsc_get_child_object_in_terms_var($parent_id, $terms, $taxonomies, $ar
295
  AND tt.term_id IN ({$terms})
296
  AND tt.parent > 0
297
  GROUP BY tr.object_id";
298
- //echo $object_sql;
299
  $object_ids = $wpdb->get_results($object_sql, ARRAY_A);
300
  if (count($object_ids) > 0) {
301
  return $object_ids;
43
  $this->variation_groups[] = $product_term;
44
  }
45
  }
 
46
 
47
  foreach((array)$this->variation_groups as $variation_group) {
48
  $variation_id = $variation_group->term_id;
 
49
  $this->first_variations[] = $this->all_associated_variations[$variation_id][0]->term_id;
50
  }
51
 
58
  */
59
  function get_variation_groups() {
60
  global $wpdb;
 
61
  $this->variation_group_count = count($this->variation_groups);
62
  $this->get_first_variations();
63
  }
99
 
100
  function get_variations() {
101
  global $wpdb;
 
 
102
  $this->variations = $this->all_associated_variations[$this->variation_group->term_id];
103
  $this->variation_count = count($this->variations);
 
104
  }
105
 
106
 
119
  if ($this->current_variation + 1 < $this->variation_count) {
120
  return true;
121
  } else if ($this->current_variation + 1 == $this->variation_count && $this->variation_count > 0) {
 
122
  // Do some cleaning up after the loop,
123
  $this->rewind_variations();
124
  }
 
 
125
  return false;
126
  }
127
 
138
  }
139
  function wpsc_get_child_object_in_select_terms($parent_id, $terms, $taxonomy){
140
  global $wpdb;
 
 
141
  $sql = "SELECT tr.`object_id`
142
  FROM `".$wpdb->term_relationships."` AS tr
143
  LEFT JOIN `".$wpdb->posts."` AS posts
217
  ) = {$term_count}
218
  GROUP BY tr.object_id
219
  HAVING `count` = {$term_count}";
 
220
  $object_ids = $wpdb->get_row($object_sql, ARRAY_A);
221
  if (count($object_ids) > 0) {
222
  return $object_ids['object_id'];
283
  AND tt.term_id IN ({$terms})
284
  AND tt.parent > 0
285
  GROUP BY tr.object_id";
 
286
  $object_ids = $wpdb->get_results($object_sql, ARRAY_A);
287
  if (count($object_ids) > 0) {
288
  return $object_ids;
wpsc-languages/EN_en.php CHANGED
@@ -121,8 +121,8 @@ define("TXT_WPSC_PAGENUMBER_POSITION_BOTH", "Both");
121
  define("TXT_WPSC_USE_THEME_ENGINE", "Use the experimental Theme Engine");
122
  define("TXT_WPSC_TM", "Target Markets");
123
  define("TXT_WPSC_SHIPPING_DETAIL","Please choose a country below to calculate your shipping costs");
124
- define('TXT_WPSC_TOTAL_THIS_MONTH', 'This Month');
125
- define('TXT_WPSC_TOTAL_INCOME', 'Life Time');
126
  define('TXT_WPSC_SALES_TITLE', 'Sales');
127
  define('TXT_WPSC_ORDERS_TITLE', 'Orders');
128
  define('TXT_WPSC_AVGORDER_TITLE', 'Avg Orders');
121
  define("TXT_WPSC_USE_THEME_ENGINE", "Use the experimental Theme Engine");
122
  define("TXT_WPSC_TM", "Target Markets");
123
  define("TXT_WPSC_SHIPPING_DETAIL","Please choose a country below to calculate your shipping costs");
124
+ define('TXT_WPSC_TOTAL_THIS_MONTH', 'Current Month');
125
+ define('TXT_WPSC_TOTAL_INCOME', 'Total Income');
126
  define('TXT_WPSC_SALES_TITLE', 'Sales');
127
  define('TXT_WPSC_ORDERS_TITLE', 'Orders');
128
  define('TXT_WPSC_AVGORDER_TITLE', 'Avg Orders');
wpsc-merchants/GoogleCheckout-XML.php CHANGED
@@ -21,58 +21,50 @@ $nzshpcrt_gateways[$num]['display_name'] = 'Google Checkout';
21
 
22
  function gateway_google($fromcheckout = false){
23
  global $wpdb, $wpsc_cart, $wpsc_checkout,$current_user, $purchlogs;
24
- //exit('<pre>'.print_r($fromcheckout, true).'</pre>');
25
  if(!isset($wpsc_checkout)){
26
- $wpsc_checkout = new wpsc_checkout();
27
  }
28
  if(!isset($_SESSION['wpsc_sessionid'])){
29
  $sessionid = (mt_rand(100,999).time());
30
  $_SESSION['wpsc_sessionid'] = $sessionid;
31
  }
32
- //exit('<pre>'.print_r($_SESSION,true).'</pre>');
33
- if($_SESSION['wpsc_delivery_region'] == null && $_SESSION['wpsc_selected_region'] == null){
34
- $_SESSION['wpsc_delivery_region'] = get_option('base_region');
35
- $_SESSION['wpsc_selected_region'] = get_option('base_region');
36
- }
37
 
38
- $wpsc_cart->get_shipping_option();
39
- $wpsc_cart->get_shipping_quotes();
40
- $wpsc_cart->get_shipping_method();
41
- $wpsc_cart->google_shipping_quotes();
42
- $subtotal = $wpsc_cart->calculate_subtotal();
43
- $base_shipping = $wpsc_cart->calculate_total_shipping();
44
- $tax = $wpsc_cart->calculate_total_tax();
45
- $total = $wpsc_cart->calculate_total_price();
46
- // exit('<pre>'.print_r($wpsc_cart, true).'</pre>');
47
- if($total > 0 ){
48
- $sql = "UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `totalprice` = ".$total.", `statusno` = '0',`user_ID`=".(int)$user_ID.", `date`= UNIX_TIMESTAMP() , `gateway`='google', `billing_country`='".$wpsc_cart->delivery_country."', shipping_country='".$wpsc_cart->selected_country."', `base_shipping`= '".$base_shipping."', shipping_method = '".$wpsc_cart->selected_shipping_method."', shipping_option= '".$wpsc_cart->selected_shipping_option."', `plugin_version`= '".WPSC_VERSION."' , `discount_value` = '".$wpsc_cart->coupons_amount."', `discount_data`='".$wpsc_cart->coupons_name."' WHERE `sessionid`=".$_SESSION['wpsc_sessionid']."";
49
- // exit($sql);
50
- $update = $wpdb->query($sql);
 
 
 
 
 
 
51
  $sql = "SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE sessionid=".$_SESSION['wpsc_sessionid'];
52
  $purchase_log_id = $wpdb->get_var($sql);
53
- $sql = "DELETE FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE purchaseid = ".$purchase_log_id;
54
- $wpdb->query($sql);
55
  $wpsc_cart->save_to_db($purchase_log_id);
56
- if(! $update){
57
- $sql = "INSERT INTO `".WPSC_TABLE_PURCHASE_LOGS."` (`totalprice`,`statusno`, `sessionid`, `user_ID`, `date`, `gateway`, `billing_country`,`shipping_country`, `base_shipping`,`shipping_method`, `shipping_option`, `plugin_version`, `discount_value`, `discount_data`) VALUES ('$total' ,'0', '".$_SESSION['wpsc_sessionid']."', '".(int)$user_ID."', UNIX_TIMESTAMP(), 'google', '{$wpsc_cart->delivery_country}', '{$wpsc_cart->selected_country}', '{$base_shipping}', '".$wpsc_cart->selected_shipping_method."', '".$wpsc_cart->selected_shipping_option."', '".WPSC_VERSION."', '{$wpsc_cart->coupons_amount}','{$wpsc_cart->coupons_name}')";
58
- $wpdb->query($sql);
59
- $sql = "SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE sessionid=".$_SESSION['wpsc_sessionid'];
60
- $purchase_log_id = $wpdb->get_var($sql);
61
- $wpsc_cart->save_to_db($purchase_log_id);
62
- }
63
-
64
- if(get_option('permalink_structure') != '') {
65
- $separator = "?";
66
- } else {
67
- $separator = "&";
68
- }
69
- Usecase($separator, $_SESSION['wpsc_sessionid'], $fromcheckout);
70
- //exit();
71
-
72
- }
73
-
74
 
75
- }
 
 
 
 
 
 
 
76
 
77
  function Usecase($separator, $sessionid, $fromcheckout) {
78
  global $wpdb, $wpsc_cart;
@@ -91,73 +83,61 @@ function gateway_google($fromcheckout = false){
91
  $cart->SetContinueShoppingUrl($returnURL);
92
  $cart->SetEditCartUrl(get_option('shopping_cart_url'));
93
  $no=1;
94
- //exit("<pre>".print_r($wpsc_cart,true)."</pre>");
95
-
96
  //new item code
97
  $no = 0;
98
- // $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
99
- // foreach($wpsc_cart->cart_items as $item){
100
- //google prohibited items not implemented
101
- $curr=new CURRENCYCONVERTER();
102
- $currency_code = $wpdb->get_results("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A);
103
- $local_currency_code = $currency_code[0]['code'];
104
- // exit('<pre>'.print_r($_REQUEST,true).'</pre>');
105
- $google_curr = get_option('google_cur');
106
- while (wpsc_have_cart_items()) {
107
- wpsc_the_cart_item();
108
- if($google_curr != $local_currency_code) {
109
  $google_currency_productprice = $curr->convert( wpsc_cart_item_price(false)/wpsc_cart_item_quantity(),$google_curr,$local_currency_code);
110
- $google_currency_shipping = $curr->convert( $wpsc_cart->selected_shipping_amount,$google_curr,$local_currency_code);
111
-
112
-
113
- } else {
114
- $google_currency_productprice = wpsc_cart_item_price(false)/wpsc_cart_item_quantity();
115
- $google_currency_shipping = $wpsc_cart->selected_shipping_amount;
116
- }
117
-
118
- // exit('<pre>'.print_r(wpsc_cart_item_name(),true).'</pre>');
119
- $cartitem["$no"] = new GoogleItem(wpsc_cart_item_name(), // Item name
120
- '', // Item description
121
- wpsc_cart_item_quantity(), // Quantity
122
- ($google_currency_productprice)); // Unit price
123
- $cart->AddItem($cartitem["$no"]);
124
- $no++;
125
  }
126
- //If there are coupons applied add coupon as a product with negative price
127
- if($wpsc_cart->coupons_amount > 0){
128
- if($google_curr != $local_currency_code) {
129
- $google_currency_productprice = $curr->convert( $wpsc_cart->coupons_amount,$google_curr,$local_currency_code);
130
- } else {
131
- $google_currency_productprice = $wpsc_cart->coupons_amount;
132
- }
133
- $cartitem[$no] = new GoogleItem('Discount', // Item name
134
- 'Discount Price', // Item description
135
- 1, // Quantity
136
- ('-'.$google_currency_productprice)); // Unit price
137
- $cart->AddItem($cartitem[$no]);
138
-
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  }
141
-
142
- // }
143
-
 
 
 
 
 
144
 
145
  // Add shipping options
146
  if(wpsc_uses_shipping() && $google_currency_shipping >0 ){
147
  $Gfilter = new GoogleShippingFilters();
148
  $google_checkout_shipping=get_option("google_shipping_country");
149
  $googleshippingcountries = count($google_checkout_shipping);
150
- //exit('<pre>'.print_r($googleshipping, true).'</pre>');
151
  if($googleshippingcountries == 242){
152
  $Gfilter->SetAllowedWorldArea(true);
153
-
154
  }else{
155
- if(is_array($google_checkout_shipping)){
156
- $google_shipping_country_ids = implode(",",$google_checkout_shipping);
157
- }
158
  $google_shipping_country = $wpdb->get_col("SELECT `isocode` FROM ".WPSC_TABLE_CURRENCY_LIST." WHERE id IN (".$google_shipping_country_ids.")");
159
  foreach($google_shipping_country as $isocode){
160
- //exit($isocode);
161
  $Gfilter->AddAllowedPostalArea($isocode);
162
  if($isocode == 'US'){
163
  $Gfilter->SetAllowedCountryArea('ALL');
@@ -174,52 +154,38 @@ function gateway_google($fromcheckout = false){
174
  //wpsc_google_shipping_quotes();
175
 
176
  // Add tax rules
177
- //if ($_SESSION['wpsc_selected_country']=='US'){
178
- //set default tax
179
- //exit('<pre>'.print_r($_SESSION,true).'</pre>');
180
- $sql = "SELECT `name`, `tax` FROM ".WPSC_TABLE_REGION_TAX." WHERE id='".$_SESSION['wpsc_selected_region']."'";
181
- //exit('<pre>'.print_r($sql, true).'</pre>');
182
- $state_name = $wpdb->get_row($sql, ARRAY_A);
183
- //exit('<pre>'.print_r($state_name, true).'</pre>');
184
- $defaultTax = $state_name['tax']/100;
185
- $tax_rule = new GoogleDefaultTaxRule($defaultTax);
186
- $sql = "SELECT `code` FROM ".WPSC_TABLE_REGION_TAX." WHERE `country_id`='136' AND `tax` = ".$state_name['tax'];
187
- $states = $wpdb->get_col($sql);
188
- //exit('<pre>'.print_r($states, true).'</pre>');
189
- $tax_rule->SetStateAreas((array)$states);
190
- $cart->AddDefaultTaxRules($tax_rule);
191
- //get alternative tax rates
192
- $sql = "SELECT DISTINCT `tax` FROM ".WPSC_TABLE_REGION_TAX." WHERE `tax` != 0 AND `tax` !=".$state_name['tax']." AND `country_id`='136' ORDER BY `tax`";
193
- $othertax = $wpdb->get_col($sql);
194
- $i = 1;
195
- //exit('<pre>'.print_r($othertax, true).'</pre>');
196
- foreach($othertax as $altTax){
197
- $sql = "SELECT `code` FROM ".WPSC_TABLE_REGION_TAX." WHERE `country_id`='136' AND `tax`=".$altTax;
198
- $alt = $wpdb->get_col($sql);
199
- $altTax = $altTax/100;
200
- $alt_google_tax = new GoogleDefaultTaxRule($altTax);
201
- $alt_google_tax->SetStateAreas($alt);
202
- //$g = new GoogleAlternateTaxTable('Alt Tax'.$i);
203
- //$g->AddAlternateTaxRules($alt_google_tax);
204
- $cart->AddDefaultTaxRules($alt_google_tax);
205
- // exit(print_r($alt,true));
206
- $i++;
207
- }
208
-
209
- //}
210
- if (get_option('google_button_size') == '0'){
211
- $google_button_size = 'BIG';
212
- } elseif(get_option('google_button_size') == '1') {
213
- $google_button_size = 'MEDIUM';
214
- } elseif(get_option('google_button_size') == '2') {
215
- $google_button_size = 'SMALL';
216
- }
217
  // Display Google Checkout button
218
- //echo '<pre>'.print_r($cart, true).'</pre>';
219
- //unset($_SESSION['wpsc_sessionid']);
220
- //if($fromCheckout){
221
  echo $cart->CheckoutButtonCode($google_button_size);
222
- //}
223
  }
224
 
225
  function wpsc_google_checkout_page(){
@@ -234,13 +200,10 @@ function wpsc_google_checkout_page(){
234
  });
235
  </script>";
236
  $options = get_option('payment_gateway');
237
- // exit('HELLO<pre>'.print_r(get_option('custom_gateway_options'), true).'</pre>');
 
 
238
 
239
- //foreach((array)get_option('custom_gateway_options') as $gateway){
240
- if(in_array('google', (array)get_option('custom_gateway_options'))){
241
- $options = 'google';
242
- }
243
- // }
244
  if($options == 'google' && isset($_SESSION['gateway'])){
245
  unset($_SESSION['gateway']);
246
  echo $script;
@@ -458,12 +421,10 @@ function nzsc_googleResponse() {
458
  $affiliate_id = $affiliate_id[1];
459
  }
460
  }
461
- //$tax = $data['new-order-notification']['order-adjustment'][];
462
  $Grequest = new GoogleRequest($merchant_id, $merchant_key, $server_type,$currency);
463
  $result = $Grequest->SendProcessOrder($google_order_number);
464
  $region_number = $wpdb->get_var("SELECT id FROM ".WPSC_TABLE_REGION_TAX."` WHERE code ='".$billing_region."'");
465
  $sql = "INSERT INTO `".WPSC_TABLE_PURCHASE_LOGS."` ( `totalprice` , `sessionid` , `date`, `billing_country`, `shipping_country`,`base_shipping`,`shipping_region`, `user_ID`, `discount_value`,`gateway`, `google_order_number`, `google_user_marketing_preference`, `affiliate_id`) VALUES ( '".$total_price."', '".$sessionid."', '".time()."', '".$billing_country."', '".$shipping_country."', '".$pnp."','".$region_number."' , '".$user_ID."' , '".$_SESSION['wpsc_discount']."','".get_option('payment_gateway')."','".$google_order_number."','".$user_marketing_preference."', '".$affiliate_id."')";
466
- // mail('hanzhimeng@gmail.com',"",$sql);
467
 
468
  $wpdb->query($sql) ;
469
  $log_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid` IN('".$sessionid."') LIMIT 1") ;
@@ -475,7 +436,6 @@ function nzsc_googleResponse() {
475
  //logging to submited_form_data
476
  $billing_fname_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='first_name' LIMIT 1") ;
477
  $sql = "INSERT INTO `".WPSC_TABLE_SUBMITED_FORM_DATA."` (log_id, form_id, value) VALUES ('".$log_id."','".$billing_fname_id."','".$billing_firstname."')";
478
- //$wpdb->query($sql) ;
479
  $billing_lname_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='last_name' LIMIT 1") ;
480
  $sql .= ", ('".$log_id."','".$billing_lname_id."','".$billing_lastname."')";
481
  $billing_address_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='address' LIMIT 1") ;
@@ -499,7 +459,6 @@ function nzsc_googleResponse() {
499
  $shipping_country_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_country' LIMIT 1") ;
500
  $sql .= ", ('".$log_id."','".$shipping_country_id."','".$shipping_country."')";
501
  $wpdb->query($sql) ;
502
- //$variations = $cart_item->product_variations;
503
  foreach($cart_items as $cart_item) {
504
  $product_id = $cart_item['merchant-item-id']['VALUE'];
505
  $item_name = $cart_item['item-name']['VALUE'];
@@ -508,9 +467,7 @@ function nzsc_googleResponse() {
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) {
513
- //$price = nzshpcrt_calculate_tax($item_unit_price, $billing_country, $region_number);
514
  if(get_option('base_country') == $billing_country) {
515
  $country_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode` IN('".get_option('base_country')."') LIMIT 1",ARRAY_A);
516
  if(($country_data['has_regions'] == 1)) {
@@ -599,8 +556,6 @@ function nzsc_googleResponse() {
599
  $sql = "UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET google_status='".$google_status."' WHERE google_order_number='".$google_order_number."'";
600
  $wpdb->query($sql) ;
601
  }
602
- // <avs-response>Y</avs-response>
603
- // <cvn-response>M</cvn-response>
604
 
605
  if ($root == "risk-information-notification") {
606
  $google_order_number = $data['risk-information-notification']['google-order-number']['VALUE'];
@@ -636,7 +591,6 @@ function nzsc_googleResponse() {
636
  $wpdb->get_var("UPDATE ".WPSC_TABLE_PURCHASE_LOGS." SET google_status='".serialize($google_status)."' WHERE google_order_number='".$google_order_number."'");
637
  }
638
  }
639
- // mail('hanzhimeng@gmail.com',"",$root . " <pre>". print_r($data,1)."</pre>");
640
  exit();
641
  }
642
  }
21
 
22
  function gateway_google($fromcheckout = false){
23
  global $wpdb, $wpsc_cart, $wpsc_checkout,$current_user, $purchlogs;
 
24
  if(!isset($wpsc_checkout)){
25
+ $wpsc_checkout = new wpsc_checkout();
26
  }
27
  if(!isset($_SESSION['wpsc_sessionid'])){
28
  $sessionid = (mt_rand(100,999).time());
29
  $_SESSION['wpsc_sessionid'] = $sessionid;
30
  }
31
+ if($_SESSION['wpsc_delivery_region'] == null && $_SESSION['wpsc_selected_region'] == null){
32
+ $_SESSION['wpsc_delivery_region'] = get_option('base_region');
33
+ $_SESSION['wpsc_selected_region'] = get_option('base_region');
34
+ }
 
35
 
36
+ $wpsc_cart->get_shipping_option();
37
+ $wpsc_cart->get_shipping_quotes();
38
+ $wpsc_cart->get_shipping_method();
39
+ $wpsc_cart->google_shipping_quotes();
40
+ $subtotal = $wpsc_cart->calculate_subtotal();
41
+ $base_shipping = $wpsc_cart->calculate_total_shipping();
42
+ $tax = $wpsc_cart->calculate_total_tax();
43
+ $total = $wpsc_cart->calculate_total_price();
44
+ if($total > 0 ){
45
+ $sql = "UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `totalprice` = ".$total.", `statusno` = '0',`user_ID`=".(int)$user_ID.", `date`= UNIX_TIMESTAMP() , `gateway`='google', `billing_country`='".$wpsc_cart->delivery_country."', shipping_country='".$wpsc_cart->selected_country."', `base_shipping`= '".$base_shipping."', shipping_method = '".$wpsc_cart->selected_shipping_method."', shipping_option= '".$wpsc_cart->selected_shipping_option."', `plugin_version`= '".WPSC_VERSION."' , `discount_value` = '".$wpsc_cart->coupons_amount."', `discount_data`='".$wpsc_cart->coupons_name."' WHERE `sessionid`=".$_SESSION['wpsc_sessionid']."";
46
+ $update = $wpdb->query($sql);
47
+ $sql = "SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE sessionid=".$_SESSION['wpsc_sessionid'];
48
+ $purchase_log_id = $wpdb->get_var($sql);
49
+ $sql = "DELETE FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE purchaseid = ".$purchase_log_id;
50
+ $wpdb->query($sql);
51
+ $wpsc_cart->save_to_db($purchase_log_id);
52
+ if(! $update){
53
+ $sql = "INSERT INTO `".WPSC_TABLE_PURCHASE_LOGS."` (`totalprice`,`statusno`, `sessionid`, `user_ID`, `date`, `gateway`, `billing_country`,`shipping_country`, `base_shipping`,`shipping_method`, `shipping_option`, `plugin_version`, `discount_value`, `discount_data`) VALUES ('$total' ,'0', '".$_SESSION['wpsc_sessionid']."', '".(int)$user_ID."', UNIX_TIMESTAMP(), 'google', '{$wpsc_cart->delivery_country}', '{$wpsc_cart->selected_country}', '{$base_shipping}', '".$wpsc_cart->selected_shipping_method."', '".$wpsc_cart->selected_shipping_option."', '".WPSC_VERSION."', '{$wpsc_cart->coupons_amount}','{$wpsc_cart->coupons_name}')";
54
+ $wpdb->query($sql);
55
  $sql = "SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE sessionid=".$_SESSION['wpsc_sessionid'];
56
  $purchase_log_id = $wpdb->get_var($sql);
 
 
57
  $wpsc_cart->save_to_db($purchase_log_id);
58
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
+ if(get_option('permalink_structure') != '') {
61
+ $separator = "?";
62
+ } else {
63
+ $separator = "&";
64
+ }
65
+ Usecase($separator, $_SESSION['wpsc_sessionid'], $fromcheckout);
66
+ }
67
+ }
68
 
69
  function Usecase($separator, $sessionid, $fromcheckout) {
70
  global $wpdb, $wpsc_cart;
83
  $cart->SetContinueShoppingUrl($returnURL);
84
  $cart->SetEditCartUrl(get_option('shopping_cart_url'));
85
  $no=1;
 
 
86
  //new item code
87
  $no = 0;
88
+ //google prohibited items not implemented
89
+ $curr=new CURRENCYCONVERTER();
90
+ $currency_code = $wpdb->get_results("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A);
91
+ $local_currency_code = $currency_code[0]['code'];
92
+ $google_curr = get_option('google_cur');
93
+ while (wpsc_have_cart_items()) {
94
+ wpsc_the_cart_item();
95
+ if($google_curr != $local_currency_code) {
 
 
 
96
  $google_currency_productprice = $curr->convert( wpsc_cart_item_price(false)/wpsc_cart_item_quantity(),$google_curr,$local_currency_code);
97
+ $google_currency_shipping = $curr->convert( $wpsc_cart->selected_shipping_amount,$google_curr,$local_currency_code);
98
+ } else {
99
+ $google_currency_productprice = wpsc_cart_item_price(false)/wpsc_cart_item_quantity();
100
+ $google_currency_shipping = $wpsc_cart->selected_shipping_amount;
 
 
 
 
 
 
 
 
 
 
 
101
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
+ $cartitem["$no"] = new GoogleItem(
104
+ wpsc_cart_item_name(), // Item name
105
+ '', // Item description
106
+ wpsc_cart_item_quantity(), // Quantity
107
+ ($google_currency_productprice) // Unit price
108
+ );
109
+ $cart->AddItem($cartitem["$no"]);
110
+ $no++;
111
+ }
112
+ //If there are coupons applied add coupon as a product with negative price
113
+ if($wpsc_cart->coupons_amount > 0){
114
+ if($google_curr != $local_currency_code) {
115
+ $google_currency_productprice = $curr->convert( $wpsc_cart->coupons_amount,$google_curr,$local_currency_code);
116
+ } else {
117
+ $google_currency_productprice = $wpsc_cart->coupons_amount;
118
  }
119
+ $cartitem[$no] = new GoogleItem(
120
+ 'Discount', // Item name
121
+ 'Discount Price', // Item description
122
+ 1, // Quantity
123
+ ('-'.$google_currency_productprice) // Unit price
124
+ );
125
+ $cart->AddItem($cartitem[$no]);
126
+ }
127
 
128
  // Add shipping options
129
  if(wpsc_uses_shipping() && $google_currency_shipping >0 ){
130
  $Gfilter = new GoogleShippingFilters();
131
  $google_checkout_shipping=get_option("google_shipping_country");
132
  $googleshippingcountries = count($google_checkout_shipping);
 
133
  if($googleshippingcountries == 242){
134
  $Gfilter->SetAllowedWorldArea(true);
 
135
  }else{
136
+ if(is_array($google_checkout_shipping)){
137
+ $google_shipping_country_ids = implode(",",$google_checkout_shipping);
138
+ }
139
  $google_shipping_country = $wpdb->get_col("SELECT `isocode` FROM ".WPSC_TABLE_CURRENCY_LIST." WHERE id IN (".$google_shipping_country_ids.")");
140
  foreach($google_shipping_country as $isocode){
 
141
  $Gfilter->AddAllowedPostalArea($isocode);
142
  if($isocode == 'US'){
143
  $Gfilter->SetAllowedCountryArea('ALL');
154
  //wpsc_google_shipping_quotes();
155
 
156
  // Add tax rules
157
+ //set default tax
158
+ $sql = "SELECT `name`, `tax` FROM ".WPSC_TABLE_REGION_TAX." WHERE id='".$_SESSION['wpsc_selected_region']."'";
159
+ $state_name = $wpdb->get_row($sql, ARRAY_A);
160
+ $defaultTax = $state_name['tax']/100;
161
+ $tax_rule = new GoogleDefaultTaxRule($defaultTax);
162
+ $sql = "SELECT `code` FROM ".WPSC_TABLE_REGION_TAX." WHERE `country_id`='136' AND `tax` = ".$state_name['tax'];
163
+ $states = $wpdb->get_col($sql);
164
+ $tax_rule->SetStateAreas((array)$states);
165
+ $cart->AddDefaultTaxRules($tax_rule);
166
+ //get alternative tax rates
167
+ $sql = "SELECT DISTINCT `tax` FROM ".WPSC_TABLE_REGION_TAX." WHERE `tax` != 0 AND `tax` !=".$state_name['tax']." AND `country_id`='136' ORDER BY `tax`";
168
+ $othertax = $wpdb->get_col($sql);
169
+ $i = 1;
170
+ foreach($othertax as $altTax){
171
+ $sql = "SELECT `code` FROM ".WPSC_TABLE_REGION_TAX." WHERE `country_id`='136' AND `tax`=".$altTax;
172
+ $alt = $wpdb->get_col($sql);
173
+ $altTax = $altTax/100;
174
+ $alt_google_tax = new GoogleDefaultTaxRule($altTax);
175
+ $alt_google_tax->SetStateAreas($alt);
176
+ $cart->AddDefaultTaxRules($alt_google_tax);
177
+ $i++;
178
+ }
179
+
180
+ if (get_option('google_button_size') == '0'){
181
+ $google_button_size = 'BIG';
182
+ } elseif(get_option('google_button_size') == '1') {
183
+ $google_button_size = 'MEDIUM';
184
+ } elseif(get_option('google_button_size') == '2') {
185
+ $google_button_size = 'SMALL';
186
+ }
 
 
 
 
 
 
 
 
 
 
187
  // Display Google Checkout button
 
 
 
188
  echo $cart->CheckoutButtonCode($google_button_size);
 
189
  }
190
 
191
  function wpsc_google_checkout_page(){
200
  });
201
  </script>";
202
  $options = get_option('payment_gateway');
203
+ if(in_array('google', (array)get_option('custom_gateway_options'))){
204
+ $options = 'google';
205
+ }
206
 
 
 
 
 
 
207
  if($options == 'google' && isset($_SESSION['gateway'])){
208
  unset($_SESSION['gateway']);
209
  echo $script;
421
  $affiliate_id = $affiliate_id[1];
422
  }
423
  }
 
424
  $Grequest = new GoogleRequest($merchant_id, $merchant_key, $server_type,$currency);
425
  $result = $Grequest->SendProcessOrder($google_order_number);
426
  $region_number = $wpdb->get_var("SELECT id FROM ".WPSC_TABLE_REGION_TAX."` WHERE code ='".$billing_region."'");
427
  $sql = "INSERT INTO `".WPSC_TABLE_PURCHASE_LOGS."` ( `totalprice` , `sessionid` , `date`, `billing_country`, `shipping_country`,`base_shipping`,`shipping_region`, `user_ID`, `discount_value`,`gateway`, `google_order_number`, `google_user_marketing_preference`, `affiliate_id`) VALUES ( '".$total_price."', '".$sessionid."', '".time()."', '".$billing_country."', '".$shipping_country."', '".$pnp."','".$region_number."' , '".$user_ID."' , '".$_SESSION['wpsc_discount']."','".get_option('payment_gateway')."','".$google_order_number."','".$user_marketing_preference."', '".$affiliate_id."')";
 
428
 
429
  $wpdb->query($sql) ;
430
  $log_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid` IN('".$sessionid."') LIMIT 1") ;
436
  //logging to submited_form_data
437
  $billing_fname_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='first_name' LIMIT 1") ;
438
  $sql = "INSERT INTO `".WPSC_TABLE_SUBMITED_FORM_DATA."` (log_id, form_id, value) VALUES ('".$log_id."','".$billing_fname_id."','".$billing_firstname."')";
 
439
  $billing_lname_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='last_name' LIMIT 1") ;
440
  $sql .= ", ('".$log_id."','".$billing_lname_id."','".$billing_lastname."')";
441
  $billing_address_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='address' LIMIT 1") ;
459
  $shipping_country_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_country' LIMIT 1") ;
460
  $sql .= ", ('".$log_id."','".$shipping_country_id."','".$shipping_country."')";
461
  $wpdb->query($sql) ;
 
462
  foreach($cart_items as $cart_item) {
463
  $product_id = $cart_item['merchant-item-id']['VALUE'];
464
  $item_name = $cart_item['item-name']['VALUE'];
467
  $item_quantity = $cart_item['quantity']['VALUE'];
468
  $product_info = $wpdb->get_results("SELECT * FROM `" . $wpdb->posts . "` WHERE id='".$product_id."' LIMIT 1", ARRAY_A) ;
469
  $product_info = $product_info[0];
 
470
  if($product_info['notax'] != 1) {
 
471
  if(get_option('base_country') == $billing_country) {
472
  $country_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode` IN('".get_option('base_country')."') LIMIT 1",ARRAY_A);
473
  if(($country_data['has_regions'] == 1)) {
556
  $sql = "UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET google_status='".$google_status."' WHERE google_order_number='".$google_order_number."'";
557
  $wpdb->query($sql) ;
558
  }
 
 
559
 
560
  if ($root == "risk-information-notification") {
561
  $google_order_number = $data['risk-information-notification']['google-order-number']['VALUE'];
591
  $wpdb->get_var("UPDATE ".WPSC_TABLE_PURCHASE_LOGS." SET google_status='".serialize($google_status)."' WHERE google_order_number='".$google_order_number."'");
592
  }
593
  }
 
594
  exit();
595
  }
596
  }
wpsc-merchants/library/googlecart.php CHANGED
@@ -423,7 +423,6 @@
423
  array('currency' => $this->currency));
424
  $xml_data->Element('quantity', $item->quantity);
425
  if($item->merchant_private_item_data != '') {
426
- // echo get_class($item->merchant_private_item_data);
427
  if(is_a($item->merchant_private_item_data,
428
  'merchantprivate')) {
429
  $item->merchant_private_item_data->AddMerchantPrivateToXML($xml_data);
@@ -479,7 +478,7 @@
479
  $xml_data->Push('checkout-flow-support');
480
  $xml_data->Push('merchant-checkout-flow-support');
481
  $xml_data->Element('platform-id', $this->google_platform_id);
482
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
483
  if($this->edit_cart_url != '')
484
  $xml_data->Element('edit-cart-url', $this->edit_cart_url);
485
  if($this->continue_shopping_url != '')
@@ -659,7 +658,6 @@
659
  $xml_data->Pop($ship->type);
660
  }
661
  else if ($ship->type == "carrier-calculated-shipping"){
662
- // $xml_data->Push($ship->type, array('name' => $ship->name));
663
  $xml_data->Push($ship->type);
664
  $xml_data->Push('carrier-calculated-shipping-options');
665
  $CCSoptions = $ship->CarrierCalculatedShippingOptions;
@@ -682,7 +680,6 @@
682
  $xml_data->Pop('carrier-calculated-shipping-option');
683
  }
684
  $xml_data->Pop('carrier-calculated-shipping-options');
685
- // $ShippingPackage = $ship->ShippingPackage;
686
  $xml_data->Push('shipping-packages');
687
  $xml_data->Push('shipping-package');
688
  $xml_data->Push('ship-from', array('id' => $ship->ShippingPackage->ship_from->id));
@@ -727,9 +724,10 @@
727
  $xml_data->Element('merchant-calculations-url',
728
  $this->merchant_calculations_url);
729
  if($this->accept_merchant_coupons != "") {
730
- $xml_data->Element('accept-merchant-coupons',
731
- // "true");
732
- $this->accept_merchant_coupons);
 
733
  }
734
  if($this->accept_gift_certificates != "") {
735
  $xml_data->Element('accept-gift-certificates',
@@ -925,7 +923,6 @@
925
  $xml_data->Pop('merchant-checkout-flow-support');
926
  $xml_data->Pop('checkout-flow-support');
927
  $xml_data->Pop('checkout-shopping-cart');
928
- //mail("hanzhimeng@gmail.com","",print_r($xml_data->GetXML(),1));
929
  return $xml_data->GetXML();
930
  }
931
 
@@ -1367,14 +1364,11 @@
1367
  * @access private
1368
  */
1369
  function xml2html($data, $path = '', &$rta){
1370
- // global $multiple_tags,$ignore_tags;
1371
- // $arr = gc_get_arr_result($data);
1372
  foreach($data as $tag_name => $tag) {
1373
  if(isset($this->ignore_tags[$tag_name])){
1374
  continue;
1375
  }
1376
  if(is_array($tag)){
1377
- // echo print_r($tag, true) . $tag_name . "<- tag name\n";
1378
  if(!$this->is_associative_array($data)) {
1379
  $new_path = $path . '-' . ($tag_name +1);
1380
  } else {
423
  array('currency' => $this->currency));
424
  $xml_data->Element('quantity', $item->quantity);
425
  if($item->merchant_private_item_data != '') {
 
426
  if(is_a($item->merchant_private_item_data,
427
  'merchantprivate')) {
428
  $item->merchant_private_item_data->AddMerchantPrivateToXML($xml_data);
478
  $xml_data->Push('checkout-flow-support');
479
  $xml_data->Push('merchant-checkout-flow-support');
480
  $xml_data->Element('platform-id', $this->google_platform_id);
481
+
482
  if($this->edit_cart_url != '')
483
  $xml_data->Element('edit-cart-url', $this->edit_cart_url);
484
  if($this->continue_shopping_url != '')
658
  $xml_data->Pop($ship->type);
659
  }
660
  else if ($ship->type == "carrier-calculated-shipping"){
 
661
  $xml_data->Push($ship->type);
662
  $xml_data->Push('carrier-calculated-shipping-options');
663
  $CCSoptions = $ship->CarrierCalculatedShippingOptions;
680
  $xml_data->Pop('carrier-calculated-shipping-option');
681
  }
682
  $xml_data->Pop('carrier-calculated-shipping-options');
 
683
  $xml_data->Push('shipping-packages');
684
  $xml_data->Push('shipping-package');
685
  $xml_data->Push('ship-from', array('id' => $ship->ShippingPackage->ship_from->id));
724
  $xml_data->Element('merchant-calculations-url',
725
  $this->merchant_calculations_url);
726
  if($this->accept_merchant_coupons != "") {
727
+ $xml_data->Element(
728
+ 'accept-merchant-coupons',
729
+ $this->accept_merchant_coupons
730
+ );
731
  }
732
  if($this->accept_gift_certificates != "") {
733
  $xml_data->Element('accept-gift-certificates',
923
  $xml_data->Pop('merchant-checkout-flow-support');
924
  $xml_data->Pop('checkout-flow-support');
925
  $xml_data->Pop('checkout-shopping-cart');
 
926
  return $xml_data->GetXML();
927
  }
928
 
1364
  * @access private
1365
  */
1366
  function xml2html($data, $path = '', &$rta){
 
 
1367
  foreach($data as $tag_name => $tag) {
1368
  if(isset($this->ignore_tags[$tag_name])){
1369
  continue;
1370
  }
1371
  if(is_array($tag)){
 
1372
  if(!$this->is_associative_array($data)) {
1373
  $new_path = $path . '-' . ($tag_name +1);
1374
  } else {
wpsc-merchants/library/googlecart1.php DELETED
@@ -1,1644 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright (C) 2007 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- /**
19
- * Classes used to build a shopping cart and submit it to Google Checkout
20
- * @version $Id: googlecart.php 1234 2007-09-25 14:58:57Z ropu $
21
- */
22
-
23
- define('MAX_DIGITAL_DESC', 1024);
24
-
25
- /**
26
- * Creates a Google Checkout shopping cart and posts it
27
- * to the google checkout sandbox or production environment
28
- * Refer demo/cartdemo.php for different use case scenarios for this code
29
- */
30
- class GoogleCart {
31
- var $merchant_id;
32
- var $merchant_key;
33
- var $variant = false;
34
- var $currency;
35
- var $server_url;
36
- var $schema_url;
37
- var $base_url;
38
- var $checkout_url;
39
- var $checkout_diagnose_url;
40
- var $request_url;
41
- var $request_diagnose_url;
42
-
43
- var $cart_expiration = "";
44
- var $merchant_private_data = "";
45
- var $edit_cart_url = "";
46
- var $continue_shopping_url = "";
47
- var $request_buyer_phone = "";
48
- var $merchant_calculated_tax = "";
49
- var $merchant_calculations_url = "";
50
- var $accept_merchant_coupons = "";
51
- var $accept_gift_certificates = "";
52
- var $rounding_mode;
53
- var $rounding_rule;
54
- var $analytics_data;
55
-
56
- var $item_arr;
57
- var $shipping_arr;
58
- var $default_tax_rules_arr;
59
- var $alternate_tax_tables_arr;
60
- var $xml_data;
61
-
62
- var $googleAnalytics_id = false;
63
- var $thirdPartyTackingUrl = false;
64
- var $thirdPartyTackingParams = array();
65
-
66
- // For HTML API Conversion
67
-
68
- // This tags are those that can be used more than once as a sub tag
69
- // so a "-#" must be added always
70
- /**
71
- * used when using the html api
72
- * tags that can be used more than once, so they need to be numbered
73
- * ("-#" suffix)
74
- */
75
- var $multiple_tags = array(
76
- 'flat-rate-shipping' => array(),
77
- 'merchant-calculated-shipping' => array(),
78
- 'pickup' => array(),
79
- 'parameterized-url' => array(),
80
- 'url-parameter' => array(),
81
- 'item' => array(),
82
- 'us-state-area' => array('tax-area'),
83
- 'us-zip-area' => array('tax-area'),
84
- 'us-country-area' => array('tax-area'),
85
- 'postal-area' => array('tax-area'),
86
- 'alternate-tax-table' => array(),
87
- 'world-area' => array('tax-area'),
88
- 'default-tax-rule' => array(),
89
- 'alternate-tax-rule' => array(),
90
- 'gift-certificate-adjustment' => array(),
91
- 'coupon-adjustment' => array(),
92
- 'coupon-result' => array(),
93
- 'gift-certificate-result' => array(),
94
- 'method' => array(),
95
- 'anonymous-address' => array(),
96
- 'result' => array(),
97
- 'string' => array(),
98
- );
99
-
100
- var $ignore_tags = array(
101
- 'xmlns' => true,
102
- 'checkout-shopping-cart' => true,
103
- // Dont know how to translate these tag yet
104
- 'merchant-private-data' => true,
105
- 'merchant-private-item-data' => true,
106
- );
107
-
108
-
109
-
110
- /**
111
- * Has all the logic to build the cart's xml (or html) request to be
112
- * posted to google's servers.
113
- *
114
- * @param string $id the merchant id
115
- * @param string $key the merchant key
116
- * @param string $server_type the server type of the server to be used, one
117
- * of 'sandbox' or 'production'.
118
- * defaults to 'sandbox'
119
- * @param string $currency the currency of the items to be added to the cart
120
- * , as of now values can be 'USD' or 'GBP'.
121
- * defaults to 'USD'
122
- */
123
- function GoogleCart($id, $key, $server_type="sandbox", $currency="USD") {
124
- $this->merchant_id = $id;
125
- $this->merchant_key = $key;
126
- $this->currency = $currency;
127
-
128
- if(strtolower($server_type) == "sandbox") {
129
- $this->server_url = "https://sandbox.google.com/checkout/";
130
- } else {
131
- $this->server_url= "https://checkout.google.com/";
132
- }
133
-
134
-
135
- $this->schema_url = "http://checkout.google.com/schema/2";
136
- $this->base_url = $this->server_url . "api/checkout/v2/";
137
- $this->checkout_url = $this->base_url . "checkout/Merchant/" . $this->merchant_id;
138
- $this->checkoutForm_url = $this->base_url . "checkoutForm/Merchant/" . $this->merchant_id;
139
-
140
- //The item, shipping and tax table arrays are initialized
141
- $this->item_arr = array();
142
- $this->shipping_arr = array();
143
- $this->alternate_tax_tables_arr = array();
144
- }
145
-
146
- /**
147
- * Sets the cart's expiration date
148
- *
149
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_good-until-date <good-until-date>}
150
- *
151
- * @param string $cart_expire a string representing a date in the
152
- * iso 8601 date and time format: {@link http://www.w3.org/TR/NOTE-datetime}
153
- *
154
- * @return void
155
- */
156
- function SetCartExpiration($cart_expire) {
157
- $this->cart_expiration = $cart_expire;
158
- }
159
-
160
- /**
161
- * Sets the merchant's private data.
162
- *
163
- * Google Checkout will return this data in the
164
- * <merchant-calculation-callback> and the
165
- * <new-order-notification> for the order.
166
- *
167
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_merchant-private-data <merchant-private-data>}
168
- *
169
- * @param MerchantPrivateData $data an object which contains the data to be
170
- * sent as merchant-private-data
171
- *
172
- * @return void
173
- */
174
- function SetMerchantPrivateData($data) {
175
- $this->merchant_private_data = $data;
176
- }
177
-
178
- /**
179
- * Sets the url where the customer can edit his cart.
180
- *
181
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_edit-cart-url <edit-cart-url>}
182
- *
183
- * @param string $url the merchant's site edit cart url
184
- * @return void
185
- */
186
- function SetEditCartUrl($url) {
187
- $this->edit_cart_url= $url;
188
- }
189
-
190
- /**
191
- * Sets the continue shopping url, which allows the customer to return
192
- * to the merchant's site after confirming an order.
193
- *
194
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_continue-shopping-url <continue-shopping-url>}
195
- *
196
- * @param string $url the merchant's site continue shopping url
197
- * @return void
198
- */
199
- function SetContinueShoppingUrl($url) {
200
- $this->continue_shopping_url = $url;
201
- }
202
-
203
- /**
204
- * Sets whether the customer must enter a phone number to complete an order.
205
- * If set to true, the customer must enter a number, which Google Checkout
206
- * will return in the new order notification for the order.
207
- *
208
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_request-buyer-phone-number <request-buyer-phone-number>}
209
- *
210
- * @param bool $req true if the customer's phone number is *required*
211
- * to complete an order.
212
- * defaults to false.
213
- * @return void
214
- */
215
- function SetRequestBuyerPhone($req) {
216
- $this->request_buyer_phone = $this->_GetBooleanValue($req, "false");
217
- }
218
-
219
- /**
220
- * Sets the information about calculations that will be performed by the
221
- * merchant.
222
- *
223
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_merchant-calculations <merchant-calculations>}
224
- *
225
- * @param string $url the merchant calculations callback url
226
- * @param bool $tax_option true if the merchant has to do tax calculations.
227
- * defaults to false.
228
- * @param bool $coupons true if the merchant accepts discount coupons.
229
- * defaults to false.
230
- * @param bool $gift_cert true if the merchant accepts gift certificates.
231
- * defaults to false.
232
- * @return void
233
- */
234
- function SetMerchantCalculations($url, $tax_option = "false",
235
- $coupons = "false", $gift_cert = "false") {
236
- $this->merchant_calculations_url = $url;
237
- $this->merchant_calculated_tax = $this->_GetBooleanValue($tax_option, "false");
238
- $this->accept_merchant_coupons = $this->_GetBooleanValue($coupons, "false");
239
- $this->accept_gift_certificates = $this->_GetBooleanValue($gift_cert, "false");
240
- }
241
-
242
- /**
243
- * Add an item to the cart.
244
- *
245
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_item <item>}
246
- *
247
- * @param GoogleItem $google_item an object that represents an item
248
- * (defined in googleitem.php)
249
- *
250
- * @return void
251
- */
252
- function AddItem($google_item) {
253
- $this->item_arr[] = $google_item;
254
- }
255
-
256
- /**
257
- * Add a shipping method to the cart.
258
- *
259
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_shipping-methods <shipping-methods>}
260
- *
261
- * @param object $ship an object that represents a shipping method, must be
262
- * one of the methods defined in googleshipping.php
263
- *
264
- * @return void
265
- */
266
- function AddShipping($ship) {
267
- $this->shipping_arr[] = $ship;
268
- }
269
-
270
- /**
271
- * Add a default tax rule to the cart.
272
- *
273
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_default-tax-rule <default-tax-rule>}
274
- *
275
- * @param GoogleDefaultTaxRule $rules an object that represents a default
276
- * tax rule (defined in googletax.php)
277
- *
278
- * @return void
279
- */
280
- function AddDefaultTaxRules($rules) {
281
- $this->default_tax_table = true;
282
- $this->default_tax_rules_arr[] = $rules;
283
- }
284
-
285
- /**
286
- * Add an alternate tax table to the cart.
287
- *
288
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_alternate-tax-table <alternate-tax-table>}
289
- *
290
- * @param GoogleAlternateTaxTable $tax an object that represents an
291
- * alternate tax table
292
- * (defined in googletax.php)
293
- *
294
- * @return void
295
- */
296
- function AddAlternateTaxTables($tax) {
297
- $this->alternate_tax_tables_arr[] = $tax;
298
- }
299
-
300
- /**
301
- * Set the policy to be used to round monetary values.
302
- * Rounding policy explanation here:
303
- * {@link http://code.google.com/apis/checkout/developer/Google_Checkout_Rounding_Policy.html}
304
- *
305
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_rounding-policy <rounding-policy>}
306
- *
307
- * @param string $mode one of "UP", "DOWN", "CEILING", "HALF_DOWN"
308
- * or "HALF_EVEN", described here: {@link http://java.sun.com/j2se/1.5.0/docs/api/java/math/RoundingMode.html}
309
- * @param string $rule one of "PER_LINE", "TOTAL"
310
- *
311
- * @return void
312
- */
313
- function AddRoundingPolicy($mode, $rule) {
314
- switch ($mode) {
315
- case "UP":
316
- case "DOWN":
317
- case "CEILING":
318
- case "HALF_UP":
319
- case "HALF_DOWN":
320
- case "HALF_EVEN":
321
- $this->rounding_mode = $mode;
322
- break;
323
- default:
324
- break;
325
- }
326
- switch ($rule) {
327
- case "PER_LINE":
328
- case "TOTAL":
329
- $this->rounding_rule = $rule;
330
- break;
331
- default:
332
- break;
333
- }
334
- }
335
-
336
- /**
337
- * Set the google analytics data.
338
- *
339
- * {@link http://code.google.com/apis/checkout/developer/checkout_analytics_integration.html info on Checkout and Analytics integration}
340
- *
341
- * @param string $data the analytics data
342
- *
343
- * @return void
344
- */
345
- function SetAnalyticsData($data) {
346
- $this->analytics_data = $data;
347
- }
348
-
349
- /**
350
- * Add a google analytics tracking id.
351
- *
352
- * {@link http://code.google.com/apis/checkout/developer/checkout_analytics_integration.html info on Checkout and Analytics integration}
353
- *
354
- * @param string $GA_id the google analytics id
355
- *
356
- * @return void
357
- */
358
- function AddGoogleAnalyticsTracking($GA_id) {
359
- $this->googleAnalytics_id = $GA_id;
360
- }
361
-
362
- /**
363
- * Add third-party tracking to the cart
364
- *
365
- * Described here:
366
- * {@link http://code.google.com/apis/checkout/developer/checkout_analytics_integration.html#googleCheckoutAnalyticsIntegrationAlternate}
367
- *
368
- * @param $tracking_attr_types attributes to be tracked, one of
369
- * ('buyer-id',
370
- * 'order-id',
371
- * 'order-subtotal',
372
- * 'order-subtotal-plus-tax',
373
- * 'order-subtotal-plus-shipping',
374
- * 'order-total',
375
- * 'tax-amount',
376
- * 'shipping-amount',
377
- * 'coupon-amount',
378
- * 'coupon-amount',
379
- * 'billing-city',
380
- * 'billing-region',
381
- * 'billing-postal-code',
382
- * 'billing-country-code',
383
- * 'shipping-city',
384
- * 'shipping-region',
385
- * 'shipping-postal-code',
386
- * 'shipping-country-code')
387
- * More info http://code.google.com/apis/checkout/developer/checkout_pixel_tracking.html#googleCheckout_tag_url-parameter
388
- */
389
- function AddThirdPartyTracking($url, $tracking_param_types = array()) {
390
- $this->thirdPartyTackingUrl = $url;
391
- $this->thirdPartyTackingParams = $tracking_param_types;
392
- }
393
-
394
- /**
395
- * Builds the cart's xml to be sent to Google Checkout.
396
- *
397
- * @return string the cart's xml
398
- */
399
- function GetXML() {
400
- require_once('xml-processing/gc_xmlbuilder.php');
401
-
402
- $xml_data = new gc_XmlBuilder();
403
-
404
- $xml_data->Push('checkout-shopping-cart',
405
- array('xmlns' => $this->schema_url));
406
- $xml_data->Push('shopping-cart');
407
-
408
- //Add cart expiration if set
409
- if($this->cart_expiration != "") {
410
- $xml_data->Push('cart-expiration');
411
- $xml_data->Element('good-until-date', $this->cart_expiration);
412
- $xml_data->Pop('cart-expiration');
413
- }
414
-
415
- //Add XML data for each of the items
416
- $xml_data->Push('items');
417
- foreach($this->item_arr as $item) {
418
- $xml_data->Push('item');
419
- $xml_data->Element('item-name', $item->item_name);
420
- $xml_data->Element('item-description', $item->item_description);
421
- $xml_data->Element('unit-price', $item->unit_price,
422
- array('currency' => $this->currency));
423
- $xml_data->Element('quantity', $item->quantity);
424
- if($item->merchant_private_item_data != '') {
425
- // echo get_class($item->merchant_private_item_data);
426
- if(is_a($item->merchant_private_item_data,
427
- 'merchantprivate')) {
428
- $item->merchant_private_item_data->AddMerchantPrivateToXML($xml_data);
429
- }
430
- else {
431
- $xml_data->Element('merchant-private-item-data',
432
- $item->merchant_private_item_data);
433
- }
434
- }
435
- if($item->merchant_item_id != '')
436
- $xml_data->Element('merchant-item-id', $item->merchant_item_id);
437
- if($item->tax_table_selector != '')
438
- $xml_data->Element('tax-table-selector', $item->tax_table_selector);
439
- // Carrier calculation
440
- if($item->item_weight != '' && $item->numeric_weight !== '') {
441
- $xml_data->EmptyElement('item-weight', array( 'unit' => $item->item_weight,
442
- 'value' => $item->numeric_weight
443
- ));
444
- }
445
- // New Digital Delivery Tags
446
- if($item->digital_content) {
447
- $xml_data->push('digital-content');
448
- if(!empty($item->digital_url)) {
449
- $xml_data->element('description', substr($item->digital_description,
450
- 0, MAX_DIGITAL_DESC));
451
- $xml_data->element('url', $item->digital_url);
452
- // To avoid NULL key message in GC confirmation Page
453
- if(!empty($item->digital_key)) {
454
- $xml_data->element('key', $item->digital_key);
455
- }
456
- }
457
- else {
458
- $xml_data->element('email-delivery',
459
- $this->_GetBooleanValue($item->email_delivery, "true"));
460
- }
461
- $xml_data->pop('digital-content');
462
- }
463
- $xml_data->Pop('item');
464
- }
465
- $xml_data->Pop('items');
466
-
467
- if($this->merchant_private_data != '') {
468
- if(is_a($this->merchant_private_data, 'merchantprivate')) {
469
- $this->merchant_private_data->AddMerchantPrivateToXML($xml_data);
470
- }
471
- else {
472
- $xml_data->Element('merchant-private-data',
473
- $this->merchant_private_data);
474
- }
475
- }
476
- $xml_data->Pop('shopping-cart');
477
-
478
- $xml_data->Push('checkout-flow-support');
479
- $xml_data->Push('merchant-checkout-flow-support');
480
- if($this->edit_cart_url != '')
481
- $xml_data->Element('edit-cart-url', $this->edit_cart_url);
482
- if($this->continue_shopping_url != '')
483
- $xml_data->Element('continue-shopping-url',
484
- $this->continue_shopping_url);
485
-
486
- if(count($this->shipping_arr) > 0)
487
- $xml_data->Push('shipping-methods');
488
-
489
- //Add the shipping methods
490
- foreach($this->shipping_arr as $ship) {
491
- //Pickup shipping handled in else part
492
- if($ship->type == "flat-rate-shipping" ||
493
- $ship->type == "merchant-calculated-shipping"
494
- // If shipping-company calc support addr-filtering and shipping restrictions as a subatag of shipping-company-calculated-shipping
495
- // ||$ship->type == "shipping-company-calculated-shipping"
496
- ) {
497
- $xml_data->Push($ship->type, array('name' => $ship->name));
498
- $xml_data->Element('price', $ship->price,
499
- array('currency' => $this->currency));
500
-
501
- $shipping_restrictions = $ship->shipping_restrictions;
502
- if (isset($shipping_restrictions)) {
503
- $xml_data->Push('shipping-restrictions');
504
-
505
- if ($shipping_restrictions->allow_us_po_box === true) {
506
- $xml_data->Element('allow-us-po-box', "true");
507
- } else {
508
- $xml_data->Element('allow-us-po-box', "false");
509
- }
510
-
511
- //Check if allowed restrictions specified
512
- if($shipping_restrictions->allowed_restrictions) {
513
- $xml_data->Push('allowed-areas');
514
- if($shipping_restrictions->allowed_country_area != "")
515
- $xml_data->EmptyElement('us-country-area',
516
- array('country-area' =>
517
- $shipping_restrictions->allowed_country_area));
518
- foreach($shipping_restrictions->allowed_state_areas_arr as $current) {
519
- $xml_data->Push('us-state-area');
520
- $xml_data->Element('state', $current);
521
- $xml_data->Pop('us-state-area');
522
- }
523
- foreach($shipping_restrictions->allowed_zip_patterns_arr as $current) {
524
- $xml_data->Push('us-zip-area');
525
- $xml_data->Element('zip-pattern', $current);
526
- $xml_data->Pop('us-zip-area');
527
- }
528
- if($shipping_restrictions->allowed_world_area === true) {
529
- $xml_data->EmptyElement('world-area');
530
- }
531
- for($i=0; $i<count($shipping_restrictions->allowed_country_codes_arr); $i++) {
532
- $xml_data->Push('postal-area');
533
- $country_code = $shipping_restrictions->allowed_country_codes_arr[$i];
534
- $postal_pattern = $shipping_restrictions->allowed_postal_patterns_arr[$i];
535
- $xml_data->Element('country-code', $country_code);
536
- if ($postal_pattern != "") {
537
- $xml_data->Element('postal-code-pattern', $postal_pattern);
538
- }
539
- $xml_data->Pop('postal-area');
540
- }
541
- $xml_data->Pop('allowed-areas');
542
- }
543
-
544
- if($shipping_restrictions->excluded_restrictions) {
545
- if (!$shipping_restrictions->allowed_restrictions) {
546
- $xml_data->EmptyElement('allowed-areas');
547
- }
548
- $xml_data->Push('excluded-areas');
549
- if($shipping_restrictions->excluded_country_area != "")
550
- $xml_data->EmptyElement('us-country-area',
551
- array('country-area' =>
552
- $shipping_restrictions->excluded_country_area));
553
- foreach($shipping_restrictions->excluded_state_areas_arr as $current) {
554
- $xml_data->Push('us-state-area');
555
- $xml_data->Element('state', $current);
556
- $xml_data->Pop('us-state-area');
557
- }
558
- foreach($shipping_restrictions->excluded_zip_patterns_arr as $current) {
559
- $xml_data->Push('us-zip-area');
560
- $xml_data->Element('zip-pattern', $current);
561
- $xml_data->Pop('us-zip-area');
562
- }
563
- for($i=0; $i<count($shipping_restrictions->excluded_country_codes_arr); $i++) {
564
- $xml_data->Push('postal-area');
565
- $country_code = $shipping_restrictions->excluded_country_codes_arr[$i];
566
- $postal_pattern = $shipping_restrictions->excluded_postal_patterns_arr[$i];
567
- $xml_data->Element('country-code', $country_code);
568
- if ($postal_pattern != "") {
569
- $xml_data->Element('postal-code-pattern', $postal_pattern);
570
- }
571
- $xml_data->Pop('postal-area');
572
- }
573
- $xml_data->Pop('excluded-areas');
574
- }
575
- $xml_data->Pop('shipping-restrictions');
576
- }
577
-
578
- if ($ship->type == "merchant-calculated-shipping") {
579
- $address_filters = $ship->address_filters;
580
- if (isset($address_filters)) {
581
- $xml_data->Push('address-filters');
582
-
583
- if ($address_filters->allow_us_po_box === true) {
584
- $xml_data->Element('allow-us-po-box', "true");
585
- } else {
586
- $xml_data->Element('allow-us-po-box', "false");
587
- }
588
-
589
- //Check if allowed restrictions specified
590
- if($address_filters->allowed_restrictions) {
591
- $xml_data->Push('allowed-areas');
592
- if($address_filters->allowed_country_area != "")
593
- $xml_data->EmptyElement('us-country-area',
594
- array('country-area' =>
595
- $address_filters->allowed_country_area));
596
- foreach($address_filters->allowed_state_areas_arr as $current) {
597
- $xml_data->Push('us-state-area');
598
- $xml_data->Element('state', $current);
599
- $xml_data->Pop('us-state-area');
600
- }
601
- foreach($address_filters->allowed_zip_patterns_arr as $current) {
602
- $xml_data->Push('us-zip-area');
603
- $xml_data->Element('zip-pattern', $current);
604
- $xml_data->Pop('us-zip-area');
605
- }
606
- if($address_filters->allowed_world_area === true) {
607
- $xml_data->EmptyElement('world-area');
608
- }
609
- for($i=0; $i<count($address_filters->allowed_country_codes_arr); $i++) {
610
- $xml_data->Push('postal-area');
611
- $country_code = $address_filters->allowed_country_codes_arr[$i];
612
- $postal_pattern = $address_filters->allowed_postal_patterns_arr[$i];
613
- $xml_data->Element('country-code', $country_code);
614
- if ($postal_pattern != "") {
615
- $xml_data->Element('postal-code-pattern', $postal_pattern);
616
- }
617
- $xml_data->Pop('postal-area');
618
- }
619
- $xml_data->Pop('allowed-areas');
620
- }
621
-
622
- if($address_filters->excluded_restrictions) {
623
- if (!$address_filters->allowed_restrictions) {
624
- $xml_data->EmptyElement('allowed-areas');
625
- }
626
- $xml_data->Push('excluded-areas');
627
- if($address_filters->excluded_country_area != "")
628
- $xml_data->EmptyElement('us-country-area',
629
- array('country-area' =>
630
- $address_filters->excluded_country_area));
631
- foreach($address_filters->excluded_state_areas_arr as $current) {
632
- $xml_data->Push('us-state-area');
633
- $xml_data->Element('state', $current);
634
- $xml_data->Pop('us-state-area');
635
- }
636
- foreach($address_filters->excluded_zip_patterns_arr as $current) {
637
- $xml_data->Push('us-zip-area');
638
- $xml_data->Element('zip-pattern', $current);
639
- $xml_data->Pop('us-zip-area');
640
- }
641
- for($i=0; $i<count($address_filters->excluded_country_codes_arr); $i++) {
642
- $xml_data->Push('postal-area');
643
- $country_code = $address_filters->excluded_country_codes_arr[$i];
644
- $postal_pattern = $address_filters->excluded_postal_patterns_arr[$i];
645
- $xml_data->Element('country-code', $country_code);
646
- if ($postal_pattern != "") {
647
- $xml_data->Element('postal-code-pattern', $postal_pattern);
648
- }
649
- $xml_data->Pop('postal-area');
650
- }
651
- $xml_data->Pop('excluded-areas');
652
- }
653
- $xml_data->Pop('address-filters');
654
- }
655
- }
656
- $xml_data->Pop($ship->type);
657
- }
658
- else if ($ship->type == "carrier-calculated-shipping"){
659
- // $xml_data->Push($ship->type, array('name' => $ship->name));
660
- $xml_data->Push($ship->type);
661
- $xml_data->Push('carrier-calculated-shipping-options');
662
- $CCSoptions = $ship->CarrierCalculatedShippingOptions;
663
- foreach($CCSoptions as $CCSoption){
664
- $xml_data->Push('carrier-calculated-shipping-option');
665
- $xml_data->Element('price', $CCSoption->price,
666
- array('currency' => $this->currency));
667
- $xml_data->Element('shipping-company', $CCSoption->shipping_company);
668
- $xml_data->Element('shipping-type', $CCSoption->shipping_type);
669
- $xml_data->Element('carrier-pickup', $CCSoption->carrier_pickup);
670
- if(!empty($CCSoption->additional_fixed_charge)) {
671
- $xml_data->Element('additional-fixed-charge',
672
- $CCSoption->additional_fixed_charge,
673
- array('currency' => $this->currency));
674
- }
675
- if(!empty($CCSoption->additional_variable_charge_percent)) {
676
- $xml_data->Element('additional-variable-charge-percent',
677
- $CCSoption->additional_variable_charge_percent);
678
- }
679
- $xml_data->Pop('carrier-calculated-shipping-option');
680
- }
681
- $xml_data->Pop('carrier-calculated-shipping-options');
682
- // $ShippingPackage = $ship->ShippingPackage;
683
- $xml_data->Push('shipping-packages');
684
- $xml_data->Push('shipping-package');
685
- $xml_data->Push('ship-from', array('id' => $ship->ShippingPackage->ship_from->id));
686
- $xml_data->Element('city', $ship->ShippingPackage->ship_from->city);
687
- $xml_data->Element('region', $ship->ShippingPackage->ship_from->region);
688
- $xml_data->Element('postal-code', $ship->ShippingPackage->ship_from->postal_code);
689
- $xml_data->Element('country-code', $ship->ShippingPackage->ship_from->country_code);
690
- $xml_data->Pop('ship-from');
691
-
692
- $xml_data->EmptyElement('width', array('unit' => $ship->ShippingPackage->unit,
693
- 'value' => $ship->ShippingPackage->width
694
- ));
695
- $xml_data->EmptyElement('length', array('unit' => $ship->ShippingPackage->unit,
696
- 'value' => $ship->ShippingPackage->length
697
- ));
698
- $xml_data->EmptyElement('height', array('unit' => $ship->ShippingPackage->unit,
699
- 'value' => $ship->ShippingPackage->height
700
- ));
701
- $xml_data->Element('delivery-address-category',
702
- $ship->ShippingPackage->delivery_address_category);
703
- $xml_data->Pop('shipping-package');
704
- $xml_data->Pop('shipping-packages');
705
-
706
- $xml_data->Pop($ship->type);
707
- }
708
- else if ($ship->type == "pickup") {
709
- $xml_data->Push('pickup', array('name' => $ship->name));
710
- $xml_data->Element('price', $ship->price,
711
- array('currency' => $this->currency));
712
- $xml_data->Pop('pickup');
713
- }
714
- }
715
- if(count($this->shipping_arr) > 0)
716
- $xml_data->Pop('shipping-methods');
717
-
718
- if($this->request_buyer_phone != "")
719
- $xml_data->Element('request-buyer-phone-number',
720
- $this->request_buyer_phone);
721
-
722
- if($this->merchant_calculations_url != "") {
723
- $xml_data->Push('merchant-calculations');
724
- $xml_data->Element('merchant-calculations-url',
725
- $this->merchant_calculations_url);
726
- if($this->accept_merchant_coupons != "") {
727
- $xml_data->Element('accept-merchant-coupons',
728
- $this->accept_merchant_coupons);
729
- }
730
- if($this->accept_gift_certificates != "") {
731
- $xml_data->Element('accept-gift-certificates',
732
- $this->accept_gift_certificates);
733
- }
734
- $xml_data->Pop('merchant-calculations');
735
- }
736
- //Set Third party Tracking
737
- if($this->thirdPartyTackingUrl) {
738
- $xml_data->push('parameterized-urls');
739
- $xml_data->push('parameterized-url',
740
- array('url' => $this->thirdPartyTackingUrl));
741
- if(is_array($this->thirdPartyTackingParams)
742
- && count($this->thirdPartyTackingParams)>0) {
743
- $xml_data->push('parameters');
744
- foreach($this->thirdPartyTackingParams as $tracking_param_name =>
745
- $tracking_param_type) {
746
- $xml_data->emptyElement('url-parameter',
747
- array('name' => $tracking_param_name,
748
- 'type' => $tracking_param_type));
749
- }
750
- $xml_data->pop('parameters');
751
- }
752
- $xml_data->pop('parameterized-url');
753
- $xml_data->pop('parameterized-urls');
754
- }
755
-
756
- //Set Default and Alternate tax tables
757
- if( (count($this->alternate_tax_tables_arr) != 0)
758
- || (count($this->default_tax_rules_arr) != 0)) {
759
- if($this->merchant_calculated_tax != "") {
760
- $xml_data->Push('tax-tables',
761
- array('merchant-calculated' => $this->merchant_calculated_tax));
762
- }
763
- else {
764
- $xml_data->Push('tax-tables');
765
- }
766
- if(count($this->default_tax_rules_arr) != 0) {
767
- $xml_data->Push('default-tax-table');
768
- $xml_data->Push('tax-rules');
769
- foreach($this->default_tax_rules_arr as $curr_rule) {
770
-
771
- if($curr_rule->country_area != "") {
772
- $xml_data->Push('default-tax-rule');
773
- $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
774
- $xml_data->Element('rate', $curr_rule->tax_rate);
775
- $xml_data->Push('tax-area');
776
- $xml_data->EmptyElement('us-country-area',
777
- array('country-area' => $curr_rule->country_area));
778
- $xml_data->Pop('tax-area');
779
- $xml_data->Pop('default-tax-rule');
780
- }
781
-
782
- foreach($curr_rule->state_areas_arr as $current) {
783
- $xml_data->Push('default-tax-rule');
784
- $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
785
- $xml_data->Element('rate', $curr_rule->tax_rate);
786
- $xml_data->Push('tax-area');
787
- $xml_data->Push('us-state-area');
788
- $xml_data->Element('state', $current);
789
- $xml_data->Pop('us-state-area');
790
- $xml_data->Pop('tax-area');
791
- $xml_data->Pop('default-tax-rule');
792
- }
793
-
794
- foreach($curr_rule->zip_patterns_arr as $current) {
795
- $xml_data->Push('default-tax-rule');
796
- $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
797
- $xml_data->Element('rate', $curr_rule->tax_rate);
798
- $xml_data->Push('tax-area');
799
- $xml_data->Push('us-zip-area');
800
- $xml_data->Element('zip-pattern', $current);
801
- $xml_data->Pop('us-zip-area');
802
- $xml_data->Pop('tax-area');
803
- $xml_data->Pop('default-tax-rule');
804
- }
805
-
806
- for($i=0; $i<count($curr_rule->country_codes_arr); $i++) {
807
- $xml_data->Push('default-tax-rule');
808
- $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
809
- $xml_data->Element('rate', $curr_rule->tax_rate);
810
- $xml_data->Push('tax-area');
811
- $xml_data->Push('postal-area');
812
- $country_code = $curr_rule->country_codes_arr[$i];
813
- $postal_pattern = $curr_rule->postal_patterns_arr[$i];
814
- $xml_data->Element('country-code', $country_code);
815
- if ($postal_pattern != "") {
816
- $xml_data->Element('postal-code-pattern', $postal_pattern);
817
- }
818
- $xml_data->Pop('postal-area');
819
- $xml_data->Pop('tax-area');
820
- $xml_data->Pop('default-tax-rule');
821
- }
822
-
823
- if ($curr_rule->world_area === true) {
824
- $xml_data->Push('default-tax-rule');
825
- $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
826
- $xml_data->Element('rate', $curr_rule->tax_rate);
827
- $xml_data->Push('tax-area');
828
- $xml_data->EmptyElement('world-area');
829
- $xml_data->Pop('tax-area');
830
- $xml_data->Pop('default-tax-rule');
831
- }
832
- }
833
- $xml_data->Pop('tax-rules');
834
- $xml_data->Pop('default-tax-table');
835
- }
836
-
837
- if(count($this->alternate_tax_tables_arr) != 0) {
838
- $xml_data->Push('alternate-tax-tables');
839
- foreach($this->alternate_tax_tables_arr as $curr_table) {
840
- $xml_data->Push('alternate-tax-table',
841
- array('standalone' => $curr_table->standalone,
842
- 'name' => $curr_table->name));
843
- $xml_data->Push('alternate-tax-rules');
844
-
845
- foreach($curr_table->tax_rules_arr as $curr_rule) {
846
- if($curr_rule->country_area != "") {
847
- $xml_data->Push('alternate-tax-rule');
848
- $xml_data->Element('rate', $curr_rule->tax_rate);
849
- $xml_data->Push('tax-area');
850
- $xml_data->EmptyElement('us-country-area',
851
- array('country-area' => $curr_rule->country_area));
852
- $xml_data->Pop('tax-area');
853
- $xml_data->Pop('alternate-tax-rule');
854
- }
855
-
856
- foreach($curr_rule->state_areas_arr as $current) {
857
- $xml_data->Push('alternate-tax-rule');
858
- $xml_data->Element('rate', $curr_rule->tax_rate);
859
- $xml_data->Push('tax-area');
860
- $xml_data->Push('us-state-area');
861
- $xml_data->Element('state', $current);
862
- $xml_data->Pop('us-state-area');
863
- $xml_data->Pop('tax-area');
864
- $xml_data->Pop('alternate-tax-rule');
865
- }
866
-
867
- foreach($curr_rule->zip_patterns_arr as $current) {
868
- $xml_data->Push('alternate-tax-rule');
869
- $xml_data->Element('rate', $curr_rule->tax_rate);
870
- $xml_data->Push('tax-area');
871
- $xml_data->Push('us-zip-area');
872
- $xml_data->Element('zip-pattern', $current);
873
- $xml_data->Pop('us-zip-area');
874
- $xml_data->Pop('tax-area');
875
- $xml_data->Pop('alternate-tax-rule');
876
- }
877
-
878
- for($i=0; $i<count($curr_rule->country_codes_arr); $i++) {
879
- $xml_data->Push('alternate-tax-rule');
880
- $xml_data->Element('rate', $curr_rule->tax_rate);
881
- $xml_data->Push('tax-area');
882
- $xml_data->Push('postal-area');
883
- $country_code = $curr_rule->country_codes_arr[$i];
884
- $postal_pattern = $curr_rule->postal_patterns_arr[$i];
885
- $xml_data->Element('country-code', $country_code);
886
- if ($postal_pattern != "") {
887
- $xml_data->Element('postal-code-pattern', $postal_pattern);
888
- }
889
- $xml_data->Pop('postal-area');
890
- $xml_data->Pop('tax-area');
891
- $xml_data->Pop('alternate-tax-rule');
892
- }
893
-
894
- if ($curr_rule->world_area === true) {
895
- $xml_data->Push('alternate-tax-rule');
896
- $xml_data->Element('rate', $curr_rule->tax_rate);
897
- $xml_data->Push('tax-area');
898
- $xml_data->EmptyElement('world-area');
899
- $xml_data->Pop('tax-area');
900
- $xml_data->Pop('alternate-tax-rule');
901
- }
902
- }
903
- $xml_data->Pop('alternate-tax-rules');
904
- $xml_data->Pop('alternate-tax-table');
905
- }
906
- $xml_data->Pop('alternate-tax-tables');
907
- }
908
- $xml_data->Pop('tax-tables');
909
- }
910
-
911
- if (($this->rounding_mode != "") && ($this->rounding_rule != "")) {
912
- $xml_data->Push('rounding-policy');
913
- $xml_data->Element('mode', $this->rounding_mode);
914
- $xml_data->Element('rule', $this->rounding_rule);
915
- $xml_data->Pop('rounding-policy');
916
- }
917
- if($this->analytics_data != ''){
918
- $xml_data->Element('analytics-data', $this->analytics_data);
919
- }
920
-
921
- $xml_data->Pop('merchant-checkout-flow-support');
922
- $xml_data->Pop('checkout-flow-support');
923
- $xml_data->Pop('checkout-shopping-cart');
924
-
925
- return $xml_data->GetXML();
926
- }
927
-
928
- /**
929
- * Set the Google Checkout button's variant.
930
- * {@link http://code.google.com/apis/checkout/developer/index.html#google_checkout_buttons}
931
- *
932
- * @param bool $variant true for an enabled button, false for a
933
- * disabled one
934
- *
935
- * @return void
936
- */
937
- function SetButtonVariant($variant) {
938
- switch ($variant) {
939
- case false:
940
- $this->variant = "disabled";
941
- break;
942
- case true:
943
- default:
944
- $this->variant = "text";
945
- break;
946
- }
947
- }
948
-
949
- /**
950
- * Submit a server-to-server request.
951
- * Creates a GoogleRequest object (defined in googlerequest.php) and sends
952
- * it to the Google Checkout server.
953
- *
954
- * more info:
955
- * {@link http://code.google.com/apis/checkout/developer/index.html#alternate_technique}
956
- *
957
- * @return array with the returned http status code (200 if OK) in index 0
958
- * and the redirect url returned by the server in index 1
959
- */
960
- function CheckoutServer2Server($proxy=array(), $certPath='') {
961
- ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.'.');
962
- require_once('library/googlerequest.php');
963
- $GRequest = new GoogleRequest($this->merchant_id,
964
- $this->merchant_key,
965
- $this->server_url=="https://checkout.google.com/"?
966
- "Production":"sandbox",
967
- $this->currency);
968
- $GRequest->SetProxy($proxy);
969
- $GRequest->SetCertificatePath($certPath);
970
-
971
- return $GRequest->SendServer2ServerCart($this->GetXML());
972
- }
973
-
974
- /**
975
- * Get the Google Checkout button's html to be used in a server-to-server
976
- * request.
977
- *
978
- * {@link http://code.google.com/apis/checkout/developer/index.html#google_checkout_buttons}
979
- *
980
- * @param string $url the merchant's site url where the form will be posted
981
- * to
982
- * @param string $size the size of the button, one of 'large', 'medium' or
983
- * 'small'.
984
- * defaults to 'large'
985
- * @param bool $variant true for an enabled button, false for a
986
- * disabled one. defaults to true. will be ignored if
987
- * SetButtonVariant() was used before.
988
- * @param string $loc the locale of the button's text, the only valid value
989
- * is 'en_US' (used as default)
990
- * @param bool $showtext whether to show Google Checkout text or not,
991
- * defaults to true.
992
- * @param string $style the background style of the button, one of 'white'
993
- * or 'trans'. defaults to "trans"
994
- *
995
- * @return string the button's html
996
- */
997
- function CheckoutServer2ServerButton($url, $size="large", $variant=true,
998
- $loc="en_US",$showtext=true, $style="trans") {
999
-
1000
- switch (strtolower($size)) {
1001
- case "medium":
1002
- $width = "168";
1003
- $height = "44";
1004
- break;
1005
-
1006
- case "small":
1007
- $width = "160";
1008
- $height = "43";
1009
- break;
1010
- case "large":
1011
- default:
1012
- $width = "180";
1013
- $height = "46";
1014
- break;
1015
- }
1016
-
1017
- if($this->variant == false) {
1018
- switch ($variant) {
1019
- case false:
1020
- $this->variant = "disabled";
1021
- break;
1022
- case true:
1023
- default:
1024
- $this->variant = "text";
1025
- break;
1026
- }
1027
- }
1028
- $data = "<div style=\"width: ".$width."px\">";
1029
- if ($this->variant == "text") {
1030
- $data .= "<div align=center><form method=\"POST\" action=\"".
1031
- $url . "\"" . ($this->googleAnalytics_id?
1032
- " onsubmit=\"setUrchinInputCode();\"":"") . ">
1033
- <input type=\"image\" name=\"Checkout\" alt=\"Checkout\"
1034
- src=\"". $this->server_url."buttons/checkout.gif?merchant_id=" .
1035
- $this->merchant_id."&w=".$width. "&h=".$height."&style=".
1036
- $style."&variant=".$this->variant."&loc=".$loc."\"
1037
- height=\"".$height."\" width=\"".$width. "\" />";
1038
-
1039
- if($this->googleAnalytics_id) {
1040
- $data .= "<input type=\"hidden\" name=\"analyticsdata\" value=\"\">";
1041
- }
1042
- $data .= "</form></div>";
1043
- if($this->googleAnalytics_id) {
1044
- $data .= "<!-- Start Google analytics -->
1045
- <script src=\"https://ssl.google-analytics.com/urchin.js\" type=\"".
1046
- "text/javascript\">
1047
- </script>
1048
- <script type=\"text/javascript\">
1049
- _uacct = \"" . $this->googleAnalytics_id . "\";
1050
- urchinTracker();
1051
- </script>
1052
- <script src=\"https://checkout.google.com/files/digital/urchin_po" .
1053
- "st.js\" type=\"text/javascript\"></script>
1054
- <!-- End Google analytics -->";
1055
- } } else {
1056
- $data .= "<div><img alt=\"Checkout\" src=\"" .
1057
- "". $this->server_url."buttons/checkout.gif?merchant_id=" .
1058
- "".$this->merchant_id."&w=".$width. "&h=".$height."&style=".$style.
1059
- "&variant=".$this->variant."&loc=".$loc."\" height=\"".$height."\"".
1060
- " width=\"".$width. "\" /></div>";
1061
-
1062
- }
1063
- $data .= "</div>";
1064
- return $data;
1065
- }
1066
-
1067
- /**
1068
- * Get the Google Checkout button's html.
1069
- *
1070
- * {@link http://code.google.com/apis/checkout/developer/index.html#google_checkout_buttons}
1071
- *
1072
- * @param string $size the size of the button, one of 'large', 'medium' or
1073
- * 'small'.
1074
- * defaults to 'large'
1075
- * @param bool $variant true for an enabled button, false for a
1076
- * disabled one. defaults to true. will be ignored if
1077
- * SetButtonVariant() was used before.
1078
- * @param string $loc the locale of the button's text, the only valid value
1079
- * is 'en_US' (used as default)
1080
- * @param bool $showtext whether to show Google Checkout text or not,
1081
- * defaults to true.
1082
- * @param string $style the background style of the button, one of 'white'
1083
- * or 'trans'. defaults to "trans"
1084
- *
1085
- * @return string the button's html
1086
- */
1087
- function CheckoutButtonCode($size="large", $variant=true, $loc="en_US",
1088
- $showtext=true, $style="trans") {
1089
-
1090
- switch (strtolower($size)) {
1091
- case "medium":
1092
- $width = "168";
1093
- $height = "44";
1094
- break;
1095
-
1096
- case "small":
1097
- $width = "160";
1098
- $height = "43";
1099
- break;
1100
- case "large":
1101
- default:
1102
- $width = "180";
1103
- $height = "46";
1104
- break;
1105
- }
1106
-
1107
- if($this->variant == false) {
1108
- switch ($variant) {
1109
- case false:
1110
- $this->variant = "disabled";
1111
- break;
1112
- case true:
1113
- default:
1114
- $this->variant = "text";
1115
- break;
1116
- }
1117
- }
1118
-
1119
-
1120
- $data = "<div style=\"width: ".$width."px\">";
1121
- if ($this->variant == "text") {
1122
- $postcart = base64_encode($this->GetXML());
1123
- $postsignature = base64_encode($this->CalcHmacSha1($this->GetXML()));
1124
- $postdata['cart']=$postcart;
1125
- $postdata['signature']=$postsignature;
1126
- //$postdata = "cart=".$postcart."&amp;signature=".$postsignature;
1127
- //exit("<pre>".print_r($this->GetXML(),1)."</pre>");
1128
- // $_SESSION['post_url'] = $this->checkout_url;
1129
- $_SESSION['postcart'] = $postcart;
1130
- $_SESSION['postsignature'] = $postsignature;
1131
-
1132
- $data .= "<div align=center><form method=\"POST\" action=\"".
1133
- $this->checkout_url . "\"" . ($this->googleAnalytics_id?
1134
- " onsubmit=\"setUrchinInputCode();\"":"") . ">
1135
- <input type=\"hidden\" name=\"cart\" value=\"".
1136
- base64_encode($this->GetXML()) ."\">
1137
- <input type=\"hidden\" name=\"signature\" value=\"".
1138
- base64_encode($this->CalcHmacSha1($this->GetXML())). "\">
1139
- <input type=\"image\" name=\"Checkout\" alt=\"Checkout\"
1140
- src=\"". $this->server_url."buttons/checkout.gif?merchant_id=" .
1141
- $this->merchant_id."&w=".$width. "&h=".$height."&style=".
1142
- $style."&variant=".$this->variant."&loc=".$loc."\"
1143
- height=\"".$height."\" width=\"".$width. "\" />";
1144
-
1145
- if($this->googleAnalytics_id) {
1146
- $data .= "<input type=\"hidden\" name=\"analyticsdata\" value=\"\">";
1147
- }
1148
- $data .= "</form></div>";
1149
- if($this->googleAnalytics_id) {
1150
- $data .= "<!-- Start Google analytics -->
1151
- <script src=\"https://ssl.google-analytics.com/urchin.js\" type=\"".
1152
- "text/javascript\">
1153
- </script>
1154
- <script type=\"text/javascript\">
1155
- _uacct = \"" . $this->googleAnalytics_id . "\";
1156
- urchinTracker();
1157
- </script>
1158
- <script src=\"https://checkout.google.com/files/digital/urchin_po" .
1159
- "st.js\" type=\"text/javascript\"></script>
1160
- <!-- End Google analytics -->";
1161
- }
1162
- } else {
1163
- $data .= "<div><img alt=\"Checkout\" src=\"" .
1164
- "". $this->server_url."buttons/checkout.gif?merchant_id=" .
1165
- "".$this->merchant_id."&w=".$width. "&h=".$height."&style=".$style.
1166
- "&variant=".$this->variant."&loc=".$loc."\" height=\"".$height."\"".
1167
- " width=\"".$width. "\" /></div>";
1168
- }
1169
-
1170
- $data .= "</div>";
1171
- //$transmit_response = SendRequest($postdata, $this->checkout_url);
1172
- //Process the response by redirecting the user to the checkout redirect URL
1173
- //ProcessXmlData($transmit_response);
1174
- //http_post_data($this->checkout_url, $postdata);// ob_start();
1175
- // $postdata = "cart=". base64_encode($this->GetXML())."&signature=". base64_encode($this->CalcHmacSha1($this->GetXML()));
1176
- // $ch = curl_init();
1177
- // curl_setopt($ch, CURLOPT_URL,$this->checkout_url);
1178
- // curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
1179
- // //curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
1180
- // curl_exec($ch);
1181
- // $returned_value = ob_get_contents();
1182
- // exit($returned_value);
1183
- // ob_end_clean();
1184
-
1185
- //ob_start();
1186
- //$postdata = "cart=". base64_encode($this->GetXML())."&signature=". base64_encode($this->CalcHmacSha1($this->GetXML()));
1187
- $ch = curl_init();
1188
- curl_setopt($ch, CURLOPT_URL,$this->checkout_url);
1189
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1190
- curl_setopt($ch, CURLOPT_POST, 1);
1191
- curl_setopt($ch, CURLOPT_HEADER, 0);
1192
- // exit($this->checkout_url);
1193
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
1194
- //curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
1195
- $result = curl_exec($ch);
1196
- $googlelink=explode("HREF=", $result);
1197
- $googlelink=$googlelink[1];
1198
- $googlelink=explode(">", $googlelink);
1199
- $googlelink=$googlelink[0];
1200
- $googlelink=explode("\"", $googlelink);
1201
- $googlelink=$googlelink[1];
1202
- $googlelink=str_replace('&amp;','&',$googlelink);
1203
- //exit($googlelink);
1204
- //header("Location:$googlelink");
1205
-
1206
- //ob_end_clean();
1207
- //return $data;
1208
- }
1209
- //Code for generating Checkout button
1210
- //@param $variant will be ignored if SetButtonVariant() was used before
1211
- function CheckoutButtonNowCode($size="large", $variant=true, $loc="en_US",
1212
- $showtext=true, $style="trans") {
1213
-
1214
- switch (strtolower($size)) {
1215
- case "small":
1216
- $width = "121";
1217
- $height = "44";
1218
- break;
1219
- case "large":
1220
- default:
1221
- $width = "117";
1222
- $height = "48";
1223
- break;
1224
- }
1225
-
1226
- if($this->variant == false) {
1227
- switch ($variant) {
1228
- case false:
1229
- $this->variant = "disabled";
1230
- break;
1231
- case true:
1232
- default:
1233
- $this->variant = "text";
1234
- break;
1235
- }
1236
- }
1237
-
1238
-
1239
-
1240
- $data = "<div style=\"width: ".$width."px\">";
1241
- if ($this->variant == "text") {
1242
- $data .= "<div align=center><form method=\"POST\" action=\"".
1243
- $this->checkout_url . "\"" . ($this->googleAnalytics_id?
1244
- " onsubmit=\"setUrchinInputCode();\"":"") . ">
1245
- <input type=\"hidden\" name=\"buyButtonCart\" value=\"".
1246
- base64_encode($this->GetXML()) ."//separator//" .
1247
- base64_encode($this->CalcHmacSha1($this->GetXML())) . "\">
1248
- <input type=\"image\" name=\"Checkout\" alt=\"BuyNow\"
1249
- src=\"". $this->server_url."buttons/buy.gif?merchant_id=" .
1250
- $this->merchant_id."&w=".$width. "&h=".$height."&style=".
1251
- $style."&variant=".$this->variant."&loc=".$loc."\"
1252
- height=\"".$height."\" width=\"".$width. "\" />";
1253
-
1254
- if($this->googleAnalytics_id) {
1255
- $data .= "<input type=\"hidden\" name=\"analyticsdata\" value=\"\">";
1256
- }
1257
- $data .= "</form></div>";
1258
- if($this->googleAnalytics_id) {
1259
- $data .= "<!-- Start Google analytics -->
1260
- <script src=\"https://ssl.google-analytics.com/urchin.js\" type=\"".
1261
- "text/javascript\">
1262
- </script>
1263
- <script type=\"text/javascript\">
1264
- _uacct = \"" . $this->googleAnalytics_id . "\";
1265
- urchinTracker();
1266
- </script>
1267
- <script src=\"https://checkout.google.com/files/digital/urchin_po" .
1268
- "st.js\" type=\"text/javascript\"></script>
1269
- <!-- End Google analytics -->";
1270
- }
1271
- // ask for link to BuyNow disable button
1272
- } else {
1273
- $data .= "<div><img alt=\"Checkout\" src=\"" .
1274
- "". $this->server_url."buttons/buy.gif?merchant_id=" .
1275
- "".$this->merchant_id."&w=".$width. "&h=".$height."&style=".$style.
1276
- "&variant=".$this->variant."&loc=".$loc."\" height=\"".$height."\"".
1277
- " width=\"".$width. "\" /></div>";
1278
- }
1279
- $data .= "</div>";
1280
- return $data;
1281
- }
1282
-
1283
-
1284
- /**
1285
- * Get the Google Checkout button's html to be used with the html api.
1286
- *
1287
- * {@link http://code.google.com/apis/checkout/developer/index.html#google_checkout_buttons}
1288
- *
1289
- * @param string $size the size of the button, one of 'large', 'medium' or
1290
- * 'small'.
1291
- * defaults to 'large'
1292
- * @param bool $variant true for an enabled button, false for a
1293
- * disabled one. defaults to true. will be ignored if
1294
- * SetButtonVariant() was used before.
1295
- * @param string $loc the locale of the button's text, the only valid value
1296
- * is 'en_US' (used as default)
1297
- * @param bool $showtext whether to show Google Checkout text or not,
1298
- * defaults to true.
1299
- * @param string $style the background style of the button, one of 'white'
1300
- * or 'trans'. defaults to "trans"
1301
- *
1302
- * @return string the button's html
1303
- */
1304
- function CheckoutHTMLButtonCode($size="large", $variant=true, $loc="en_US",
1305
- $showtext=true, $style="trans") {
1306
-
1307
- switch (strtolower($size)) {
1308
- case "medium":
1309
- $width = "168";
1310
- $height = "44";
1311
- break;
1312
-
1313
- case "small":
1314
- $width = "160";
1315
- $height = "43";
1316
- break;
1317
- case "large":
1318
- default:
1319
- $width = "180";
1320
- $height = "46";
1321
- break;
1322
- }
1323
-
1324
- if($this->variant == false) {
1325
- switch ($variant) {
1326
- case false:
1327
- $this->variant = "disabled";
1328
- break;
1329
- case true:
1330
- default:
1331
- $this->variant = "text";
1332
- break;
1333
- }
1334
- }
1335
-
1336
-
1337
- $data = "<div style=\"width: ".$width."px\">";
1338
- if ($this->variant == "text") {
1339
- $data .= "<div align=\"center\"><form method=\"POST\" action=\"".
1340
- $this->checkoutForm_url . "\"" . ($this->googleAnalytics_id?
1341
- " onsubmit=\"setUrchinInputCode();\"":"") . ">";
1342
-
1343
- $request = $this->GetXML();
1344
- require_once('xml-processing/gc_xmlparser.php');
1345
- $xml_parser = new gc_xmlparser($request);
1346
- $root = $xml_parser->GetRoot();
1347
- $XMLdata = $xml_parser->GetData();
1348
- $this->xml2html($XMLdata[$root], '', $data);
1349
- $data .= "<input type=\"image\" name=\"Checkout\" alt=\"Checkout\" " .
1350
- "src=\"". $this->server_url."buttons/checkout.gif?merchant_id=".
1351
- $this->merchant_id."&w=".$width. "&h=".$height."&style=".
1352
- $style."&variant=".$this->variant."&loc=".$loc."\"
1353
- height=\"".$height."\" width=\"".$width. "\" />";
1354
-
1355
- if($this->googleAnalytics_id) {
1356
- $data .= "<input type=\"hidden\" name=\"analyticsdata\" value=\"\">";
1357
- }
1358
- $data .= "</form></div>";
1359
- if($this->googleAnalytics_id) {
1360
- $data .= "<!-- Start Google analytics -->
1361
- <script src=\"https://ssl.google-analytics.com/urchin.js\" type=\"".
1362
- "text/javascript\">
1363
- </script>
1364
- <script type=\"text/javascript\">
1365
- _uacct = \"" . $this->googleAnalytics_id . "\";
1366
- urchinTracker();
1367
- </script>
1368
- <script src=\"https://checkout.google.com/files/digital/urchin_po" .
1369
- "st.js\" type=\"text/javascript\"></script>
1370
- <!-- End Google analytics -->";
1371
- }
1372
- } else {
1373
- $data .= "<div align=\"center\"><img alt=\"Checkout\" src=\"" .
1374
- "". $this->server_url."buttons/checkout.gif?merchant_id=" .
1375
- "".$this->merchant_id."&w=".$width. "&h=".$height."&style=".$style.
1376
- "&variant=".$this->variant."&loc=".$loc."\" height=\"".$height."\"".
1377
- " width=\"".$width. "\" /></div>";
1378
- }
1379
- if($showtext){
1380
- $data .= "<div align=\"center\"><a href=\"javascript:void(window.ope" .
1381
- "n('http://checkout.google.com/seller/what_is_google_checkout.html'" .
1382
- ",'whatischeckout','scrollbars=0,resizable=1,directories=0,height=2" .
1383
- "50,width=400'));\" onmouseover=\"return window.status = 'What is G" .
1384
- "oogle Checkout?'\" onmouseout=\"return window.status = ''\"><font " .
1385
- "size=\"-2\">What is Google Checkout?</font></a></div>";
1386
- }
1387
- $data .= "</div>";
1388
-
1389
-
1390
- return $data;
1391
-
1392
- }
1393
-
1394
- /**
1395
- * @access private
1396
- */
1397
- function xml2html($data, $path = '', &$rta){
1398
- // global $multiple_tags,$ignore_tags;
1399
- // $arr = gc_get_arr_result($data);
1400
- foreach($data as $tag_name => $tag) {
1401
- if(isset($this->ignore_tags[$tag_name])){
1402
- continue;
1403
- }
1404
- if(is_array($tag)){
1405
- // echo print_r($tag, true) . $tag_name . "<- tag name\n";
1406
- if(!$this->is_associative_array($data)) {
1407
- $new_path = $path . '-' . ($tag_name +1);
1408
- } else {
1409
- if(isset($this->multiple_tags[$tag_name])
1410
- && $this->is_associative_array($tag)
1411
- && !$this->isChildOf($path, $this->multiple_tags[$tag_name])){
1412
- $tag_name .= '-1';
1413
- }
1414
- $new_path = $path . (empty($path)?'':'.') . $tag_name;
1415
- }
1416
- $this->xml2html($tag, $new_path, $rta);
1417
- }
1418
- else {
1419
- $new_path = $path;
1420
- if($tag_name != 'VALUE'){
1421
- $new_path = $path . "." . $tag_name;
1422
- }
1423
- $rta .= '<input type="hidden" name="' .
1424
- $new_path . '" value="' .$tag . '"/>'."\n";
1425
- }
1426
- }
1427
- }
1428
-
1429
- // Returns true if a given variable represents an associative array
1430
- /**
1431
- * @access private
1432
- */
1433
- function is_associative_array($var) {
1434
- return is_array($var) && !is_numeric(implode('', array_keys($var)));
1435
- }
1436
-
1437
- /**
1438
- * @access private
1439
- */
1440
- function isChildOf($path='', $parents=array()){
1441
- $intersect =array_intersect(explode('.',$path), $parents);
1442
- return !empty($intersect);
1443
- }
1444
-
1445
- /**
1446
- * Get the Google Checkout acceptance logos html
1447
- *
1448
- * {@link http://checkout.google.com/seller/acceptance_logos.html}
1449
- *
1450
- * @param integer $type the acceptance logo type, valid values: 1, 2, 3
1451
- *
1452
- * @return string the logo's html
1453
- */
1454
- function CheckoutAcceptanceLogo($type=1) {
1455
- switch ($type) {
1456
- case 2:
1457
- return '<link rel="stylesheet" href="https://checkout.google.com/' .
1458
- 'seller/accept/s.css" type="text/css" media="screen" /><scrip' .
1459
- 't type="text/javascript" src="https://checkout.google.com/se' .
1460
- 'ller/accept/j.js"></script><script type="text/javascript">sh' .
1461
- 'owMark(1);</script><noscript><img src="https://checkout.goog' .
1462
- 'le.com/seller/accept/images/st.gif" width="92" height="88" a' .
1463
- 'lt="Google Checkout Acceptance Mark" /></noscript>';
1464
- break;
1465
- case 3:
1466
- return '<link rel="stylesheet" href="https://checkout.google.com/' .
1467
- 'seller/accept/s.css" type="text/css" media="screen" /><scrip' .
1468
- 't type="text/javascript" src="https://checkout.google.com/se' .
1469
- 'ller/accept/j.js"></script><script type="text/javascript">sh' .
1470
- 'owMark(2);</script><noscript><img src="https://checkout.goog' .
1471
- 'le.com/seller/accept/images/ht.gif" width="182" height="44" ' .
1472
- 'alt="Google Checkout Acceptance Mark" /></noscript>';
1473
- break;
1474
- case 1:
1475
- default:
1476
- return '<link rel="stylesheet" href="https://checkout.google.com/' .
1477
- 'seller/accept/s.css" type="text/css" media="screen" /><scrip' .
1478
- 't type="text/javascript" src="https://checkout.google.com/se' .
1479
- 'ller/accept/j.js"></script><script type="text/javascript">sh' .
1480
- 'owMark(3);</script><noscript><img src="https://checkout.goog' .
1481
- 'le.com/seller/accept/images/sc.gif" width="72" height="73" a' .
1482
- 'lt="Google Checkout Acceptance Mark" /></noscript>';
1483
- break;
1484
- }
1485
- }
1486
-
1487
- /**
1488
- * Calculates the cart's hmac-sha1 signature, this allows google to verify
1489
- * that the cart hasn't been tampered by a third-party.
1490
- *
1491
- * {@link http://code.google.com/apis/checkout/developer/index.html#create_signature}
1492
- *
1493
- * @param string $data the cart's xml
1494
- * @return string the cart's signature (in binary format)
1495
- */
1496
- function CalcHmacSha1($data) {
1497
- $key = $this->merchant_key;
1498
- $blocksize = 64;
1499
- $hashfunc = 'sha1';
1500
- if (strlen($key) > $blocksize) {
1501
- $key = pack('H*', $hashfunc($key));
1502
- }
1503
- $key = str_pad($key, $blocksize, chr(0x00));
1504
- $ipad = str_repeat(chr(0x36), $blocksize);
1505
- $opad = str_repeat(chr(0x5c), $blocksize);
1506
- $hmac = pack(
1507
- 'H*', $hashfunc(
1508
- ($key^$opad).pack(
1509
- 'H*', $hashfunc(
1510
- ($key^$ipad).$data
1511
- )
1512
- )
1513
- )
1514
- );
1515
- return $hmac;
1516
- }
1517
-
1518
- //Method used internally to set true/false cart variables
1519
- /**
1520
- * @access private
1521
- */
1522
- function _GetBooleanValue($value, $default) {
1523
- switch(strtolower($value)){
1524
- case "true":
1525
- return "true";
1526
- break;
1527
- case "false":
1528
- return"false";
1529
- break;
1530
- default:
1531
- return $default;
1532
- break;
1533
- }
1534
- }
1535
- //Method used internally to set true/false cart variables
1536
- // Deprecated, must NOT use eval, bug-prune function
1537
- /**
1538
- * @access private
1539
- */
1540
- function _SetBooleanValue($string, $value, $default) {
1541
- $value = strtolower($value);
1542
- if($value == "true" || $value == "false")
1543
- eval('$this->'.$string.'="'.$value.'";');
1544
- else
1545
- eval('$this->'.$string.'="'.$default.'";');
1546
- }
1547
- }
1548
-
1549
- /**
1550
- * @abstract
1551
- * Abstract class that represents the merchant-private-data.
1552
- *
1553
- * See {@link MerchantPrivateData} and {@link MerchantPrivateItemData}
1554
- *
1555
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_merchant-private-data <merchant-private-data>}
1556
- */
1557
- class MerchantPrivate {
1558
- var $data;
1559
- var $type = "Abstract";
1560
- function MerchantPrivate() {
1561
- }
1562
-
1563
- function AddMerchantPrivateToXML(&$xml_data) {
1564
- if(is_array($this->data)) {
1565
- $xml_data->Push($this->type);
1566
- $this->_recursiveAdd($xml_data, $this->data);
1567
- $xml_data->Pop($this->type);
1568
- }
1569
- else {
1570
- $xml_data->Element($this->type, (string)$this->data);
1571
- }
1572
- }
1573
-
1574
- /**
1575
- * @access private
1576
- */
1577
- function _recursiveAdd(&$xml_data, $data){
1578
- foreach($data as $name => $value) {
1579
- if(is_array($value)) {
1580
- $xml_data->Push($name);
1581
- $this->_recursiveAdd($xml_data, $name);
1582
- $xml_data->Pop($name);
1583
- }
1584
- else {
1585
- $xml_data->Element($name, (string)$value);
1586
- }
1587
- }
1588
- }
1589
- }
1590
-
1591
- /**
1592
- * Class that represents the merchant-private-data.
1593
- *
1594
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_merchant-private-data <merchant-private-data>}
1595
- */
1596
- class MerchantPrivateData extends MerchantPrivate {
1597
- /**
1598
- * @param mixed $data a string with the data that will go in the
1599
- * merchant-private-data tag or an array that will
1600
- * be mapped to xml, formatted like (e.g.):
1601
- * array('my-order-id' => 34234,
1602
- * 'stuff' => array('registered' => 'yes',
1603
- * 'category' => 'hip stuff'))
1604
- * this will map to:
1605
- * <my-order-id>
1606
- * <stuff>
1607
- * <registered>yes</registered>
1608
- * <category>hip stuff</category>
1609
- * </stuff>
1610
- * </my-order-id>
1611
- */
1612
- function MerchantPrivateData($data = array()) {
1613
- $this->data = $data;
1614
- $this->type = 'merchant-private-data';
1615
- }
1616
- }
1617
-
1618
- /**
1619
- * Class that represents a merchant-private-item-data.
1620
- *
1621
- * GC tag: {@link http://code.google.com/apis/checkout/developer/index.html#tag_merchant-private-item-data <merchant-private-data>}
1622
- */
1623
- class MerchantPrivateItemData extends MerchantPrivate {
1624
- /**
1625
- * @param mixed $data a string with the data that will go in the
1626
- * merchant-private-item-data tag or an array that will
1627
- * be mapped to xml, formatted like:
1628
- * array('my-item-id' => 34234,
1629
- * 'stuff' => array('label' => 'cool',
1630
- * 'category' => 'hip stuff'))
1631
- * this will map to:
1632
- * <my-item-id>
1633
- * <stuff>
1634
- * <label>cool</label>
1635
- * <category>hip stuff</category>
1636
- * </stuff>
1637
- * </my-item-id>
1638
- */
1639
- function MerchantPrivateItemData($data = array()) {
1640
- $this->data = $data;
1641
- $this->type = 'merchant-private-item-data';
1642
- }
1643
- }
1644
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-merchants/library/googleshipping.php CHANGED
@@ -107,7 +107,6 @@
107
  var $type = "carrier-calculated-shipping";
108
 
109
  var $CarrierCalculatedShippingOptions = array();
110
- // var $ShippingPackages = array();
111
  var $ShippingPackage;
112
 
113
  /**
@@ -129,7 +128,6 @@
129
  * @param GoogleShippingPackage $package
130
  */
131
  function addShippingPackage($package){
132
- // $this->ShippingPackages[] = $package;
133
  $this->ShippingPackage = $package;
134
  }
135
  }
@@ -146,8 +144,6 @@
146
  var $carrier_pickup;
147
  var $additional_fixed_charge;
148
  var $additional_variable_charge_percent;
149
- // var $shipping_restrictions;
150
- // var $address_filters;
151
 
152
  /**
153
  * @param double $price the default shipping cost to be used if Google is
@@ -189,14 +185,6 @@
189
  $this->additional_variable_charge_percent = (double)$additional_variable_charge_percent;
190
  }
191
  }
192
-
193
- // function AddShippingRestrictions($restrictions) {
194
- // $this->shipping_restrictions = $restrictions;
195
- // }
196
- //
197
- // function AddAddressFilters($filters) {
198
- // $this->address_filters = $filters;
199
- // }
200
  }
201
 
202
  /**
107
  var $type = "carrier-calculated-shipping";
108
 
109
  var $CarrierCalculatedShippingOptions = array();
 
110
  var $ShippingPackage;
111
 
112
  /**
128
  * @param GoogleShippingPackage $package
129
  */
130
  function addShippingPackage($package){
 
131
  $this->ShippingPackage = $package;
132
  }
133
  }
144
  var $carrier_pickup;
145
  var $additional_fixed_charge;
146
  var $additional_variable_charge_percent;
 
 
147
 
148
  /**
149
  * @param double $price the default shipping cost to be used if Google is
185
  $this->additional_variable_charge_percent = (double)$additional_variable_charge_percent;
186
  }
187
  }
 
 
 
 
 
 
 
 
188
  }
189
 
190
  /**
wpsc-merchants/paypal-express.merchant.php CHANGED
@@ -301,7 +301,6 @@ function form_paypal_express() {
301
  $paypal_currency_list = $wpsc_gateways['wpsc_merchant_paypal_express']['supported_currencies']['currency_list'];
302
 
303
  $currency_list = $wpdb->get_results("SELECT DISTINCT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `code` IN ('".implode("','",$paypal_currency_list)."')", ARRAY_A);
304
- // exit("SELECT DISTINCT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `code` IN ('".implode("','",$paypal_currency_list)."')".'<pre>'.print_r($wpsc_gateways,1).'</pre>');
305
  foreach($currency_list as $currency_item) {
306
  $selected_currency = '';
307
  if($current_currency == $currency_item['code']) {
@@ -466,7 +465,6 @@ function paypal_processingfunctions(){
466
  $_SESSION['reshash']=$resArray;
467
  if($ack!="SUCCESS"){
468
  $location = get_option('transact_url')."&act=error";
469
- // header("Location: $location");
470
  }else{
471
  $transaction_id = $wpdb->escape($resArray['TRANSACTIONID']);
472
  switch($resArray['PAYMENTSTATUS']) {
@@ -485,7 +483,6 @@ function paypal_processingfunctions(){
485
 
486
  $_SESSION['paypalExpressMessage'] = null;
487
  wp_redirect($location);
488
- // header("Location: $location");
489
  exit();
490
  }
491
 
301
  $paypal_currency_list = $wpsc_gateways['wpsc_merchant_paypal_express']['supported_currencies']['currency_list'];
302
 
303
  $currency_list = $wpdb->get_results("SELECT DISTINCT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `code` IN ('".implode("','",$paypal_currency_list)."')", ARRAY_A);
 
304
  foreach($currency_list as $currency_item) {
305
  $selected_currency = '';
306
  if($current_currency == $currency_item['code']) {
465
  $_SESSION['reshash']=$resArray;
466
  if($ack!="SUCCESS"){
467
  $location = get_option('transact_url')."&act=error";
 
468
  }else{
469
  $transaction_id = $wpdb->escape($resArray['TRANSACTIONID']);
470
  switch($resArray['PAYMENTSTATUS']) {
483
 
484
  $_SESSION['paypalExpressMessage'] = null;
485
  wp_redirect($location);
 
486
  exit();
487
  }
488
 
wpsc-merchants/paypal-pro.merchant.php CHANGED
@@ -58,10 +58,7 @@ class wpsc_merchant_paypal_pro extends wpsc_merchant {
58
  $data['RETURNFMFDETAILS'] = "1"; // optional - return fraud management filter data
59
 
60
  // Basic Cart Data
61
- //$data['TRANSACTIONID'] = $this->cart_data['session_id'];
62
- //$data['CURRENCYCODE'] = $this->cart_data['store_currency'];
63
  $data['INVNUM'] = $this->cart_data['session_id'];
64
- //$data['CUSTOM'] = $this->cart_data['session_id'];
65
  $data['NOTIFYURL'] = add_query_arg( 'gateway', 'wpsc_merchant_paypal_pro', $this->cart_data['notification_url'] );
66
  $data['IPADDRESS'] = $_SERVER["REMOTE_ADDR"];
67
 
@@ -69,7 +66,6 @@ class wpsc_merchant_paypal_pro extends wpsc_merchant {
69
  $data['FIRSTNAME'] = $this->cart_data['billing_address']['first_name'];
70
  $data['LASTNAME'] = $this->cart_data['billing_address']['last_name'];
71
  $data['EMAIL'] = $this->cart_data['email_address'];
72
- // $data['PHONENUM'] = $this->cart_data['billing_address'];
73
  $data['STREET'] = $this->cart_data['billing_address']['address'];
74
  $data['CITY'] = $this->cart_data['billing_address']['city'];
75
  $data['STATE'] = $this->cart_data['billing_address']['state'];
@@ -96,12 +92,10 @@ class wpsc_merchant_paypal_pro extends wpsc_merchant {
96
  $data['CVV2'] = $_POST['card_code'];
97
 
98
  // Ordered Items
99
- //$discount = $wpsc_cart->coupons_amount;
100
 
101
  // Cart Item Data
102
  $i = $item_total = $tax_total = 0;
103
 
104
- // $shipping_total = $this->cart_data['shipping_price'];
105
  $shipping_total = $this->cart_data['base_shipping'];
106
 
107
  foreach ( $this->cart_items as $cart_row ) {
@@ -111,10 +105,6 @@ class wpsc_merchant_paypal_pro extends wpsc_merchant {
111
  $cart_items['L_QTY' . $i] = $cart_row['quantity'];
112
  $cart_items['L_TAXAMT' . $i] = $this->format_price( 0 );
113
 
114
- //"item_number_$i" => $cart_row['product_id'],
115
- //"shipping_$i" => $this->format_price($cart_row['shipping']), // additional shipping for the the (first item / total of the items)
116
- //"shipping2_$i" => $this->format_price($cart_row['shipping']), // additional shipping beyond the first item
117
-
118
  $item_total += $this->format_price( $cart_row['price'] * $cart_row['quantity'] );
119
  $tax_total += $this->format_price( $cart_row['tax'] );
120
  ++$i;
@@ -128,8 +118,6 @@ class wpsc_merchant_paypal_pro extends wpsc_merchant {
128
 
129
  $data['AMT'] = number_format( $item_total + $tax_total + $shipping_total, 2 );
130
 
131
- // exit("<pre>".print_r($data, true)."</pre><br /><br /><pre>".print_r($this->cart_data, true)."</pre>");
132
-
133
  $this->collected_gateway_data = $data;
134
  }
135
 
@@ -150,8 +138,6 @@ class wpsc_merchant_paypal_pro extends wpsc_merchant {
150
  );
151
  $response = wp_remote_post( $paypal_url, $options );
152
 
153
- //exit( '<pre>' . print_r( $options, true ) . '</pre><pre>' . print_r( $response, true ) . '</pre>' );
154
-
155
  // parse the response body
156
 
157
  $error_data = array( );
@@ -187,13 +173,10 @@ class wpsc_merchant_paypal_pro extends wpsc_merchant {
187
  }
188
  }
189
 
190
- //exit("<pre>".print_r($parsed_response,true)."</pre>");
191
-
192
  switch ( $parsed_response['ACK'] ) {
193
  case 'Success':
194
  case 'SuccessWithWarning':
195
  $this->set_transaction_details( $parsed_response['TRANSACTIONID'], 3 );
196
- //transaction_results($this->cart_data['session_id'], false);
197
  $this->go_to_transaction_results( $this->cart_data['session_id'] );
198
  break;
199
 
@@ -289,7 +272,6 @@ class wpsc_merchant_paypal_pro extends wpsc_merchant {
289
  " . print_r( $this->cart_items, true ) . "
290
  {$altered_count}
291
  ";
292
- //mail('thomas.howard@gmail.com', "IPN Debugging", $message);
293
  }
294
 
295
  function format_price( $price ) {
@@ -316,7 +298,6 @@ class wpsc_merchant_paypal_pro extends wpsc_merchant {
316
  }
317
 
318
  function submit_paypal_pro() {
319
- //exit('<pre>'.print_r($_POST, true).'</pre>');
320
  if ( isset( $_POST['PayPalPro']['username'] ) )
321
  update_option( 'paypal_pro_username', $_POST['PayPalPro']['username'] );
322
 
58
  $data['RETURNFMFDETAILS'] = "1"; // optional - return fraud management filter data
59
 
60
  // Basic Cart Data
 
 
61
  $data['INVNUM'] = $this->cart_data['session_id'];
 
62
  $data['NOTIFYURL'] = add_query_arg( 'gateway', 'wpsc_merchant_paypal_pro', $this->cart_data['notification_url'] );
63
  $data['IPADDRESS'] = $_SERVER["REMOTE_ADDR"];
64
 
66
  $data['FIRSTNAME'] = $this->cart_data['billing_address']['first_name'];
67
  $data['LASTNAME'] = $this->cart_data['billing_address']['last_name'];
68
  $data['EMAIL'] = $this->cart_data['email_address'];
 
69
  $data['STREET'] = $this->cart_data['billing_address']['address'];
70
  $data['CITY'] = $this->cart_data['billing_address']['city'];
71
  $data['STATE'] = $this->cart_data['billing_address']['state'];
92
  $data['CVV2'] = $_POST['card_code'];
93
 
94
  // Ordered Items
 
95
 
96
  // Cart Item Data
97
  $i = $item_total = $tax_total = 0;
98
 
 
99
  $shipping_total = $this->cart_data['base_shipping'];
100
 
101
  foreach ( $this->cart_items as $cart_row ) {
105
  $cart_items['L_QTY' . $i] = $cart_row['quantity'];
106
  $cart_items['L_TAXAMT' . $i] = $this->format_price( 0 );
107
 
 
 
 
 
108
  $item_total += $this->format_price( $cart_row['price'] * $cart_row['quantity'] );
109
  $tax_total += $this->format_price( $cart_row['tax'] );
110
  ++$i;
118
 
119
  $data['AMT'] = number_format( $item_total + $tax_total + $shipping_total, 2 );
120
 
 
 
121
  $this->collected_gateway_data = $data;
122
  }
123
 
138
  );
139
  $response = wp_remote_post( $paypal_url, $options );
140
 
 
 
141
  // parse the response body
142
 
143
  $error_data = array( );
173
  }
174
  }
175
 
 
 
176
  switch ( $parsed_response['ACK'] ) {
177
  case 'Success':
178
  case 'SuccessWithWarning':
179
  $this->set_transaction_details( $parsed_response['TRANSACTIONID'], 3 );
 
180
  $this->go_to_transaction_results( $this->cart_data['session_id'] );
181
  break;
182
 
272
  " . print_r( $this->cart_items, true ) . "
273
  {$altered_count}
274
  ";
 
275
  }
276
 
277
  function format_price( $price ) {
298
  }
299
 
300
  function submit_paypal_pro() {
 
301
  if ( isset( $_POST['PayPalPro']['username'] ) )
302
  update_option( 'paypal_pro_username', $_POST['PayPalPro']['username'] );
303
 
wpsc-merchants/paypal-standard.merchant.php CHANGED
@@ -107,8 +107,6 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
107
 
108
  // Order settings to be sent to paypal
109
  $paypal_vars += array(
110
- //'tax' => '',
111
- //'custom' => '',
112
  'invoice' => $this->cart_data['session_id']
113
  );
114
 
@@ -258,7 +256,6 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
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>";
262
  echo "<pre>".print_r($this->collected_gateway_data,true)."</pre>";
263
  exit();
264
  }
@@ -368,9 +365,6 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
368
  $price = number_format(sprintf("%01.2f",$price),$decimal_places,'.','');
369
  return $price;
370
  }
371
-
372
-
373
-
374
  }
375
 
376
 
@@ -536,7 +530,6 @@ function form_paypal_multiple() {
536
  $current_currency = $store_currency_data['code'];
537
  }
538
 
539
- // exit($current_currency.'<br />'.$store_currency_data['code']);
540
  if($current_currency != $store_currency_data['code']) {
541
  $output .= "
542
  <tr>
107
 
108
  // Order settings to be sent to paypal
109
  $paypal_vars += array(
 
 
110
  'invoice' => $this->cart_data['session_id']
111
  );
112
 
256
 
257
  if(defined('WPSC_ADD_DEBUG_PAGE') and (WPSC_ADD_DEBUG_PAGE == true) ) {
258
  echo "<a href='".get_option('paypal_multiple_url')."?".$gateway_values."'>Test the URL here</a>";
 
259
  echo "<pre>".print_r($this->collected_gateway_data,true)."</pre>";
260
  exit();
261
  }
365
  $price = number_format(sprintf("%01.2f",$price),$decimal_places,'.','');
366
  return $price;
367
  }
 
 
 
368
  }
369
 
370
 
530
  $current_currency = $store_currency_data['code'];
531
  }
532
 
 
533
  if($current_currency != $store_currency_data['code']) {
534
  $output .= "
535
  <tr>
wpsc-merchants/paypal_certified.php DELETED
@@ -1,1147 +0,0 @@
1
- <?php
2
-
3
- $nzshpcrt_gateways[$num]['name'] = 'PayPal Express Checkout';
4
- $nzshpcrt_gateways[$num]['internalname'] = 'paypal_certified';
5
- $nzshpcrt_gateways[$num]['function'] = 'gateway_paypal_certified';
6
- $nzshpcrt_gateways[$num]['form'] = "form_paypal_certified";
7
- $nzshpcrt_gateways[$num]['submit_function'] = "submit_paypal_certified";
8
- $nzshpcrt_gateways[$num]['payment_type'] = "paypal";
9
- $nzshpcrt_gateways[$num]['display_name'] = "PayPal Express";
10
-
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', 'MYR');
12
- $nzshpcrt_gateways[$num]['supported_currencies']['option_name'] = 'paypal_curcode';
13
-
14
-
15
- function gateway_paypal_certified($separator, $sessionid)
16
- {
17
- $_SESSION['paypalExpressMessage']= ' <h4>Transaction Canceled</h4>';
18
- // ==================================
19
- // PayPal Express Checkout Module
20
- // ==================================
21
-
22
- //'------------------------------------
23
- //' The paymentAmount is the total value of
24
- //' the shopping cart, that was set
25
- //' earlier in a session variable
26
- //' by the shopping cart page
27
- //'------------------------------------
28
- //exit('<pre>'.print_r($_SESSION, true).'</pre>');
29
- $paymentAmount = wpsc_cart_total(false);
30
- $_SESSION['paypalAmount'] = $paymentAmount;
31
- $_SESSION['paypalexpresssessionid'] = $sessionid;
32
- paypal_certified_currencyconverter();
33
- //exit($_SESSION['paypalAmount']);
34
- //'------------------------------------
35
- //' The currencyCodeType and paymentType
36
- //' are set to the selections made on the Integration Assistant
37
- //'------------------------------------
38
- $currencyCodeType = get_option('paypal_curcode');
39
- $paymentType = "Sale";
40
-
41
- //'------------------------------------
42
- //' The returnURL is the location where buyers return to when a
43
- //' payment has been succesfully authorized.
44
- //'
45
- //' This is set to the value entered on the Integration Assistant
46
- //'------------------------------------
47
- //exit(get_option('transact_url'));
48
- $transact_url = get_option('transact_url');
49
- $returnURL = $transact_url.$separator."sessionid=".$sessionid."&gateway=paypal";
50
-
51
- //'------------------------------------
52
- //' The cancelURL is the location buyers are sent to when they hit the
53
- //' cancel button during authorization of payment during the PayPal flow
54
- //'
55
- //' This is set to the value entered on the Integration Assistant
56
- //'------------------------------------
57
- $cancelURL = $transact_url;
58
- //'------------------------------------
59
- //' Calls the SetExpressCheckout API call
60
- //'
61
- //' The CallShortcutExpressCheckout function is defined in the file PayPalFunctions.php,
62
- //' it is included at the top of this file.
63
- //'-------------------------------------------------
64
- $resArray = CallShortcutExpressCheckout ($_SESSION['paypalAmount'], $currencyCodeType, $paymentType, $returnURL, $cancelURL);
65
- //exit("<pre>".print_r($resArray,true)."</pre>");
66
- $ack = strtoupper($resArray["ACK"]);
67
- if($ack=="SUCCESS") {
68
- RedirectToPayPal ( $resArray["TOKEN"] );
69
- } else {
70
- //Display a user friendly Error on the page using any of the following error information returned by PayPal
71
- $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
72
- $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
73
- $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
74
- $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
75
-
76
- echo "SetExpressCheckout API call failed. ";
77
- echo "Detailed Error Message: " . $ErrorLongMsg;
78
- echo "Short Error Message: " . $ErrorShortMsg;
79
- echo "Error Code: " . $ErrorCode;
80
- echo "Error Severity Code: " . $ErrorSeverityCode;
81
- }
82
-
83
-
84
- // header("Location: ".get_option('paypal_multiple_url')."?".$output);
85
- exit();
86
- }
87
- function paypal_certified_currencyconverter(){
88
- global $wpdb;
89
- $currency_code = $wpdb->get_results("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A);
90
- $local_currency_code = $currency_code[0]['code'];
91
- $paypal_currency_code = get_option('paypal_curcode');
92
- if($paypal_currency_code == '') {
93
- $paypal_currency_code = 'US';
94
- }
95
- //exit(get_option('currency_type'). " ".$paypal_currency_code);
96
-
97
- // 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.
98
- $curr=new CURRENCYCONVERTER();
99
- if($paypal_currency_code != $local_currency_code) {
100
- $paypal_currency_productprice = $curr->convert($_SESSION['paypalAmount'],$paypal_currency_code,$local_currency_code);
101
- $paypal_currency_shipping = $curr->convert($local_currency_shipping,$paypal_currency_code,$local_currency_code);
102
- //exit($paypal_currency_productprice . " " . $paypal_currency_shipping.' '.$local_currency_productprice . " " . $local_currency_code);
103
- $base_shipping = $curr->convert($purchase_log['base_shipping'],$paypal_currency_code, $local_currency_code);
104
- } else {
105
- $paypal_currency_productprice = $_SESSION['paypalAmount'];
106
- $paypal_currency_shipping = $local_currency_shipping;
107
- $base_shipping = $purchase_log['base_shipping'];
108
- }
109
- switch($paypal_currency_code) {
110
- case "JPY":
111
- $decimal_places = 0;
112
- break;
113
-
114
- case "HUF":
115
- $decimal_places = 0;
116
-
117
- default:
118
- $decimal_places = 2;
119
- break;
120
- }
121
- //echo "$paypal_currency_code|$local_currency_code";
122
- $_SESSION['paypalAmount'] = number_format(sprintf("%01.2f", $paypal_currency_productprice),$decimal_places,'.','');
123
-
124
-
125
- }
126
- function processingfunctions()
127
- {
128
- global $wpdb, $wpsc_cart;
129
-
130
- $sessionid = '';
131
- if (isset($_SESSION['paypalexpresssessionid'])) {
132
- $sessionid = $_SESSION['paypalexpresssessionid'];
133
- }
134
-
135
- if(isset($_REQUEST['act']) && ($_REQUEST['act']=='error')){
136
- session_start();
137
- $resArray=$_SESSION['reshash'];
138
- $_SESSION['paypalExpressMessage']= '
139
- <center>
140
-
141
- <table width="700" align="left">
142
- <tr>
143
- <td colspan="2" class="header">The PayPal API has returned an error!</td>
144
- </tr>
145
- ';
146
- //it will print if any URL errors
147
- if(isset($_SESSION['curl_error_no'])) {
148
- $errorCode= $_SESSION['curl_error_no'] ;
149
- $errorMessage=$_SESSION['curl_error_msg'] ;
150
- $response = $_SESSION['response'];
151
- session_unset();
152
-
153
- $_SESSION['paypalExpressMessage'].='
154
- <tr>
155
- <td>response:</td>
156
- <td><?php echo $response; ?></td>
157
- </tr>
158
-
159
- <tr>
160
- <td>Error Number:</td>
161
- <td><?= $errorCode ?></td>
162
- </tr>
163
- <tr>
164
- <td>Error Message:</td>
165
- <td><?= $errorMessage ?></td>
166
- </tr>
167
-
168
- </center>
169
- </table>';
170
- } else {
171
-
172
- /* If there is no URL Errors, Construct the HTML page with
173
- Response Error parameters.
174
- */
175
- $_SESSION['paypalExpressMessage'] .="
176
-
177
- <td>Ack:</td>
178
- <td>".$resArray['ACK']."</td>
179
- </tr>
180
- <tr>
181
- <td>Correlation ID:</td>
182
- <td>".$resArray['CORRELATIONID']."</td>
183
- </tr>
184
- <tr>
185
- <td>Version:</td>
186
- <td>".$resArray['VERSION']."</td>
187
- </tr>";
188
-
189
- $count=0;
190
- while (isset($resArray["L_SHORTMESSAGE".$count])) {
191
- $errorCode = $resArray["L_ERRORCODE".$count];
192
- $shortMessage = $resArray["L_SHORTMESSAGE".$count];
193
- $longMessage = $resArray["L_LONGMESSAGE".$count];
194
- $count=$count+1;
195
- $_SESSION['paypalExpressMessage'] .="
196
- <tr>
197
- <td>Error Number:</td>
198
- <td> $errorCode </td>
199
- </tr>
200
- <tr>
201
- <td>Short Message:</td>
202
- <td> $shortMessage </td>
203
- </tr>
204
- <tr>
205
- <td>Long Message:</td>
206
- <td> $longMessage </td>
207
- </tr>";
208
-
209
- }//end while
210
- }// end else
211
- $_SESSION['paypalExpressMessage'] .="
212
- </center>
213
- </table>";
214
-
215
- }else if(isset($_REQUEST['act']) && ($_REQUEST['act']=='do')){
216
- session_start();
217
-
218
- /* Gather the information to make the final call to
219
- finalize the PayPal payment. The variable nvpstr
220
- holds the name value pairs
221
- */
222
- //exit(wpsc_cart_total(false));
223
- $token =urlencode($_REQUEST['token']);
224
- $paymentAmount =urlencode ($_SESSION['paypalAmount']);
225
- $paymentType = urlencode($_SESSION['paymentType']);
226
- $currCodeType = urlencode(get_option('paypal_curcode'));
227
- $payerID = urlencode($_REQUEST['PayerID']);
228
- $serverName = urlencode($_SERVER['SERVER_NAME']);
229
- $BN='Instinct_e-commerce_wp-shopping-cart_NZ';
230
-
231
- $nvpstr='&TOKEN='.$token.'&PAYERID='.$payerID.'&PAYMENTACTION=Sale&AMT='.$paymentAmount.'&CURRENCYCODE='.$currCodeType.'&IPADDRESS='.$serverName."&BUTTONSOURCE=".$BN ;
232
- // exit($nvpstr);
233
- /* Make the call to PayPal to finalize payment
234
- If an error occured, show the resulting errors
235
- */
236
- $resArray=hash_call("DoExpressCheckoutPayment",$nvpstr);
237
-
238
- /* Display the API response back to the browser.
239
- If the response from PayPal was a success, display the response parameters'
240
- If the response was an error, display the errors received using APIError.php.
241
- */
242
- $ack = strtoupper($resArray["ACK"]);
243
-
244
- //echo('<pre>'.print_r($resArray, true).'</re>');
245
- if($ack!="SUCCESS"){
246
- $_SESSION['reshash']=$resArray;
247
- $location = get_option('transact_url')."&act=error";
248
- // header("Location: $location");
249
- }else{
250
- $transaction_id = $wpdb->escape($resArray['TRANSACTIONID']);
251
- switch($resArray['PAYMENTSTATUS']) {
252
- case 'Processed': // I think this is mostly equivalent to Completed
253
- case 'Completed':
254
- $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `processed` = '2' WHERE `sessionid` = ".$sessionid." LIMIT 1");
255
- transaction_results($sessionid, false, $transaction_id);
256
- break;
257
-
258
- case 'Pending': // need to wait for "Completed" before processing
259
- $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `transactid` = '".$transaction_id."', `date` = '".time()."' WHERE `sessionid` = ".$sessionid." LIMIT 1");
260
- break;
261
- }
262
- $location = add_query_arg('sessionid', $sessionid, get_option('transact_url'));
263
- //echo $location;
264
- $_SESSION['paypalExpressMessage'] = null;
265
- header("Location: $location");
266
- exit();
267
- }
268
- //exit('<pre>'.print_r($resArray, true).'</pre>');
269
- // $_SESSION['paypalExpressMessage'] ="
270
- // <h4>Transaction Accepted Please Keep these References Handy.</h4>
271
- // <table class='' >
272
- //
273
- // <tr>
274
- // <td >
275
- // Transaction ID:</td>
276
- // <td>".$resArray['TRANSACTIONID']."</td>
277
- // </tr>
278
- // <tr>
279
- // <td >
280
- // Amount:</td>
281
- // <td>".$currCodeType." ".$resArray['AMT']."</td>
282
- // </tr>
283
- // </table>";
284
-
285
-
286
- //unset session shopping cart
287
- @$_SESSION['nzshpcrt_serialized_cart'] = '';
288
- $_SESSION['nzshpcrt_cart'] = '';
289
- $_SESSION['nzshpcrt_cart'] = Array();
290
- //exit('HERE');
291
- $wpsc_cart->empty_cart();
292
-
293
- } else if(isset($_REQUEST['paymentType']) || isset($_REQUEST['token'])){
294
- $token = $_REQUEST['token'];
295
- if(! isset($token)) {
296
- /*
297
- The servername and serverport tells PayPal where the buyer
298
- should be directed back to after authorizing payment.
299
- In this case, its the local webserver that is running this script
300
- Using the servername and serverport, the return URL is the first
301
- portion of the URL that buyers will return to after authorizing payment
302
- */
303
-
304
- $paymentAmount=$_SESSION['paypalAmount'];
305
- $currencyCodeType=get_option('paypal_curcode');
306
- $paymentType='Sale';
307
-
308
- /* The returnURL is the location where buyers return when a
309
- payment has been succesfully authorized.
310
- The cancelURL is the location buyers are sent to when they hit the
311
- cancel button during authorization of payment during the PayPal flow
312
- */
313
- if(get_option('permalink_structure') != '')
314
- {
315
- $separator ="?";
316
- }
317
- else
318
- {
319
- $separator ="&";
320
- }
321
- $returnURL =urlencode(get_option('transact_url').$separator.'currencyCodeType='.$currencyCodeType.'&paymentType='.$paymentType.'&paymentAmount='.$paymentAmount);
322
- $cancelURL =urlencode(get_option('transact_url').$separator.'paymentType=$paymentType' );
323
-
324
- /* Construct the parameter string that describes the PayPal payment
325
- the varialbes were set in the web form, and the resulting string
326
- is stored in $nvpstr
327
- */
328
-
329
- $nvpstr="&Amt=".$paymentAmount."&PAYMENTACTION=".$paymentType."&ReturnUrl=".$returnURL."&CANCELURL=".$cancelURL ."&CURRENCYCODE=".$currencyCodeType;
330
-
331
- /* Make the call to PayPal to set the Express Checkout token
332
- If the API call succeded, then redirect the buyer to PayPal
333
- to begin to authorize payment. If an error occured, show the
334
- resulting errors
335
- */
336
- $resArray=hash_call("SetExpressCheckout",$nvpstr);
337
- $_SESSION['reshash']=$resArray;
338
-
339
- $ack = strtoupper($resArray["ACK"]);
340
-
341
- if($ack=="SUCCESS"){
342
- // Redirect to paypal.com here
343
- $token = urldecode($resArray["TOKEN"]);
344
- $payPalURL = PAYPAL_URL.$token;
345
- header("Location: ".$payPalURL);
346
- } else {
347
- //Redirecting to APIError.php to display errors.
348
- $location = get_option('transact_url')."&act=error";
349
- header("Location: $location");
350
- }
351
- exit();
352
- } else {
353
- /* At this point, the buyer has completed in authorizing payment
354
- at PayPal. The script will now call PayPal with the details
355
- of the authorization, incuding any shipping information of the
356
- buyer. Remember, the authorization is not a completed transaction
357
- at this state - the buyer still needs an additional step to finalize
358
- the transaction
359
- */
360
-
361
- $token =urlencode( $_REQUEST['token']);
362
-
363
- /* Build a second API request to PayPal, using the token as the
364
- ID to get the details on the payment authorization
365
- */
366
- $nvpstr="&TOKEN=".$token;
367
-
368
- /* Make the API call and store the results in an array. If the
369
- call was a success, show the authorization details, and provide
370
- an action to complete the payment. If failed, show the error
371
- */
372
- $resArray=hash_call("GetExpressCheckoutDetails",$nvpstr);
373
- $_SESSION['reshash']=$resArray;
374
- $ack = strtoupper($resArray["ACK"]);
375
- if($ack=="SUCCESS"){
376
-
377
- /********************************************************
378
- GetExpressCheckoutDetails.php
379
-
380
- This functionality is called after the buyer returns from
381
- PayPal and has authorized the payment.
382
-
383
- Displays the payer details returned by the
384
- GetExpressCheckoutDetails response and calls
385
- DoExpressCheckoutPayment.php to complete the payment
386
- authorization.
387
-
388
- Called by ReviewOrder.php.
389
-
390
- Calls DoExpressCheckoutPayment.php and APIError.php.
391
-
392
- ********************************************************/
393
-
394
-
395
- session_start();
396
-
397
- /* Collect the necessary information to complete the
398
- authorization for the PayPal payment
399
- */
400
-
401
- $_SESSION['token']=$_REQUEST['token'];
402
- $_SESSION['payer_id'] = $_REQUEST['PayerID'];
403
-
404
- /*
405
- $_SESSION['paymentAmount']=$_REQUEST['paymentAmount'];
406
- $_SESSION['currCodeType']=$_REQUEST['currencyCodeType'];
407
- $_SESSION['paymentType']=$_REQUEST['paymentType'];
408
- */
409
-
410
- $resArray=$_SESSION['reshash'];
411
-
412
- if(get_option('permalink_structure') != '')
413
- {
414
- $separator ="?";
415
- }
416
- else
417
- {
418
- $separator ="&";
419
- }
420
-
421
- /* Display the API response back to the browser .
422
- If the response from PayPal was a success, display the response parameters
423
- */
424
- if(isset($_REQUEST['token']) && !isset($_REQUEST['PayerID'])){
425
- $_SESSION['paypalExpressMessage']= '<h4>TRANSACTION CANCELED</h4>';
426
- }else{
427
- $output ="
428
- <table width='400' class='paypal_express_form'>
429
- <tr>
430
- <td align='left' class='firstcol'><b>Order Total:</b></td>
431
- <td align='left'>".$wpsc_cart->process_as_currency($_SESSION['paypalAmount']) ."</td>
432
- </tr>
433
- <tr>
434
- <td align='left'><b>Shipping Address: </b></td>
435
- </tr>
436
- <tr>
437
- <td align='left' class='firstcol'>
438
- Street 1:</td>
439
- <td align='left'>".$resArray['SHIPTOSTREET']."</td>
440
-
441
- </tr>
442
- <tr>
443
- <td align='left' class='firstcol'>
444
- Street 2:</td>
445
- <td align='left'>".$resArray['SHIPTOSTREET2']."
446
- </td>
447
- </tr>
448
- <tr>
449
- <td align='left' class='firstcol'>
450
- City:</td>
451
-
452
- <td align='left'>".$resArray['SHIPTOCITY']."</td>
453
- </tr>
454
- <tr>
455
- <td align='left' class='firstcol'>
456
- State:</td>
457
- <td align='left'>".$resArray['SHIPTOSTATE']."</td>
458
- </tr>
459
- <tr>
460
- <td align='left' class='firstcol'>
461
- Postal code:</td>
462
-
463
- <td align='left'>".$resArray['SHIPTOZIP']."</td>
464
- </tr>
465
- <tr>
466
- <td align='left' class='firstcol'>
467
- Country:</td>
468
- <td align='left'>".$resArray['SHIPTOCOUNTRYNAME']."</td>
469
- </tr>
470
- <tr>
471
- <td>";
472
- // $purchase_log = $wpdb->get_row("SELECT `id`,`billing_region` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`= '".$wpdb->escape($_SESSION['paypalexpresssessionid']) ."' LIMIT 1", ARRAY_A) ;
473
- // $usersql = "SELECT `".WPSC_TABLE_SUBMITED_FORM_DATA."`.value, `".WPSC_TABLE_CHECKOUT_FORMS."`.`name`, `".WPSC_TABLE_CHECKOUT_FORMS."`.`unique_name` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN `".WPSC_TABLE_SUBMITED_FORM_DATA."` ON `".WPSC_TABLE_CHECKOUT_FORMS."`.id = `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`form_id` WHERE `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`log_id`=".$purchase_log['id']." ORDER BY `".WPSC_TABLE_CHECKOUT_FORMS."`.`order`";
474
- //
475
- // $userinfo = $wpdb->get_results($usersql, ARRAY_A);
476
- //
477
- //
478
- $output .= "<form action=".get_option('transact_url')." method='post'>\n";
479
- $output .= " <input type='hidden' name='totalAmount' value='".wpsc_cart_total(false)."' />\n";
480
- $output .= " <input type='hidden' name='shippingStreet' value='".$resArray['SHIPTOSTREET']."' />\n";
481
- $output .= " <input type='hidden' name='shippingStreet2' value='".$resArray['SHIPTOSTREET2']."' />\n";
482
- $output .= " <input type='hidden' name='shippingCity' value='".$resArray['SHIPTOCITY']."' />\n";
483
- $output .= " <input type='hidden' name='shippingState' value='".$resArray['SHIPTOSTATE']."' />\n";
484
- $output .= " <input type='hidden' name='postalCode' value='".$resArray['SHIPTOZIP']."' />\n";
485
- $output .= " <input type='hidden' name='country' value='".$resArray['SHIPTOCOUNTRYNAME']."' />\n";
486
- $output .= " <input type='hidden' name='token' value='".$_SESSION['token']."' />\n";
487
- $output .= " <input type='hidden' name='PayerID' value='".$_SESSION['payer_id']."' />\n";
488
- $output .= " <input type='hidden' name='act' value='do' />\n";
489
- $output .= " <p> <input name='usePayPal' type='submit' value='Make Payment' /></p>\n";
490
- $output .= "</form>";
491
-
492
- $output .= "<form action=".get_option('transact_url')." method='post'>\n";
493
- $output .= " <input type='hidden' name='totalAmount' value='".wpsc_cart_total(false)."' />\n";
494
-
495
- // foreach((array)$userinfo as $key => $value){
496
- // if(($value['unique_name']=='billingfirstname') && $value['value'] != ''){
497
- // $data['SHIPTONAME'] = $value['value'];
498
- // }
499
- // if(($value['unique_name']=='billinglastname') && $value['value'] != ''){
500
- // $data['SHIPTONAME'] .= " ".$value['value'];
501
- // }
502
- //
503
- // if(($value['unique_name']=='billingaddress') && $value['value'] != ''){
504
- // $data['SHIPTOSTREET'] = $value['value'];
505
- // }
506
- // if(($value['unique_name']=='billingcity') && $value['value'] != ''){
507
- // $data['SHIPTOCITY'] = $value['value'];
508
- // }
509
- // if(($value['unique_name']=='billingcountry') && $value['value'] != ''){
510
- // $data['SHIPTOCOUNTRYCODE'] = $value['value'];
511
- // $state = $wpdb->get_var("SELECT `code` FROM `".WPSC_TABLE_REGION_TAX."` WHERE `id` ='{$purchase_log['billing_region']}' LIMIT 1");
512
- // if($purchase_log['billing_region'] > 0) {
513
- // $data['SHIPTOSTATE'] = $state;
514
- // }
515
- // }
516
- // if(($value['unique_name']=='billingpostcode') && $value['value'] != ''){
517
- // $data['SHIPTOZIP'] = $value['value'];
518
- // }
519
- // }
520
- //
521
- // $output .= " <input type='text' name='shippingStreet' value='".$data['SHIPTOSTREET']."' />\n";
522
- // $output .= " <input type='text' name='shippingCity' value='".$data['SHIPTOCITY']."' />\n";
523
- // $output .= " <input type='text' name='shippingState' value='".$data['SHIPTOSTATE']."' />\n";
524
- // $output .= " <input type='text' name='postalCode' value='".$data['SHIPTOZIP']."' />\n";
525
- // $output .= " <input type='text' name='country' value='".$data['SHIPTOCOUNTRYCODE']."' />\n";
526
- // $output .= " <input type='text' name='token' value='".$_SESSION['token']."' />\n";
527
- // $output .= " <input type='text' name='PayerID' value='".$_SESSION['payer_id']."' />\n";
528
- // $output .= " <input type='hidden' name='act' value='do' />\n";
529
- // $output .= " <p> <label for='useOther'>Use Previous Shipping Information:</label> <input name='useOther' type='submit' value='Make Payment' /></p>\n";
530
- // $output .= "</form>";
531
- $output .=" </td>
532
- </tr>
533
- </table>
534
- </center>
535
- ";
536
- $_SESSION['paypalExpressMessage'] = $output;
537
- }
538
- }
539
- }
540
- }
541
-
542
-
543
- }
544
- function submit_paypal_certified()
545
- {
546
- if(isset($_POST['paypal_certified_apiuser']))
547
- {
548
- update_option('paypal_certified_apiuser', $_POST['paypal_certified_apiuser']);
549
- }
550
-
551
- if(isset($_POST['paypal_certified_apipass']))
552
- {
553
- update_option('paypal_certified_apipass', $_POST['paypal_certified_apipass']);
554
- }
555
-
556
- if(isset($_POST['paypal_curcode']))
557
- {
558
- update_option('paypal_curcode', $_POST['paypal_curcode']);
559
- }
560
-
561
- if(isset($_POST['paypal_certified_apisign']))
562
- {
563
- update_option('paypal_certified_apisign', $_POST['paypal_certified_apisign']);
564
- }
565
-
566
- if(isset($_POST['paypal_certified_server_type'])) {
567
-
568
- update_option('paypal_certified_server_type', $_POST['paypal_certified_server_type']);
569
- //exit(get_option('paypal_certified_server_type').'<pre>'.print_r($_POST, true).'</pre>');
570
- }
571
- if (!isset($_POST['paypal_form'])) $_POST['paypal_form'] = array();
572
- foreach((array)$_POST['paypal_form'] as $form => $value) {
573
- update_option(('paypal_form_'.$form), $value);
574
- }
575
- return true;
576
- }
577
-
578
- function form_paypal_certified()
579
- {
580
- global $wpdb, $wpsc_gateways;
581
- $select_currency[get_option('paypal_curcode')] = "selected='selected'";
582
- if (get_option('paypal_certified_server_type') == 'sandbox'){
583
- $serverType1="checked='checked'";
584
- } elseif(get_option('paypal_certified_server_type') == 'production') {
585
- $serverType2 ="checked='checked'";
586
- }
587
-
588
- if (!isset($serverType1)) $serverType1 = '';
589
- if (!isset($serverType2)) $serverType2 = '';
590
-
591
- $output = "
592
- <tr>
593
- <td>API Username
594
- </td>
595
- <td>
596
- <input type='text' size='40' value='".get_option('paypal_certified_apiuser')."' name='paypal_certified_apiuser' />
597
- </td>
598
- </tr>
599
- <tr>
600
- <td>API Password
601
- </td>
602
- <td>
603
- <input type='text' size='40' value='".get_option('paypal_certified_apipass')."' name='paypal_certified_apipass' />
604
- </td>
605
- </tr>
606
- <tr>
607
- <td>API Signature
608
- </td>
609
- <td>
610
- <input type='text' size='70' value='".get_option('paypal_certified_apisign')."' name='paypal_certified_apisign' />
611
- </td>
612
- </tr>
613
- <tr>
614
- <td>Server Type
615
- </td>
616
- <td>
617
- <input $serverType1 type='radio' name='paypal_certified_server_type' value='sandbox' /> Sandbox (For testing)
618
- <input $serverType2 type='radio' name='paypal_certified_server_type' value='production' /> Production
619
- </td>
620
- </tr>
621
- ";
622
-
623
- $store_currency_code = $wpdb->get_var("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id` IN ('".absint(get_option('currency_type'))."')");
624
- $current_currency = get_option('paypal_curcode');
625
- if($current_currency != $store_currency_code) {
626
- $output .= "
627
- <tr>
628
- <td colspan='2'><strong class='form_group'>".__('Currency Converter')."</td>
629
- </tr>
630
- <tr>
631
- <td colspan='2'>".__('If your website uses a currency not accepted by PayPal, select an accepted currency using the drop down menu bellow. Buyers on your site will still pay in your local currency however we will send the order through to PayPal using currency you choose below.')."</td>
632
- </tr>\n";
633
-
634
- $output .= " <tr>\n";
635
-
636
-
637
-
638
- $output .= " <td>Convert to </td>\n";
639
- $output .= " <td>\n";
640
- $output .= " <select name='paypal_curcode'>\n";
641
-
642
- if (!isset($wpsc_gateways['paypal_multiple']['supported_currencies']['currency_list'])) $wpsc_gateways['paypal_multiple']['supported_currencies']['currency_list'] = array();
643
- $paypal_currency_list = $wpsc_gateways['paypal_multiple']['supported_currencies']['currency_list'];
644
-
645
- $currency_list = $wpdb->get_results("SELECT DISTINCT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `code` IN ('".implode("','",$paypal_currency_list)."')", ARRAY_A);
646
- foreach($currency_list as $currency_item) {
647
- $selected_currency = '';
648
- if($current_currency == $currency_item['code']) {
649
- $selected_currency = "selected='selected'";
650
- }
651
- $output .= "<option ".$selected_currency." value='{$currency_item['code']}'>{$currency_item['currency']}</option>";
652
- }
653
- $output .= " </select> \n";
654
- $output .= " </td>\n";
655
- $output .= " </tr>\n";
656
- }
657
-
658
- $output .= "
659
- <tr class='update_gateway' >
660
- <td colspan='2'>
661
- <div class='submit'>
662
- <input type='submit' value='Update &raquo;' name='updateoption'/>
663
- </div>
664
- </td>
665
- </tr>
666
-
667
- <tr style='background: none;'>
668
- <td colspan='2'>
669
- <h4>Forms Sent to Gateway</h4>
670
- </td>
671
- </tr>
672
-
673
- <tr>
674
- <td>
675
- First Name Field
676
- </td>
677
- <td>
678
- <select name='paypal_form[first_name]'>
679
- ".nzshpcrt_form_field_list(get_option('paypal_form_first_name'))."
680
- </select>
681
- </td>
682
- </tr>
683
- <tr>
684
- <td>
685
- Last Name Field
686
- </td>
687
- <td>
688
- <select name='paypal_form[last_name]'>
689
- ".nzshpcrt_form_field_list(get_option('paypal_form_last_name'))."
690
- </select>
691
- </td>
692
- </tr>
693
- <tr>
694
- <td>
695
- Address Field
696
- </td>
697
- <td>
698
- <select name='paypal_form[address]'>
699
- ".nzshpcrt_form_field_list(get_option('paypal_form_address'))."
700
- </select>
701
- </td>
702
- </tr>
703
- <tr>
704
- <td>
705
- City Field
706
- </td>
707
- <td>
708
- <select name='paypal_form[city]'>
709
- ".nzshpcrt_form_field_list(get_option('paypal_form_city'))."
710
- </select>
711
- </td>
712
- </tr>
713
- <tr>
714
- <td>
715
- State Field
716
- </td>
717
- <td>
718
- <select name='paypal_form[state]'>
719
- ".nzshpcrt_form_field_list(get_option('paypal_form_state'))."
720
- </select>
721
- </td>
722
- </tr>
723
- <tr>
724
- <td>
725
- Postal code/Zip code Field
726
- </td>
727
- <td>
728
- <select name='paypal_form[post_code]'>
729
- ".nzshpcrt_form_field_list(get_option('paypal_form_post_code'))."
730
- </select>
731
- </td>
732
- </tr>
733
- <tr>
734
- <td>
735
- Country Field
736
- </td>
737
- <td>
738
- <select name='paypal_form[country]'>
739
- ".nzshpcrt_form_field_list(get_option('paypal_form_country'))."
740
- </select>
741
- </td>
742
- </tr>
743
- ";
744
- return $output;
745
- }
746
- //paypalfunctions//
747
- /********************************************
748
- PayPal API Module
749
-
750
- Defines all the global variables and the wrapper functions
751
- ********************************************/
752
- $PROXY_HOST = '127.0.0.1';
753
- $PROXY_PORT = '808';
754
-
755
- //'------------------------------------
756
- //' PayPal API Credentials
757
- //'------------------------------------
758
- $API_UserName=get_option('paypal_certified_apiuser');
759
- $API_Password=get_option('paypal_certified_apipass');
760
- $API_Signature=get_option('paypal_certified_apisign');
761
-
762
- // BN Code is only applicable for partners
763
- $sBNCode = "PP-ECWizard";
764
-
765
-
766
- /*
767
- ' Define the PayPal Redirect URLs.
768
- ' This is the URL that the buyer is first sent to do authorize payment with their paypal account
769
- ' change the URL depending if you are testing on the sandbox or the live PayPal site
770
- '
771
- ' For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=
772
- ' For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token=
773
- */
774
- //$SandboxFlag = true;
775
- //exit(get_option('paypal_certified_server_type'));
776
- $SandboxFlag = '';
777
- if (get_option('paypal_certified_server_type') == 'sandbox'){
778
- $SandboxFlag=true;
779
- } elseif(get_option('paypal_certified_server_type') == 'production') {
780
- $SandboxFlag=false;
781
- }
782
- if ($SandboxFlag == true)
783
- {
784
- $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
785
- $PAYPAL_URL = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=";
786
- }
787
- else
788
- {
789
- $API_Endpoint = "https://api-3t.paypal.com/nvp";
790
- $PAYPAL_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
791
- }
792
-
793
- $USE_PROXY = false;
794
- $version="56.0";
795
-
796
- /*
797
- if (session_id() == "")
798
- session_start();
799
- */
800
-
801
- /* An express checkout transaction starts with a token, that
802
- identifies to PayPal your transaction
803
- In this example, when the script sees a token, the script
804
- knows that the buyer has already authorized payment through
805
- paypal. If no token was found, the action is to send the buyer
806
- to PayPal to first authorize payment
807
- */
808
-
809
- /*
810
- '-------------------------------------------------------------------------------------------------------------------------------------------
811
- ' Purpose: Prepares the parameters for the SetExpressCheckout API Call.
812
- ' Inputs:
813
- ' paymentAmount: Total value of the shopping cart
814
- ' currencyCodeType: Currency code value the PayPal API
815
- ' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization
816
- ' returnURL: the page where buyers return to after they are done with the payment review on PayPal
817
- ' cancelURL: the page where buyers return to when they cancel the payment review on PayPal
818
- '--------------------------------------------------------------------------------------------------------------------------------------------
819
- */
820
- function CallShortcutExpressCheckout( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL) {
821
- global $wpdb;
822
- //------------------------------------------------------------------------------------------------------------------------------------
823
- // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
824
- //exit($cancelURL);
825
- $purchase_log = $wpdb->get_row("SELECT `id`,`billing_region` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`= '".$wpdb->escape($_SESSION['paypalexpresssessionid']) ."' LIMIT 1", ARRAY_A) ;
826
- $usersql = "SELECT `".WPSC_TABLE_SUBMITED_FORM_DATA."`.value, `".WPSC_TABLE_CHECKOUT_FORMS."`.`name`, `".WPSC_TABLE_CHECKOUT_FORMS."`.`unique_name` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN `".WPSC_TABLE_SUBMITED_FORM_DATA."` ON `".WPSC_TABLE_CHECKOUT_FORMS."`.id = `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`form_id` WHERE `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`log_id`=".$purchase_log['id']." ORDER BY `".WPSC_TABLE_CHECKOUT_FORMS."`.`order`";
827
- //exit($usersql);
828
- $userinfo = $wpdb->get_results($usersql, ARRAY_A);
829
- // print("<pre>".print_r($usersql,true)."</pre>");
830
- // print("<pre>".print_r($userinfo,true)."</pre>");
831
-
832
- $nvpstr="&Amt=". $paymentAmount;
833
- $nvpstr = $nvpstr . "&PAYMENTACTION=" . $paymentType;
834
- $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL;
835
- $nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL;
836
- $nvpstr = $nvpstr . "&CURRENCYCODE=" . $currencyCodeType;
837
- $data = array();
838
-
839
- foreach((array)$userinfo as $key => $value){
840
- if(($value['unique_name']=='billingfirstname') && $value['value'] != ''){
841
- $data['SHIPTONAME'] = $value['value'];
842
- }
843
- if(($value['unique_name']=='billinglastname') && $value['value'] != ''){
844
- $data['SHIPTONAME'] .= " ".$value['value'];
845
- }
846
-
847
- if(($value['unique_name']=='billingaddress') && $value['value'] != ''){
848
- $data['SHIPTOSTREET'] = $value['value'];
849
- }
850
- if(($value['unique_name']=='billingcity') && $value['value'] != ''){
851
- $data['SHIPTOCITY'] = $value['value'];
852
- }
853
- if(($value['unique_name']=='billingcountry') && $value['value'] != ''){
854
- $data['SHIPTOCOUNTRYCODE'] = $value['value'];
855
- $state = $wpdb->get_var("SELECT `code` FROM `".WPSC_TABLE_REGION_TAX."` WHERE `id` ='{$purchase_log['billing_region']}' LIMIT 1");
856
- if($purchase_log['billing_region'] > 0) {
857
- $data['SHIPTOSTATE'] = $state;
858
- }
859
- }
860
- if(($value['unique_name']=='billingpostcode') && $value['value'] != ''){
861
- $data['SHIPTOZIP'] = $value['value'];
862
- }
863
- }
864
-
865
- if(count($data) >= 4) {
866
- //$data['ADDROVERRIDE'] = 1;
867
- $temp_data = array();
868
- foreach($data as $key => $value) {
869
- $temp_data[] = $key."=".$value;
870
- }
871
- $nvpstr = $nvpstr . "&".implode("&",$temp_data);
872
- }
873
-
874
- //print("<pre>".print_r($data,true)."</pre>");
875
- //exit($nvpstr);
876
- $_SESSION["currencyCodeType"] = $currencyCodeType;
877
- $_SESSION["PaymentType"] = $paymentType;
878
-
879
- //'---------------------------------------------------------------------------------------------------------------
880
- //' Make the API call to PayPal
881
- //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.
882
- //' If an error occured, show the resulting errors
883
- //'---------------------------------------------------------------------------------------------------------------
884
- $resArray=hash_call("SetExpressCheckout", $nvpstr);
885
- $ack = strtoupper($resArray["ACK"]);
886
- if($ack=="SUCCESS")
887
- {
888
- $token = urldecode($resArray["TOKEN"]);
889
- $_SESSION['TOKEN']=$token;
890
- }
891
-
892
- return $resArray;
893
- }
894
-
895
- /*
896
- '-------------------------------------------------------------------------------------------------------------------------------------------
897
- ' Purpose: Prepares the parameters for the SetExpressCheckout API Call.
898
- ' Inputs:
899
- ' paymentAmount: Total value of the shopping cart
900
- ' currencyCodeType: Currency code value the PayPal API
901
- ' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization
902
- ' returnURL: the page where buyers return to after they are done with the payment review on PayPal
903
- ' cancelURL: the page where buyers return to when they cancel the payment review on PayPal
904
- ' shipToName: the Ship to name entered on the merchant's site
905
- ' shipToStreet: the Ship to Street entered on the merchant's site
906
- ' shipToCity: the Ship to City entered on the merchant's site
907
- ' shipToState: the Ship to State entered on the merchant's site
908
- ' shipToCountryCode: the Code for Ship to Country entered on the merchant's site
909
- ' shipToZip: the Ship to ZipCode entered on the merchant's site
910
- ' shipToStreet2: the Ship to Street2 entered on the merchant's site
911
- ' phoneNum: the phoneNum entered on the merchant's site
912
- '--------------------------------------------------------------------------------------------------------------------------------------------
913
- */
914
- function CallMarkExpressCheckout( $paymentAmount, $currencyCodeType, $paymentType, $returnURL,
915
- $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState,
916
- $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum
917
- )
918
- {
919
- //------------------------------------------------------------------------------------------------------------------------------------
920
- // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
921
-
922
- $nvpstr="&Amt=". $paymentAmount;
923
- $nvpstr = $nvpstr . "&PAYMENTACTION=" . $paymentType;
924
- $nvpstr = $nvpstr . "&ReturnUrl=" . $returnURL;
925
- $nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL;
926
- $nvpstr = $nvpstr . "&CURRENCYCODE=" . $currencyCodeType;
927
- $nvpstr = $nvpstr . "&ADDROVERRIDE=1";
928
- $nvpstr = $nvpstr . "&SHIPTONAME=" . $shipToName;
929
- $nvpstr = $nvpstr . "&SHIPTOSTREET=" . $shipToStreet;
930
- $nvpstr = $nvpstr . "&SHIPTOSTREET2=" . $shipToStreet2;
931
- $nvpstr = $nvpstr . "&SHIPTOCITY=" . $shipToCity;
932
- $nvpstr = $nvpstr . "&SHIPTOSTATE=" . $shipToState;
933
- $nvpstr = $nvpstr . "&SHIPTOCOUNTRYCODE=" . $shipToCountryCode;
934
- $nvpstr = $nvpstr . "&SHIPTOZIP=" . $shipToZip;
935
- $nvpstr = $nvpstr . "&PHONENUM=" . $phoneNum;
936
-
937
- $_SESSION["currencyCodeType"] = $currencyCodeType;
938
- $_SESSION["PaymentType"] = $paymentType;
939
-
940
- //'---------------------------------------------------------------------------------------------------------------
941
- //' Make the API call to PayPal
942
- //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.
943
- //' If an error occured, show the resulting errors
944
- //'---------------------------------------------------------------------------------------------------------------
945
- $resArray=hash_call("SetExpressCheckout", $nvpstr);
946
- $ack = strtoupper($resArray["ACK"]);
947
- if($ack=="SUCCESS")
948
- {
949
- $token = urldecode($resArray["TOKEN"]);
950
- $_SESSION['TOKEN']=$token;
951
- }
952
-
953
- return $resArray;
954
- }
955
-
956
- /*
957
- '-------------------------------------------------------------------------------------------
958
- ' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call.
959
- '
960
- ' Inputs:
961
- ' None
962
- ' Returns:
963
- ' The NVP Collection object of the GetExpressCheckoutDetails Call Response.
964
- '-------------------------------------------------------------------------------------------
965
- */
966
- function GetShippingDetails( $token )
967
- {
968
- //'--------------------------------------------------------------
969
- //' At this point, the buyer has completed authorizing the payment
970
- //' at PayPal. The function will call PayPal to obtain the details
971
- //' of the authorization, incuding any shipping information of the
972
- //' buyer. Remember, the authorization is not a completed transaction
973
- //' at this state - the buyer still needs an additional step to finalize
974
- //' the transaction
975
- //'--------------------------------------------------------------
976
-
977
- //'---------------------------------------------------------------------------
978
- //' Build a second API request to PayPal, using the token as the
979
- //' ID to get the details on the payment authorization
980
- //'---------------------------------------------------------------------------
981
- $nvpstr="&TOKEN=" . $token;
982
-
983
- //'---------------------------------------------------------------------------
984
- //' Make the API call and store the results in an array.
985
- //' If the call was a success, show the authorization details, and provide
986
- //' an action to complete the payment.
987
- //' If failed, show the error
988
- //'---------------------------------------------------------------------------
989
- $resArray=hash_call("GetExpressCheckoutDetails",$nvpstr);
990
- $ack = strtoupper($resArray["ACK"]);
991
- if($ack == "SUCCESS")
992
- {
993
- $_SESSION['payer_id'] = $resArray['PAYERID'];
994
- }
995
- return $resArray;
996
- }
997
-
998
- /*
999
- '-------------------------------------------------------------------------------------------------------------------------------------------
1000
- ' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call.
1001
- '
1002
- ' Inputs:
1003
- ' sBNCode: The BN code used by PayPal to track the transactions from a given shopping cart.
1004
- ' Returns:
1005
- ' The NVP Collection object of the GetExpressCheckoutDetails Call Response.
1006
- '--------------------------------------------------------------------------------------------------------------------------------------------
1007
- */
1008
- function ConfirmPayment( $FinalPaymentAmt )
1009
- {
1010
- /* Gather the information to make the final call to
1011
- finalize the PayPal payment. The variable nvpstr
1012
- holds the name value pairs
1013
- */
1014
-
1015
-
1016
- //Format the other parameters that were stored in the session from the previous calls
1017
- $token = urlencode($_SESSION['token']);
1018
- $paymentType = urlencode($_SESSION['paymentType']);
1019
- $currencyCodeType = urlencode($_SESSION['currencyCodeType']);
1020
- $payerID = urlencode($_SESSION['payer_id']);
1021
-
1022
- $serverName = urlencode($_SERVER['SERVER_NAME']);
1023
-
1024
- $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTACTION=' . $paymentType . '&AMT=' . $FinalPaymentAmt;
1025
- $nvpstr .= '&CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName;
1026
-
1027
- /* Make the call to PayPal to finalize payment
1028
- If an error occured, show the resulting errors
1029
- */
1030
- $resArray=hash_call("DoExpressCheckoutPayment",$nvpstr);
1031
-
1032
- /* Display the API response back to the browser.
1033
- If the response from PayPal was a success, display the response parameters'
1034
- If the response was an error, display the errors received using APIError.php.
1035
- */
1036
- $ack = strtoupper($resArray["ACK"]);
1037
-
1038
- return $resArray;
1039
- }
1040
-
1041
- /**
1042
- '-------------------------------------------------------------------------------------------------------------------------------------------
1043
- * hash_call: Function to perform the API call to PayPal using API signature
1044
- * @methodName is name of API method.
1045
- * @nvpStr is nvp string.
1046
- * returns an associtive array containing the response from the server.
1047
- '-------------------------------------------------------------------------------------------------------------------------------------------
1048
- */
1049
- function hash_call($methodName,$nvpStr)
1050
- {
1051
- //declaring of global variables
1052
- global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature;
1053
- global $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
1054
- global $gv_ApiErrorURL;
1055
- global $sBNCode;
1056
-
1057
- //setting the curl parameters.
1058
- $ch = curl_init();
1059
-
1060
- curl_setopt($ch, CURLOPT_URL,$API_Endpoint);
1061
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
1062
-
1063
- //turning off the server and peer verification(TrustManager Concept).
1064
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
1065
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
1066
-
1067
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
1068
- curl_setopt($ch, CURLOPT_POST, 1);
1069
-
1070
- //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
1071
- //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
1072
- if($USE_PROXY)
1073
- curl_setopt ($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT);
1074
-
1075
- //NVPRequest for submitting to server
1076
- $nvpreq="METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode);
1077
-
1078
- //setting the nvpreq as POST FIELD to curl
1079
- curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
1080
- //exit($nvpreq);
1081
- //getting response from server
1082
- $response = curl_exec($ch);
1083
- //exit('<pre>'.print_r($response, true).'</pre>');
1084
- //convrting NVPResponse to an Associative Array
1085
- $nvpResArray=deformatNVP($response);
1086
- $nvpReqArray=deformatNVP($nvpreq);
1087
- $_SESSION['nvpReqArray']=$nvpReqArray;
1088
-
1089
- if (curl_errno($ch))
1090
- {
1091
- // moving to display page to display curl errors
1092
- $_SESSION['curl_error_no']=curl_errno($ch) ;
1093
- $_SESSION['curl_error_msg']=curl_error($ch);
1094
-
1095
- //Execute the Error handling module to display errors.
1096
- }
1097
- else
1098
- {
1099
- //closing the curl
1100
- curl_close($ch);
1101
- } return $nvpResArray;
1102
- }
1103
-
1104
- /*'----------------------------------------------------------------------------------
1105
- Purpose: Redirects to PayPal.com site.
1106
- Inputs: NVP string.
1107
- Returns:
1108
- ----------------------------------------------------------------------------------
1109
- */
1110
- function RedirectToPayPal ( $token )
1111
- {
1112
- global $PAYPAL_URL;
1113
-
1114
- // Redirect to paypal.com here
1115
- $payPalURL = $PAYPAL_URL . $token;
1116
- header("Location: ".$payPalURL);
1117
- }
1118
-
1119
-
1120
- /*'----------------------------------------------------------------------------------
1121
- * This function will take NVPString and convert it to an Associative Array and it will decode the response.
1122
- * It is usefull to search for a particular key and displaying arrays.
1123
- * @nvpstr is NVPString.
1124
- * @nvpArray is Associative Array.
1125
- ----------------------------------------------------------------------------------
1126
- */
1127
- function deformatNVP($nvpstr) {
1128
- $intial=0;
1129
- $nvpArray = array();
1130
-
1131
- while(strlen($nvpstr)) {
1132
- //postion of Key
1133
- $keypos= strpos($nvpstr,'=');
1134
- //position of value
1135
- $valuepos = strpos($nvpstr,'&') ? strpos($nvpstr,'&'): strlen($nvpstr);
1136
-
1137
- /*getting the Key and Value values and storing in a Associative Array*/
1138
- $keyval=substr($nvpstr,$intial,$keypos);
1139
- $valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1);
1140
- //decoding the respose
1141
- $nvpArray[urldecode($keyval)] =urldecode( $valval);
1142
- $nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr));
1143
- }
1144
- return $nvpArray;
1145
- }
1146
- add_action('init', 'processingfunctions');
1147
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-merchants/testmode.merchant.php CHANGED
@@ -32,7 +32,6 @@ class wpsc_merchant_testmode extends wpsc_merchant {
32
 
33
  function submit() {
34
  $this->set_purchase_processed_by_purchid(2);
35
- //$this->set_transaction_details();
36
  $this->go_to_transaction_results($this->cart_data['session_id']);
37
 
38
  exit();
@@ -43,8 +42,6 @@ class wpsc_merchant_testmode extends wpsc_merchant {
43
  function form_testmode() {
44
  $output = "<tr>\n\r";
45
  $output .= " <td colspan='2'>\n\r";
46
- // $output = " </td>\n\r";
47
- // $output = " <td>\n\r";
48
 
49
  $output .= "<strong>".__('Enter the payment instructions that you wish to display to your customers when they make a purchase', 'wpsc').":</strong><br />\n\r";
50
  $output .= "<textarea cols='40' rows='9' name='wpsc_options[payment_instructions]'>".stripslashes(get_option('payment_instructions'))."</textarea><br />\n\r";
32
 
33
  function submit() {
34
  $this->set_purchase_processed_by_purchid(2);
 
35
  $this->go_to_transaction_results($this->cart_data['session_id']);
36
 
37
  exit();
42
  function form_testmode() {
43
  $output = "<tr>\n\r";
44
  $output .= " <td colspan='2'>\n\r";
 
 
45
 
46
  $output .= "<strong>".__('Enter the payment instructions that you wish to display to your customers when they make a purchase', 'wpsc').":</strong><br />\n\r";
47
  $output .= "<textarea cols='40' rows='9' name='wpsc_options[payment_instructions]'>".stripslashes(get_option('payment_instructions'))."</textarea><br />\n\r";
wpsc-shipping/flatrate.php CHANGED
@@ -9,7 +9,6 @@
9
  class flatrate {
10
  var $internal_name, $name;
11
 
12
-
13
  /**
14
  *
15
  *
@@ -22,10 +21,6 @@ class flatrate {
22
  return true;
23
  }
24
 
25
-
26
-
27
-
28
-
29
  /**
30
  *
31
  *
@@ -35,10 +30,6 @@ class flatrate {
35
  return $this->name;
36
  }
37
 
38
-
39
-
40
-
41
-
42
  /**
43
  *
44
  *
@@ -48,13 +39,6 @@ class flatrate {
48
  return $this->internal_name;
49
  }
50
 
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
  /**
59
  *
60
  *
@@ -89,13 +73,8 @@ class flatrate {
89
  $output .= "<tr class='rate_row'><td>Europe</td><td>$<input type='text' size='4' name='shipping[europe]' value='{$shipping['europe']}'></td></tr>";
90
  $output .= "<tr class='rate_row'><td>Africa</td><td>$<input type='text' size='4' name='shipping[africa]' value='{$shipping['africa']}'></td></tr>";
91
  return $output;
92
-
93
  }
94
 
95
-
96
-
97
-
98
-
99
  /**
100
  *
101
  *
@@ -112,10 +91,6 @@ class flatrate {
112
  return true;
113
  }
114
 
115
-
116
-
117
-
118
-
119
  /**
120
  *
121
  *
@@ -220,13 +195,6 @@ class flatrate {
220
 
221
  }
222
 
223
-
224
-
225
-
226
-
227
-
228
-
229
-
230
  /**
231
  *
232
  *
@@ -282,10 +250,6 @@ class flatrate {
282
  return $shipping;
283
  }
284
 
285
-
286
-
287
-
288
-
289
  /**
290
  *
291
  *
@@ -296,8 +260,6 @@ class flatrate {
296
  function get_cart_shipping($total_price, $weight) {
297
  return $output;
298
  }
299
-
300
-
301
  }
302
 
303
 
9
  class flatrate {
10
  var $internal_name, $name;
11
 
 
12
  /**
13
  *
14
  *
21
  return true;
22
  }
23
 
 
 
 
 
24
  /**
25
  *
26
  *
30
  return $this->name;
31
  }
32
 
 
 
 
 
33
  /**
34
  *
35
  *
39
  return $this->internal_name;
40
  }
41
 
 
 
 
 
 
 
 
42
  /**
43
  *
44
  *
73
  $output .= "<tr class='rate_row'><td>Europe</td><td>$<input type='text' size='4' name='shipping[europe]' value='{$shipping['europe']}'></td></tr>";
74
  $output .= "<tr class='rate_row'><td>Africa</td><td>$<input type='text' size='4' name='shipping[africa]' value='{$shipping['africa']}'></td></tr>";
75
  return $output;
 
76
  }
77
 
 
 
 
 
78
  /**
79
  *
80
  *
91
  return true;
92
  }
93
 
 
 
 
 
94
  /**
95
  *
96
  *
195
 
196
  }
197
 
 
 
 
 
 
 
 
198
  /**
199
  *
200
  *
250
  return $shipping;
251
  }
252
 
 
 
 
 
253
  /**
254
  *
255
  *
260
  function get_cart_shipping($total_price, $weight) {
261
  return $output;
262
  }
 
 
263
  }
264
 
265
 
wpsc-shipping/library/shipwire_functions.php CHANGED
@@ -20,8 +20,6 @@ function shipwire_build_xml($log_id) {
20
  }
21
 
22
  foreach ($form_info as $info) {
23
- //echo "<pre>".print_r(array_flip($form_info),1)."</pre>";
24
- // exit (print_r(!array_search('delivery_address',$info),1));
25
  if ((($info['type'] == 'delivery_address') && ($info['active']=='1')) || (!$delivery_address && ($info['type'] == 'address') && ($info['active']=='1'))) {
26
  $address_key = $info['id'];
27
  } else if((($info['type'] == 'delivery_city') && ($info['active']=='1')) || (!$delivery_city && ($info['type'] == 'city') && ($info['active']=='1'))) {
@@ -38,10 +36,8 @@ function shipwire_build_xml($log_id) {
38
  }
39
 
40
  $user_infos = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_SUBMITED_FORM_DATA." WHERE log_id='".$log_id."'", ARRAY_A);
41
- //echo (print_r($user_infos,1));
42
  foreach ($user_infos as $user_info) {
43
  if ($user_info['form_id'] == $address_key) {
44
- //exit ($user_info['form_id']." ".$address_key);
45
  $address = $user_info['value'];
46
  }
47
  if ($user_info['form_id'] == $city_key) {
@@ -67,7 +63,6 @@ function shipwire_build_xml($log_id) {
67
  }
68
  $full_name = $first_name." ".$last_name;
69
  $products = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_CART_CONTENTS." WHERE purchaseid='".$log_id."'",ARRAY_A);
70
- //return $log_id;
71
  $xml = "<?xml version='1.0' encoding='utf-8'?>";
72
  $xml .= "<OrderList>";
73
  $xml .= "<EmailAddress>$email</EmailAddress>";
20
  }
21
 
22
  foreach ($form_info as $info) {
 
 
23
  if ((($info['type'] == 'delivery_address') && ($info['active']=='1')) || (!$delivery_address && ($info['type'] == 'address') && ($info['active']=='1'))) {
24
  $address_key = $info['id'];
25
  } else if((($info['type'] == 'delivery_city') && ($info['active']=='1')) || (!$delivery_city && ($info['type'] == 'city') && ($info['active']=='1'))) {
36
  }
37
 
38
  $user_infos = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_SUBMITED_FORM_DATA." WHERE log_id='".$log_id."'", ARRAY_A);
 
39
  foreach ($user_infos as $user_info) {
40
  if ($user_info['form_id'] == $address_key) {
 
41
  $address = $user_info['value'];
42
  }
43
  if ($user_info['form_id'] == $city_key) {
63
  }
64
  $full_name = $first_name." ".$last_name;
65
  $products = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_CART_CONTENTS." WHERE purchaseid='".$log_id."'",ARRAY_A);
 
66
  $xml = "<?xml version='1.0' encoding='utf-8'?>";
67
  $xml .= "<OrderList>";
68
  $xml .= "<EmailAddress>$email</EmailAddress>";
wpsc-shipping/nzpost.php DELETED
@@ -1,83 +0,0 @@
1
- <?php /*
2
- class nzpost {
3
- var $internal_name, $name;
4
- function nzpost () {
5
-
6
- $this->internal_name = "nzpost";
7
- $this->name="NZ Post";
8
- $this->is_external=true;
9
- $this->requires_curl=true;
10
- $this->requires_weight=false;
11
- $this->needs_zipcode=false;
12
- $this->xml2Array;
13
-
14
- return true;
15
- }
16
-
17
- function getId() {
18
- // return $this->usps_id;
19
- }
20
-
21
- function setId($id) {
22
- // $usps_id = $id;
23
- // return true;
24
- }
25
-
26
- function getName() {
27
- return $this->name;
28
- }
29
-
30
- function getInternalName() {
31
- return $this->internal_name;
32
- }
33
-
34
- function getForm() {
35
- $output = "<label for='wpsc_nzpost_trackAPI'>Tracking API: </label>";
36
- $output .= "<input type='text' value='".get_option('wpsc_nzpost_trackAPI')."' name='wpsc_nzpost_trackAPI' />";
37
- return $output;
38
- }
39
-
40
- function submit_form() {
41
- global $wpdb;
42
- if ($_POST['wpsc_nzpost_trackAPI'] != '') {
43
- $value = $wpdb->escape($_POST['wpsc_nzpost_trackAPI']);
44
- update_option('wpsc_nzpost_trackAPI', $value);
45
- }
46
- return true;
47
- }
48
- function getStatus($trackid){
49
- require_once(WPSC_FILE_PATH."/wpsc-includes/xmlparser.php");
50
- $url = 'http://services.nzpost.co.nz/TrackAndTrace.svc/TrackID/';
51
- $nzposttrackAPI = get_option('wpsc_nzpost_trackAPI');
52
- $version = '10.1.2.3';
53
- $trackid = 'JB101069625NZ';
54
- $url = $url.$nzposttrackAPI.'/'.$version.'/'.$trackid;
55
- $ch = curl_init();
56
-
57
- curl_setopt($ch, CURLOPT_URL, $url);
58
- curl_setopt($ch, CURLOPT_HEADER, 0);
59
- // curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
60
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
61
- $Results=curl_exec($ch);
62
-
63
- curl_close($ch);
64
- $parser = new xml2array;
65
- $parsed = $parser->parse($Results);
66
- $_SESSION['wpsc_nzpost_parsed'] = $parsed;
67
- $this->xml2Array = $parsed;
68
- return $parsed[0]['children'][0]['children'][2]['tagData'];
69
- }
70
- function getMethod() {
71
-
72
- }
73
-
74
- function getQuote() {
75
-
76
- }
77
-
78
- function get_item_shipping() {
79
- }
80
- }
81
- $nzpost = new nzpost();
82
- $wpsc_shipping_modules[$nzpost->getInternalName()] = $nzpost;*/
83
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-shipping/tablerate.php CHANGED
@@ -10,7 +10,6 @@ class tablerate {
10
 
11
  var $internal_name, $name;
12
 
13
-
14
  /**
15
  *
16
  *
@@ -23,10 +22,6 @@ class tablerate {
23
  return true;
24
  }
25
 
26
-
27
-
28
-
29
-
30
  /**
31
  *
32
  *
@@ -36,10 +31,6 @@ class tablerate {
36
  return $this->name;
37
  }
38
 
39
-
40
-
41
-
42
-
43
  /**
44
  *
45
  *
@@ -49,10 +40,6 @@ class tablerate {
49
  return $this->internal_name;
50
  }
51
 
52
-
53
-
54
-
55
-
56
  /**
57
  *
58
  *
@@ -86,10 +73,6 @@ class tablerate {
86
  return $output;
87
  }
88
 
89
-
90
-
91
-
92
-
93
  /**
94
  *
95
  *
@@ -122,10 +105,6 @@ class tablerate {
122
  return true;
123
  }
124
 
125
-
126
-
127
-
128
-
129
  /**
130
  *
131
  *
@@ -187,12 +166,6 @@ class tablerate {
187
  }
188
  }
189
 
190
-
191
-
192
-
193
-
194
-
195
-
196
  /**
197
  *
198
  *
10
 
11
  var $internal_name, $name;
12
 
 
13
  /**
14
  *
15
  *
22
  return true;
23
  }
24
 
 
 
 
 
25
  /**
26
  *
27
  *
31
  return $this->name;
32
  }
33
 
 
 
 
 
34
  /**
35
  *
36
  *
40
  return $this->internal_name;
41
  }
42
 
 
 
 
 
43
  /**
44
  *
45
  *
73
  return $output;
74
  }
75
 
 
 
 
 
76
  /**
77
  *
78
  *
105
  return true;
106
  }
107
 
 
 
 
 
108
  /**
109
  *
110
  *
166
  }
167
  }
168
 
 
 
 
 
 
 
169
  /**
170
  *
171
  *
wpsc-shipping/ups.php CHANGED
@@ -306,13 +306,9 @@ class ups {
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";}
@@ -338,8 +334,8 @@ class ups {
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);
@@ -423,10 +419,9 @@ class ups {
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
@@ -461,8 +456,6 @@ class ups {
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
 
@@ -545,7 +538,6 @@ class ups {
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);
@@ -568,15 +560,7 @@ class ups {
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>
@@ -744,15 +728,11 @@ class ups {
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']);
306
  $xml = "";
307
  if (is_array($data)){
308
  foreach($data as $key=>$value){
309
+ $xml .= "<".trim($key).">\n";
310
+ $xml .= $this->array2xml($value);
311
+ $xml .= "</".trim($key).">\n";
 
 
 
 
312
  }
313
  }else if(is_bool($data)){
314
  if($data){$xml = "true\n";}
334
 
335
  $access = array(
336
  "AccessLicenseNumber"=>base64_decode($args['api_id']), // UPS API ID#
337
+ "UserId" =>base64_decode($args['username']), // UPS API Username
338
+ "Password" =>base64_decode($args['password']) // UPS API Password
339
  );
340
 
341
  $REQUEST .= $this->array2xml($access);
419
 
420
  $Shipment["ShipTo"]= array(
421
  "Address"=>array(
422
+ "StateProvinceCode"=>$args['dest_state'], // The Destination State
423
+ "PostalCode"=>$args['dest_pcode'], // The Destination Postal Code
424
+ "CountryCode"=>$args['dest_ccode'], // The Destination Country
 
425
  ));
426
 
427
  if ($args['residential'] == '1'){ //ResidentialAddressIndicator orig - Indicator
456
  $REQUEST .= "</RatingServiceSelectionRequest>";
457
 
458
  // Return the final XML document as a string to be used by _makeRateRequest
 
 
459
  return $REQUEST;
460
  }
461
 
538
  $price = "";
539
  $time = "";
540
 
 
541
  $getNegotiatedRateNode = $rate_block->getElementsByTagName("NegotiatedRates");
542
  if ($getNegotiatedRateNode){
543
  $negotiatedRateNode = $getNegotiatedRateNode->item(0);
560
  // Get the <TotalCharges> Node from the XML chunk
561
  $getChargeNodes = $rate_block->getElementsByTagName("TotalCharges");
562
  $chargeNode = $getChargeNodes->item(0);
563
+
 
 
 
 
 
 
 
 
564
  // Get the <CurrencyCode> from the <TotalCharge> chunk
565
  $getCurrNode= $chargeNode->getElementsByTagName("CurrencyCode");
566
  // Get the value of <CurrencyCode>
728
  }else{
729
  // Build the XML request
730
  $request = $this->_buildRateRequest($args);
 
 
731
  // Now that we have the message to send ... Send it!
732
  $raw_quote = $this->_makeRateRequest($request);
733
  // Now we have the UPS response .. unfortunately its not ready
734
  // to be viewed by normal humans ...
735
  $quotes = $this->_parseQuote($raw_quote);
 
 
736
  // If we actually have rates back from UPS we can use em!
737
  if ($quotes != false){
738
  $rate_table = $this->_formatTable($quotes,$args['currency']);
wpsc-shipping/usps.php CHANGED
@@ -107,7 +107,6 @@ class usps {
107
  }
108
 
109
  function submit_form() {
110
- // exit('<pre>'.print_r($_POST, true).'</pre>');
111
  if ($_POST['uspsid'] != '') {
112
  update_option('uspsid', $_POST['uspsid']);
113
  }
@@ -171,7 +170,6 @@ class usps {
171
  "PRIORITY_REGULAR" => 0,
172
  "PRIORITY_LARGE" => 0,
173
  "EXPRESS" => 0,
174
- //"EXPRESS HFP" => 0,
175
  "EXPRESS_REGULAR" => 0,
176
  "PARCEL POST" => 0,
177
  "MEDIA" => 0,
@@ -220,14 +218,6 @@ class usps {
220
  $container = 'FLAT RATE ENVELOPE';
221
  }
222
 
223
- /*
224
- if ($key == 'EXPRESS HFP') {
225
- echo 'alio alio';
226
- $container = 'FLAT RATE ENVELOPE';
227
- }
228
- *
229
- */
230
-
231
  if ($key == 'EXPRESS_REGULAR') {
232
  $key = 'EXPRESS';
233
  $container = '';
@@ -261,7 +251,6 @@ class usps {
261
  '<Size>' . $size . '</Size>' .
262
  '<Machinable>' . $machinable . '</Machinable>' .
263
  '</Package>';
264
- //echo 'A<pre>'.$request.'</pre>A';
265
 
266
  if ($transit) {
267
  $transitreq = 'USERID="' . MODULE_SHIPPING_USPS_USERID .
@@ -286,7 +275,6 @@ class usps {
286
  $services_count++;
287
  }
288
  $request .= '</RateV3Request>'; //'</RateRequest>'; //Changed by Greg Deeth April 30, 2008
289
- //exit($request);
290
  $request = 'API=RateV3&XML=' . urlencode($request);
291
  } else {
292
  $dest=$wpdb->get_var("SELECT country FROM ".WPSC_TABLE_CURRENCY_LIST." WHERE isocode='".$dest."'");
@@ -313,7 +301,6 @@ class usps {
313
  }else {
314
  $url = 'http://'.$usps_server.'/' . $api_dll . '?' . $request;
315
  }
316
- //exit('URL '.$url);
317
  $ch=curl_init();
318
  curl_setopt($ch, CURLOPT_URL, $url);
319
  curl_setopt($ch, CURLOPT_NOPROGRESS, 1);
@@ -323,10 +310,7 @@ class usps {
323
  curl_setopt($ch, CURLOPT_USERAGENT, 'wp-e-commerce');
324
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
325
  $body = curl_exec($ch);
326
- //echo '<pre>'.print_r($body, true).'</pre>';
327
- //exit('Response:<pre>'.print_r($body, true).'</pre>'.$url);
328
  curl_close($ch);
329
- //exit($body);
330
  $rates=array();
331
  $response=array();
332
  while (true) {
@@ -347,7 +331,6 @@ class usps {
347
  $number = $regs[1];
348
  $description = ereg('<Description>(.*)</Description>', $response[0], $regs);
349
  $description = $regs[1];
350
- //return array('error' => $number . ' - ' . $description);
351
  }
352
  }
353
 
@@ -411,14 +394,12 @@ class usps {
411
  }
412
  }
413
  $wpsc_usps_quote = $rates;
414
- //return $rates;
415
  } else {
416
  if (ereg('<Error>', $response[0])) {
417
  $number = ereg('<Number>(.*)</Number>', $response[0], $regs);
418
  $number = $regs[1];
419
  $description = ereg('<Description>(.*)</Description>', $response[0], $regs);
420
  $description = $regs[1];
421
- //return array('error' => $number . ' - ' . $description);
422
  } else {
423
  $body = $response[0];
424
  $services = array();
@@ -434,7 +415,6 @@ class usps {
434
  }
435
 
436
  $allowed_types = Array( 'EXPRESS MAIL INT' => "Express Mail International (EMS)", 'EXPRESS MAIL INT FLAT RATE ENV' => "Express Mail International (EMS) Flat-Rate Envelope", 'PRIORITY MAIL INT' => "Priority Mail International", 'PRIORITY MAIL INT FLAT RATE ENV' => "Priority Mail International Flat-Rate Envelope", 'PRIORITY MAIL INT FLAT RATE BOX' => "Priority Mail International Flat-Rate Box", 'FIRST-CLASS MAIL INT' => "First Class Mail International Letters" );
437
- //foreach( explode(", ", MODULE_SHIPPING_USPS_TYPES_INTL) as $value ) $allowed_types[$value] = $this->intl_types[$value];
438
 
439
  $size = sizeof($services);
440
  for ($i=0, $n=$size; $i<$n; $i++) {
@@ -454,12 +434,10 @@ class usps {
454
  if ($time != '') $transittime[$service] = ' (' . $time . ')';
455
  }
456
  }
457
- //$uspsQuote=$rates;
458
  }
459
  }
460
  $uspsQuote=$rates;
461
  $wpsc_usps_quote = $rates;
462
- //echo ('<pre>'.print_r($uspsQuote,true).'</pre>');
463
  return $uspsQuote;
464
  }
465
 
107
  }
108
 
109
  function submit_form() {
 
110
  if ($_POST['uspsid'] != '') {
111
  update_option('uspsid', $_POST['uspsid']);
112
  }
170
  "PRIORITY_REGULAR" => 0,
171
  "PRIORITY_LARGE" => 0,
172
  "EXPRESS" => 0,
 
173
  "EXPRESS_REGULAR" => 0,
174
  "PARCEL POST" => 0,
175
  "MEDIA" => 0,
218
  $container = 'FLAT RATE ENVELOPE';
219
  }
220
 
 
 
 
 
 
 
 
 
221
  if ($key == 'EXPRESS_REGULAR') {
222
  $key = 'EXPRESS';
223
  $container = '';
251
  '<Size>' . $size . '</Size>' .
252
  '<Machinable>' . $machinable . '</Machinable>' .
253
  '</Package>';
 
254
 
255
  if ($transit) {
256
  $transitreq = 'USERID="' . MODULE_SHIPPING_USPS_USERID .
275
  $services_count++;
276
  }
277
  $request .= '</RateV3Request>'; //'</RateRequest>'; //Changed by Greg Deeth April 30, 2008
 
278
  $request = 'API=RateV3&XML=' . urlencode($request);
279
  } else {
280
  $dest=$wpdb->get_var("SELECT country FROM ".WPSC_TABLE_CURRENCY_LIST." WHERE isocode='".$dest."'");
301
  }else {
302
  $url = 'http://'.$usps_server.'/' . $api_dll . '?' . $request;
303
  }
 
304
  $ch=curl_init();
305
  curl_setopt($ch, CURLOPT_URL, $url);
306
  curl_setopt($ch, CURLOPT_NOPROGRESS, 1);
310
  curl_setopt($ch, CURLOPT_USERAGENT, 'wp-e-commerce');
311
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
312
  $body = curl_exec($ch);
 
 
313
  curl_close($ch);
 
314
  $rates=array();
315
  $response=array();
316
  while (true) {
331
  $number = $regs[1];
332
  $description = ereg('<Description>(.*)</Description>', $response[0], $regs);
333
  $description = $regs[1];
 
334
  }
335
  }
336
 
394
  }
395
  }
396
  $wpsc_usps_quote = $rates;
 
397
  } else {
398
  if (ereg('<Error>', $response[0])) {
399
  $number = ereg('<Number>(.*)</Number>', $response[0], $regs);
400
  $number = $regs[1];
401
  $description = ereg('<Description>(.*)</Description>', $response[0], $regs);
402
  $description = $regs[1];
 
403
  } else {
404
  $body = $response[0];
405
  $services = array();
415
  }
416
 
417
  $allowed_types = Array( 'EXPRESS MAIL INT' => "Express Mail International (EMS)", 'EXPRESS MAIL INT FLAT RATE ENV' => "Express Mail International (EMS) Flat-Rate Envelope", 'PRIORITY MAIL INT' => "Priority Mail International", 'PRIORITY MAIL INT FLAT RATE ENV' => "Priority Mail International Flat-Rate Envelope", 'PRIORITY MAIL INT FLAT RATE BOX' => "Priority Mail International Flat-Rate Box", 'FIRST-CLASS MAIL INT' => "First Class Mail International Letters" );
 
418
 
419
  $size = sizeof($services);
420
  for ($i=0, $n=$size; $i<$n; $i++) {
434
  if ($time != '') $transittime[$service] = ' (' . $time . ')';
435
  }
436
  }
 
437
  }
438
  }
439
  $uspsQuote=$rates;
440
  $wpsc_usps_quote = $rates;
 
441
  return $uspsQuote;
442
  }
443
 
wpsc-shipping/weightrate.php CHANGED
@@ -9,7 +9,6 @@
9
  class weightrate {
10
  var $internal_name, $name;
11
 
12
-
13
  /**
14
  *
15
  *
@@ -22,10 +21,6 @@ class weightrate {
22
  return true;
23
  }
24
 
25
-
26
-
27
-
28
-
29
  /**
30
  *
31
  *
@@ -35,10 +30,6 @@ class weightrate {
35
  return $this->name;
36
  }
37
 
38
-
39
-
40
-
41
-
42
  /**
43
  *
44
  *
@@ -48,10 +39,6 @@ class weightrate {
48
  return $this->internal_name;
49
  }
50
 
51
-
52
-
53
-
54
-
55
  /**
56
  *
57
  *
@@ -78,13 +65,8 @@ class weightrate {
78
  $output.="<tr class='addlayer'><td colspan='2'>Layers: <a style='cursor:pointer;' id='addweightlayer' >Add Layer</a></td></tr>";
79
 
80
  return $output;
81
-
82
  }
83
 
84
-
85
-
86
-
87
-
88
  /**
89
  *
90
  *
@@ -125,15 +107,9 @@ class weightrate {
125
  update_option('weight_rate_layers', $new_layer);
126
 
127
  }
128
-
129
  return true;
130
-
131
  }
132
 
133
-
134
-
135
-
136
-
137
  /**
138
  *
139
  *
@@ -189,9 +165,6 @@ class weightrate {
189
 
190
  }
191
 
192
-
193
-
194
-
195
  /**
196
  *
197
  *
@@ -246,11 +219,6 @@ class weightrate {
246
  }
247
  return $shipping;
248
  }
249
-
250
-
251
-
252
-
253
-
254
  }
255
 
256
 
9
  class weightrate {
10
  var $internal_name, $name;
11
 
 
12
  /**
13
  *
14
  *
21
  return true;
22
  }
23
 
 
 
 
 
24
  /**
25
  *
26
  *
30
  return $this->name;
31
  }
32
 
 
 
 
 
33
  /**
34
  *
35
  *
39
  return $this->internal_name;
40
  }
41
 
 
 
 
 
42
  /**
43
  *
44
  *
65
  $output.="<tr class='addlayer'><td colspan='2'>Layers: <a style='cursor:pointer;' id='addweightlayer' >Add Layer</a></td></tr>";
66
 
67
  return $output;
 
68
  }
69
 
 
 
 
 
70
  /**
71
  *
72
  *
107
  update_option('weight_rate_layers', $new_layer);
108
 
109
  }
 
110
  return true;
 
111
  }
112
 
 
 
 
 
113
  /**
114
  *
115
  *
165
 
166
  }
167
 
 
 
 
168
  /**
169
  *
170
  *
219
  }
220
  return $shipping;
221
  }
 
 
 
 
 
222
  }
223
 
224
 
wpsc-taxes/controllers/taxes_controller.class.php CHANGED
@@ -73,20 +73,18 @@ 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_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'] ) {
85
- $taxable_total += $wpsc_cart->calculate_total_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
73
  $returnable = array( 'total' => $total_tax );
74
  } else {
75
  //check if there are any rates setup for the base_country
76
+ //calculate subtotal for the items
77
+ $taxable_total = $wpsc_cart->calculate_subtotal();
78
+
79
+ //get the rate for the country and region if set
80
+ $tax_rate = $this->wpec_taxes->wpec_taxes_get_rate( $wpec_selected_country, $region );
81
+
82
+ //is the region configured to apply tax on shipping? if so add shipping price to the taxable total
83
+ if ( $tax_rate['shipping'] ) {
84
+ $taxable_total += $wpsc_cart->calculate_total_shipping();
85
+ }// if
86
+ //calculate tax
87
+ $returnable = array( 'total' => $this->wpec_taxes_calculate_tax( $taxable_total, $tax_rate['rate'] ), 'rate' => $tax_rate['rate'] );
 
 
88
  }// if
89
  }// if
90
  } //if
wpsc-theme/functions/wpsc-transaction_results_functions.php CHANGED
@@ -297,8 +297,6 @@ function transaction_results( $sessionid, $echo_to_screen = true, $transaction_i
297
  $report_user = __( 'Customer Details', 'wpsc' ) . "\n\r";
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 ) {
297
  $report_user = __( 'Customer Details', 'wpsc' ) . "\n\r";
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 ) {
wpsc-theme/functions/wpsc-user_log_functions.php CHANGED
@@ -37,7 +37,6 @@ function validate_form_data() {
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 ) {
@@ -224,7 +223,6 @@ function wpsc_display_form_fields() {
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>";
@@ -233,14 +231,12 @@ function wpsc_display_form_fields() {
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>";
@@ -401,7 +397,6 @@ function wpsc_user_details() {
401
  $billing_country = $country_data[0]['value'];
402
  $shipping_country = $country_data[0]['value'];
403
  }
404
- //exit('<pre>'.print_r($purchase,true).'</pre>');
405
  echo wpsc_currency_display( $purchase['totalprice'], array('display_as_html' => false) );
406
  $subtotal += $purchase['totalprice'];
407
  echo " </td>\n\r";
@@ -439,7 +434,6 @@ function wpsc_user_details() {
439
  $usps_id = get_option( 'usps_user_id' );
440
  if ( $usps_id != null ) {
441
  $XML1 = "<TrackFieldRequest USERID=\"$usps_id\"><TrackID ID=\"" . $purchase['track_id'] . "\"></TrackID></TrackFieldRequest>";
442
- //eecho cho "--->".$purchase['track_id'];
443
  $ch = curl_init();
444
  curl_setopt( $ch, CURLOPT_URL, "http://secure.shippingapis.com/ShippingAPITest.dll?" );
445
  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
@@ -447,7 +441,6 @@ function wpsc_user_details() {
447
  curl_setopt( $ch, CURLOPT_HEADER, 0 );
448
  $postdata = "API=TrackV2&XML=" . $XML1;
449
  curl_setopt( $ch, CURLOPT_POSTFIELDS, $postdata );
450
- // $result = curl_exec($ch);
451
 
452
  $parser = new xml2array;
453
  $parsed = $parser->parse( $result );
@@ -621,8 +614,6 @@ function wpsc_user_details() {
621
  echo " <tr><td>" . __( 'Email', 'wpsc' ) . ":</td><td>" . $purchase['email'] . "</td></tr>";
622
  }
623
 
624
- //if(get_option('payment_method') == 2)
625
- //{
626
  $gateway_name = '';
627
  foreach ( (array)$nzshpcrt_gateways as $gateway ) {
628
  if ( $purchase_log[0]['gateway'] != 'testmode' ) {
@@ -633,14 +624,13 @@ function wpsc_user_details() {
633
  $gateway_name = "Manual Payment";
634
  }
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
  }
642
  echo "</table>";
643
- } // */
644
  echo " </div>\n\r";
645
  echo " </div>\n\r";
646
  echo " </td>\n\r";
37
 
38
  $any_bad_inputs = false;
39
  $changes_saved = false;
 
40
  $_SESSION['collected_data'] = null;
41
 
42
  if ( $_POST['collected_data'] != null ) {
223
  $country_code = ($meta_data[$form_field['id']][0]);
224
  else
225
  $country_code = ($meta_data[$form_field['id']]);
 
226
  echo "<select name='collected_data[" . $form_field['id'] . "][0]' >" . nzshpcrt_country_list( $country_code ) . "</select>";
227
  if( isset($meta_data[$form_field['id']][1]) )
228
  echo "<br /><select name='collected_data[" . $form_field['id'] . "][1]'>" . nzshpcrt_region_list( $country_code, $meta_data[$form_field['id']][1] ) . "</select>";
231
 
232
  break;
233
 
 
234
  case "delivery_country":
235
 
236
  if (is_array($meta_data[$form_field['id']]))
237
  $country_code = ($meta_data[$form_field['id']][0]);
238
  else
239
  $country_code = ($meta_data[$form_field['id']]);
 
240
  echo "<select name='collected_data[" . $form_field['id'] . "][0]' >" . nzshpcrt_country_list( $country_code ) . "</select>";
241
  if( isset($meta_data[$form_field['id']][1]) )
242
  echo "<br /><select name='collected_data[" . $form_field['id'] . "][1]'>" . nzshpcrt_region_list( $country_code, $meta_data[$form_field['id']][1] ) . "</select>";
397
  $billing_country = $country_data[0]['value'];
398
  $shipping_country = $country_data[0]['value'];
399
  }
 
400
  echo wpsc_currency_display( $purchase['totalprice'], array('display_as_html' => false) );
401
  $subtotal += $purchase['totalprice'];
402
  echo " </td>\n\r";
434
  $usps_id = get_option( 'usps_user_id' );
435
  if ( $usps_id != null ) {
436
  $XML1 = "<TrackFieldRequest USERID=\"$usps_id\"><TrackID ID=\"" . $purchase['track_id'] . "\"></TrackID></TrackFieldRequest>";
 
437
  $ch = curl_init();
438
  curl_setopt( $ch, CURLOPT_URL, "http://secure.shippingapis.com/ShippingAPITest.dll?" );
439
  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
441
  curl_setopt( $ch, CURLOPT_HEADER, 0 );
442
  $postdata = "API=TrackV2&XML=" . $XML1;
443
  curl_setopt( $ch, CURLOPT_POSTFIELDS, $postdata );
 
444
 
445
  $parser = new xml2array;
446
  $parsed = $parser->parse( $result );
614
  echo " <tr><td>" . __( 'Email', 'wpsc' ) . ":</td><td>" . $purchase['email'] . "</td></tr>";
615
  }
616
 
 
 
617
  $gateway_name = '';
618
  foreach ( (array)$nzshpcrt_gateways as $gateway ) {
619
  if ( $purchase_log[0]['gateway'] != 'testmode' ) {
624
  $gateway_name = "Manual Payment";
625
  }
626
  }
 
627
  echo " <tr><td>" . __( 'Payment Method', 'wpsc' ) . ":</td><td>" . $gateway_name . "</td></tr>";
628
  echo " <tr><td>" . __( 'Purchase #', 'wpsc' ) . ":</td><td>" . $purchase['id'] . "</td></tr>";
629
  if ( $purchase['transactid'] != '' ) {
630
  echo " <tr><td>" . __( 'Transaction Id', 'wpsc' ) . ":</td><td>" . $purchase['transactid'] . "</td></tr>";
631
  }
632
  echo "</table>";
633
+ }
634
  echo " </div>\n\r";
635
  echo " </div>\n\r";
636
  echo " </td>\n\r";
wpsc-theme/wpsc-cart_widget.php CHANGED
@@ -1,6 +1,3 @@
1
- <?php
2
- //echo "<pre>".print_r($GLOBALS['wpsc_cart']->cart_items[0], true)."</pre>";
3
- ?>
4
  <?php if(isset($cart_messages) && count($cart_messages) > 0) { ?>
5
  <?php foreach((array)$cart_messages as $cart_message) { ?>
6
  <span class="cart_message"><?php echo $cart_message; ?></span>
 
 
 
1
  <?php if(isset($cart_messages) && count($cart_messages) > 0) { ?>
2
  <?php foreach((array)$cart_messages as $cart_message) { ?>
3
  <span class="cart_message"><?php echo $cart_message; ?></span>
wpsc-theme/wpsc-products_page.php CHANGED
@@ -224,7 +224,6 @@ global $wpsc_query, $wpdb, $wp_query;
224
  </div><!--close productcol-->
225
  <?php if(wpsc_product_on_special()) : ?><span class="sale"><?php _e('Sale', 'wpsc'); ?></span><?php endif; ?>
226
  </div><!--close default_product_display-->
227
- <?php //exit(); ?>
228
 
229
  <?php endwhile; ?>
230
  <?php /** end the product loop here */?>
@@ -233,7 +232,6 @@ global $wpsc_query, $wpdb, $wp_query;
233
  <?php endif ; ?>
234
  <?php do_action( 'wpsc_theme_footer' ); ?>
235
 
236
- <?php //exit('<pre>'.print_r($wpsc_query->a_page_url(),true).'</pre>'); ?>
237
  <?php if(wpsc_has_pages_bottom()) : ?>
238
  <div class="wpsc_page_numbers_bottom">
239
  <?php wpsc_pagination(); ?>
224
  </div><!--close productcol-->
225
  <?php if(wpsc_product_on_special()) : ?><span class="sale"><?php _e('Sale', 'wpsc'); ?></span><?php endif; ?>
226
  </div><!--close default_product_display-->
 
227
 
228
  <?php endwhile; ?>
229
  <?php /** end the product loop here */?>
232
  <?php endif ; ?>
233
  <?php do_action( 'wpsc_theme_footer' ); ?>
234
 
 
235
  <?php if(wpsc_has_pages_bottom()) : ?>
236
  <div class="wpsc_page_numbers_bottom">
237
  <?php wpsc_pagination(); ?>
wpsc-theme/wpsc-shopping_cart_page.php CHANGED
@@ -17,9 +17,6 @@ endif;
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>
@@ -80,7 +77,7 @@ endif;
80
  <?php endwhile; ?>
81
  <?php //this HTML displays coupons if there are any active coupons to use ?>
82
 
83
- <?php //echo "<pre>"; print_r($wpsc_cart); echo "</pre>"; echo "total cart weight: ".wpsc_cart_weight_total();
84
 
85
  if(wpsc_uses_coupons()): ?>
86
 
@@ -489,7 +486,7 @@ endif;
489
  <?php if(!wpsc_has_tnc()) : ?>
490
  <input type='hidden' value='yes' name='agree' />
491
  <?php endif; ?>
492
- <?php //exit('<pre>'.print_r($wpsc_gateway->wpsc_gateways[0]['name'], true).'</pre>');
493
  if(wpsc_is_noca_gateway()){
494
 
495
  }else{?>
17
  <tr class="header">
18
  <th colspan="2" ><?php _e('Product', 'wpsc'); ?></th>
19
  <th><?php _e('Quantity', 'wpsc'); ?></th>
 
 
 
20
  <th><?php _e('Price', 'wpsc'); ?></th>
21
  <th><?php _e('Total', 'wpsc'); ?></th>
22
  <th>&nbsp;</th>
77
  <?php endwhile; ?>
78
  <?php //this HTML displays coupons if there are any active coupons to use ?>
79
 
80
+ <?php
81
 
82
  if(wpsc_uses_coupons()): ?>
83
 
486
  <?php if(!wpsc_has_tnc()) : ?>
487
  <input type='hidden' value='yes' name='agree' />
488
  <?php endif; ?>
489
+ <?php
490
  if(wpsc_is_noca_gateway()){
491
 
492
  }else{?>
wpsc-theme/wpsc-single_product.php CHANGED
@@ -134,7 +134,6 @@
134
  <?php if(wpsc_has_multi_adding()): ?>
135
  <fieldset><legend><?php _e('Quantity', 'wpsc'); ?></legend>
136
  <div class="wpsc_quantity_update">
137
- <?php /*<label for="wpsc_quantity_update_<?php echo wpsc_the_product_id(); ?>"><?php _e('Quantity', 'wpsc'); ?>:</label>*/ ?>
138
  <input type="text" id="wpsc_quantity_update_<?php echo wpsc_the_product_id(); ?>" name="wpsc_quantity_update" size="2" value="1" />
139
  <input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
140
  <input type="hidden" name="wpsc_update_quantity" value="true" />
134
  <?php if(wpsc_has_multi_adding()): ?>
135
  <fieldset><legend><?php _e('Quantity', 'wpsc'); ?></legend>
136
  <div class="wpsc_quantity_update">
 
137
  <input type="text" id="wpsc_quantity_update_<?php echo wpsc_the_product_id(); ?>" name="wpsc_quantity_update" size="2" value="1" />
138
  <input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
139
  <input type="hidden" name="wpsc_update_quantity" value="true" />
wpsc-updates/database_template.php CHANGED
@@ -116,19 +116,6 @@ $wpsc_database_template[$table_name]['columns']['time'] = "bigint(20) unsigned N
116
  $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
117
  $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}product_rating";
118
 
119
-
120
- // code to create or update the {$wpdb->prefix}wpsc_product_variations table
121
- /*
122
- $table_name = WPSC_TABLE_PRODUCT_VARIATIONS;
123
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
124
- $wpsc_database_template[$table_name]['columns']['name'] = "varchar(128) NOT NULL DEFAULT '' ";
125
- $wpsc_database_template[$table_name]['columns']['variation_association'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
126
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
127
- $wpsc_database_template[$table_name]['indexes']['variation_association'] = " KEY `variation_association` ( `variation_association` ) ";
128
- $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}product_variations";
129
- */
130
-
131
-
132
  // code to create or update the {$wpdb->prefix}wpsc_purchase_logs table
133
  $table_name = WPSC_TABLE_PURCHASE_LOGS; /* !wpsc_purchase_logs */
134
  $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
@@ -166,18 +153,6 @@ $wpsc_database_template[$table_name]['indexes']['gateway'] = " KEY `gateway` ( `
166
  $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}purchase_logs";
167
 
168
 
169
- // code to create or update the {$wpdb->prefix}wpsc_purchase_statuses table
170
- //$table_name = WPSC_TABLE_PURCHASE_STATUSES; /* !wpsc_purchase_statuses */
171
- /*
172
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
173
- $wpsc_database_template[$table_name]['columns']['name'] = "varchar(128) NOT NULL DEFAULT '' ";
174
- $wpsc_database_template[$table_name]['columns']['active'] = "varchar(1) NOT NULL DEFAULT '0' ";
175
- $wpsc_database_template[$table_name]['columns']['colour'] = "varchar(6) NOT NULL DEFAULT '' ";
176
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
177
- $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}purchase_statuses";
178
- */
179
-
180
-
181
  // code to create or update the {$wpdb->prefix}wpsc_region_tax table
182
  $table_name = WPSC_TABLE_REGION_TAX; /* !wpsc_region_tax */
183
  $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
@@ -201,63 +176,6 @@ $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id
201
  $wpsc_database_template[$table_name]['indexes']['log_id'] = " KEY `log_id` ( `log_id`, `form_id` )";
202
  $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}submited_form_data";
203
 
204
-
205
- /*
206
- // code to create or update the {$wpdb->prefix}wpsc_variation_assoc table
207
- $table_name = WPSC_TABLE_VARIATION_ASSOC;
208
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
209
- $wpsc_database_template[$table_name]['columns']['type'] = "varchar(64) NOT NULL DEFAULT '' ";
210
- $wpsc_database_template[$table_name]['columns']['name'] = "varchar(128) NOT NULL DEFAULT '' ";
211
- $wpsc_database_template[$table_name]['columns']['associated_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
212
- $wpsc_database_template[$table_name]['columns']['variation_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
213
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
214
- $wpsc_database_template[$table_name]['indexes']['associated_id'] = " KEY `associated_id` ( `associated_id` )";
215
- $wpsc_database_template[$table_name]['indexes']['variation_id'] = " KEY `variation_id` ( `variation_id` )";
216
- $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}variation_associations";
217
- */
218
-
219
- /*
220
-
221
- // code to create or update the {$wpdb->prefix}wpsc_variation_properties table
222
- $table_name = WPSC_TABLE_VARIATION_PROPERTIES;
223
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
224
- $wpsc_database_template[$table_name]['columns']['product_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
225
- $wpsc_database_template[$table_name]['columns']['stock'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
226
- $wpsc_database_template[$table_name]['columns']['price'] = "decimal(11,2) NOT NULL DEFAULT '0' ";
227
- $wpsc_database_template[$table_name]['columns']['special_price'] = "decimal(11,2) NULL DEFAULT NULL ";
228
- $wpsc_database_template[$table_name]['columns']['sku'] = "text NULL";
229
- $wpsc_database_template[$table_name]['columns']['weight'] = "varchar(64) NULL DEFAULT '' ";
230
- $wpsc_database_template[$table_name]['columns']['weight_unit'] = "varchar(10) NOT NULL DEFAULT '' ";
231
- $wpsc_database_template[$table_name]['columns']['visibility'] = "varchar(1) NOT NULL DEFAULT '1' ";
232
- $wpsc_database_template[$table_name]['columns']['file'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
233
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
234
- $wpsc_database_template[$table_name]['indexes']['product_id'] = " KEY `product_id` ( `product_id` )";
235
- $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}variation_priceandstock";
236
-
237
-
238
- // code to create or update the {$wpdb->prefix}wpsc_variation_values table
239
- $table_name = WPSC_TABLE_VARIATION_VALUES;
240
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
241
- $wpsc_database_template[$table_name]['columns']['name'] = "varchar(128) NOT NULL DEFAULT '' ";
242
- $wpsc_database_template[$table_name]['columns']['variation_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
243
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
244
- $wpsc_database_template[$table_name]['indexes']['variation_id'] = " KEY `variation_id` ( `variation_id` )";
245
- $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}variation_values";
246
-
247
-
248
- // code to create or update the {$wpdb->prefix}wpsc_variation_values_assoc table
249
- $table_name = WPSC_TABLE_VARIATION_VALUES_ASSOC;
250
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
251
- $wpsc_database_template[$table_name]['columns']['product_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
252
- $wpsc_database_template[$table_name]['columns']['value_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
253
- $wpsc_database_template[$table_name]['columns']['visible'] = "varchar(1) NOT NULL DEFAULT '0' ";
254
- $wpsc_database_template[$table_name]['columns']['variation_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
255
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
256
- $wpsc_database_template[$table_name]['indexes']['product_id'] = " KEY `product_id` ( `product_id`, `value_id`, `variation_id` )";
257
- $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}variation_values_associations";
258
-
259
- */
260
-
261
  // code to create or update the {$wpdb->prefix}wpsc_coupon_codes table
262
  $table_name = WPSC_TABLE_COUPON_CODES;
263
  $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
@@ -277,64 +195,6 @@ $wpsc_database_template[$table_name]['indexes']['active'] = " KEY `active` ( `ac
277
  $wpsc_database_template[$table_name]['indexes']['start'] = " KEY `start` ( `start` )";
278
  $wpsc_database_template[$table_name]['indexes']['expiry'] = " KEY `expiry` ( `expiry` )";
279
 
280
-
281
- // // code to create or update the {$wpdb->prefix}wpsc_logged_subscriptions table
282
- // $table_name = WPSC_TABLE_LOGGED_SUBSCRIPTIONS;
283
- // $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
284
- // $wpsc_database_template[$table_name]['columns']['cart_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
285
- // $wpsc_database_template[$table_name]['columns']['user_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
286
- // $wpsc_database_template[$table_name]['columns']['length'] = "varchar(64) NOT NULL DEFAULT '0' ";
287
- // $wpsc_database_template[$table_name]['columns']['start_time'] = "varchar(64) NOT NULL DEFAULT '0' ";
288
- // $wpsc_database_template[$table_name]['columns']['active'] = "varchar(1) NOT NULL DEFAULT '0' ";
289
- // $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
290
- // $wpsc_database_template[$table_name]['indexes']['cart_id'] = " KEY `cart_id` ( `cart_id` )";
291
- // $wpsc_database_template[$table_name]['indexes']['user_id'] = " KEY `user_id` ( `user_id` )";
292
- // $wpsc_database_template[$table_name]['indexes']['start_time'] = " KEY `start_time` ( `start_time` )";
293
-
294
-
295
- // code to create or update the {$wpdb->prefix}wpsc_productmeta table
296
- /*
297
- $table_name = WPSC_TABLE_PRODUCTMETA;
298
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
299
- $wpsc_database_template[$table_name]['columns']['product_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
300
- $wpsc_database_template[$table_name]['columns']['meta_key'] = "varchar(255) NULL DEFAULT '' ";
301
- $wpsc_database_template[$table_name]['columns']['meta_value'] = "longtext NULL ";
302
- $wpsc_database_template[$table_name]['columns']['custom'] = "varchar(1) NOT NULL DEFAULT '0' ";
303
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
304
- $wpsc_database_template[$table_name]['indexes']['product_id'] = " KEY `product_id` ( `product_id` )";
305
- $wpsc_database_template[$table_name]['indexes']['meta_key'] = " KEY `meta_key` ( `meta_key` )";
306
- $wpsc_database_template[$table_name]['indexes']['custom'] = " KEY `custom` ( `custom` )";
307
- */
308
-
309
-
310
- // code to create or update the {$wpdb->prefix}wpsc_categorisation_groups table
311
- /*
312
- $table_name = WPSC_TABLE_CATEGORISATION_GROUPS;
313
- $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
314
- $wpsc_database_template[$table_name]['columns']['name'] = "varchar(255) NOT NULL DEFAULT '' ";
315
- $wpsc_database_template[$table_name]['columns']['description'] = "text NOT NULL ";
316
- $wpsc_database_template[$table_name]['columns']['active'] = "varchar(1) NOT NULL DEFAULT '1' ";
317
- $wpsc_database_template[$table_name]['columns']['default'] = "varchar(1) NOT NULL DEFAULT '0' ";
318
- $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
319
- $wpsc_database_template[$table_name]['indexes']['group_name'] = " KEY `group_name` ( `name` )";
320
- */
321
-
322
-
323
- // code to create or update the {$wpdb->prefix}wpsc_variation_combinations table
324
- /* $table_name = WPSC_TABLE_VARIATION_COMBINATIONS;
325
- $wpsc_database_template[$table_name]['columns']['product_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
326
- $wpsc_database_template[$table_name]['columns']['priceandstock_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
327
- $wpsc_database_template[$table_name]['columns']['value_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
328
- $wpsc_database_template[$table_name]['columns']['variation_id'] = "bigint(20) unsigned NOT NULL DEFAULT '0' ";
329
- $wpsc_database_template[$table_name]['columns']['all_variation_ids'] = "varchar(64) NOT NULL DEFAULT '' ";
330
- $wpsc_database_template[$table_name]['indexes']['product_id'] = " KEY `product_id` ( `product_id` )";
331
- $wpsc_database_template[$table_name]['indexes']['priceandstock_id'] = " KEY `priceandstock_id` ( `priceandstock_id` )";
332
- $wpsc_database_template[$table_name]['indexes']['value_id'] = " KEY `value_id` ( `value_id` )";
333
- $wpsc_database_template[$table_name]['indexes']['variation_id'] = " KEY `variation_id` ( `variation_id` )";
334
- $wpsc_database_template[$table_name]['indexes']['all_variation_ids'] = " KEY `all_variation_ids` ( `all_variation_ids` )";
335
- */
336
-
337
-
338
  // code to create or update the {$wpdb->prefix}wpsc_claimed_stock table
339
  $table_name = WPSC_TABLE_CLAIMED_STOCK; /* !wpsc_claimed_stock */
340
  $wpsc_database_template[$table_name]['columns']['product_id'] = "bigint(20) UNSIGNED NOT NULL DEFAULT '0' ";
116
  $wpsc_database_template[$table_name]['indexes']['PRIMARY'] = "PRIMARY KEY ( `id` )";
117
  $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}product_rating";
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  // code to create or update the {$wpdb->prefix}wpsc_purchase_logs table
120
  $table_name = WPSC_TABLE_PURCHASE_LOGS; /* !wpsc_purchase_logs */
121
  $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
153
  $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}purchase_logs";
154
 
155
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  // code to create or update the {$wpdb->prefix}wpsc_region_tax table
157
  $table_name = WPSC_TABLE_REGION_TAX; /* !wpsc_region_tax */
158
  $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
176
  $wpsc_database_template[$table_name]['indexes']['log_id'] = " KEY `log_id` ( `log_id`, `form_id` )";
177
  $wpsc_database_template[$table_name]['previous_names'] = "{$wpdb->prefix}submited_form_data";
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  // code to create or update the {$wpdb->prefix}wpsc_coupon_codes table
180
  $table_name = WPSC_TABLE_COUPON_CODES;
181
  $wpsc_database_template[$table_name]['columns']['id'] = "bigint(20) unsigned NOT NULL auto_increment";
195
  $wpsc_database_template[$table_name]['indexes']['start'] = " KEY `start` ( `start` )";
196
  $wpsc_database_template[$table_name]['indexes']['expiry'] = " KEY `expiry` ( `expiry` )";
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  // code to create or update the {$wpdb->prefix}wpsc_claimed_stock table
199
  $table_name = WPSC_TABLE_CLAIMED_STOCK; /* !wpsc_claimed_stock */
200
  $wpsc_database_template[$table_name]['columns']['product_id'] = "bigint(20) UNSIGNED NOT NULL DEFAULT '0' ";
wpsc-updates/updating_tasks.php CHANGED
@@ -7,8 +7,7 @@ if(get_option('wpsc_trackingid_subject') == ''){
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
 
13
  if($wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_REGION_TAX."` WHERE `code` NOT IN ('')") < 51) {
14
  $wpdb->query("UPDATE `".WPSC_TABLE_REGION_TAX."` SET `code` = 'AL' WHERE `name` IN ('Alabama') LIMIT 1 ;");
@@ -413,7 +412,7 @@ if($wpdb->get_var("SELECT `option_id` FROM `{$wpdb->options}` WHERE `option_name
413
  if((get_option('flat_rates') == null) || (count(get_option('flat_rates')) < 1)) {
414
  $local_shipping = get_option('base_local_shipping');
415
  $international_shipping = get_option('base_international_shipping');
416
- // echo $international_shipping;
417
  // Local Shipping Settings
418
  $shipping['local'] = $local_shipping;
419
 
@@ -431,19 +430,10 @@ if((get_option('flat_rates') == null) || (count(get_option('flat_rates')) < 1))
431
  $shipping['europe'] = $international_shipping;
432
  $shipping['africa'] = $international_shipping;
433
 
434
- //echo "<pre>".print_r($shipping,true)."</pre>";
435
-
436
  update_option('flat_rates',$shipping);
437
  }
438
 
439
  if(get_option('custom_shipping_options') == null ) {
440
  update_option('custom_shipping_options',array('flatrate'));
441
  }
442
- /*
443
- if($wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_STATUSES."`") != 5){
444
- $sql ="INSERT INTO `".WPSC_TABLE_PURCHASE_STATUSES."` (`name`,`active`) VALUES ('Failed Transaction','1')";
445
- //echo $sql;
446
- $wpdb->query($sql);
447
- }
448
- */
449
  ?>
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
 
12
  if($wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_REGION_TAX."` WHERE `code` NOT IN ('')") < 51) {
13
  $wpdb->query("UPDATE `".WPSC_TABLE_REGION_TAX."` SET `code` = 'AL' WHERE `name` IN ('Alabama') LIMIT 1 ;");
412
  if((get_option('flat_rates') == null) || (count(get_option('flat_rates')) < 1)) {
413
  $local_shipping = get_option('base_local_shipping');
414
  $international_shipping = get_option('base_international_shipping');
415
+
416
  // Local Shipping Settings
417
  $shipping['local'] = $local_shipping;
418
 
430
  $shipping['europe'] = $international_shipping;
431
  $shipping['africa'] = $international_shipping;
432
 
 
 
433
  update_option('flat_rates',$shipping);
434
  }
435
 
436
  if(get_option('custom_shipping_options') == null ) {
437
  update_option('custom_shipping_options',array('flatrate'));
438
  }
 
 
 
 
 
 
 
439
  ?>
wpsc-widgets/latest_product_widget.php CHANGED
@@ -72,8 +72,8 @@ class WP_Widget_Latest_Products extends WP_Widget {
72
  $instance = wp_parse_args( (array)$instance, array(
73
  'title' => '',
74
  'number' => 5,
75
- 'width' => 45,
76
- 'height' => 45
77
  ) );
78
 
79
  // Values
72
  $instance = wp_parse_args( (array)$instance, array(
73
  'title' => '',
74
  'number' => 5,
75
+ 'width' => 45,
76
+ 'height' => 45
77
  ) );
78
 
79
  // Values
wpsc-widgets/tagging_functions.php CHANGED
@@ -163,11 +163,6 @@ function get_product_tag_link( $tag_id ) {
163
 
164
  $file = get_option( 'home' ) . '/';
165
  $taglink = get_option( 'product_list_url' ) . '?product_tag=' . $slug;
166
- /*
167
- $taglink = get_option('product_list_url')."tag/%tag%";
168
- $taglink = str_replace('%tag%', $slug, $taglink);
169
- $taglink = user_trailingslashit($taglink, 'category');
170
- */
171
  }
172
 
173
  return apply_filters( 'product_tag_link', $taglink, $tag_id );
163
 
164
  $file = get_option( 'home' ) . '/';
165
  $taglink = get_option( 'product_list_url' ) . '?product_tag=' . $slug;
 
 
 
 
 
166
  }
167
 
168
  return apply_filters( 'product_tag_link', $taglink, $tag_id );