WP eCommerce - Version 3.8.7.6

Version Description

  • New: Default hook to filter sessionid for previously selected payment gateways.
  • Change: Stock notification emails are now sent to "purchase log email address" rather than admin address.
  • Fix: SQL injection vulnerability.
  • Fix: 3.7 -> 3.8 Database Upgrade Routine fails when importing variations sets with the same name.
  • Fix: Category link structure is not correct in pagination links with hierarchical category permalink.
  • Fix: Fix SQL error when using "?items_per_page=all" query.
  • Fix: Missing "Use as product thumbnail" on WordPress 3.3.
  • Fix: Products Page does not support custom page template - uses page.php instead.
  • Fix: Products page, category items per page is broken, relies on 'posts per page' setting in Settings -> reading.
  • Fix: Sticky post view broken due to deprecated query_string filter.
  • Fix: Sub-pages of Products Page aren't supported.
  • Fix: Total Quantity check for coupons.
  • Fix: Use ->add_help_tab() to support WP 3.3 admin screen API.
  • Fix: [wpsc_products] shortcode does not use 'Sort Product By' setting - it defaults to date-based ordering.
  • Fix: dashboard.css is loaded for WordPress > 3.3 (404 error).
Download this release

Release Info

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

Code changes from version 3.8.7.5 to 3.8.7.6

readme.txt CHANGED
@@ -4,13 +4,13 @@ Donate link: http://getshopped.org
4
  Tags: e-commerce, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
5
  Requires at least: 3.0
6
  Tested up to: 3.3.1
7
- Stable tag: 3.8.7.5
8
 
9
  WP e-Commerce is a free WordPress Shopping Cart Plugin that lets customers buy your products, services and digital downloads online.
10
 
11
  == Description ==
12
 
13
- We make setting up an ecommerce shop easy, and with over 1.3 Million downloads, we have unparalleled experience.
14
 
15
  Features:
16
 
@@ -23,7 +23,7 @@ Features:
23
  * Works out-of-the-box with WordPress MU (make sure you use sub domains with your MU setup)
24
 
25
  = 100% Customizable =
26
- * A designers dream – use your own HTML & CSS and have complete control over the look and feel of your. store
27
  * Easy to modify templates
28
 
29
  = Amazing Support =
@@ -156,6 +156,23 @@ After upgrading from earlier versions look for link "Update Store". This will up
156
 
157
 
158
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  = 3.8.7.5 =
160
  * Fix XSS vulnerability.
161
 
4
  Tags: e-commerce, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
5
  Requires at least: 3.0
6
  Tested up to: 3.3.1
7
+ Stable tag: 3.8.7.6
8
 
9
  WP e-Commerce is a free WordPress Shopping Cart Plugin that lets customers buy your products, services and digital downloads online.
10
 
11
  == Description ==
12
 
13
+ We make setting up an ecommerce shop easy, and with over 1.5 Million downloads, we have unparalleled experience.
14
 
15
  Features:
16
 
23
  * Works out-of-the-box with WordPress MU (make sure you use sub domains with your MU setup)
24
 
25
  = 100% Customizable =
26
+ * A designers dream – use your own HTML & CSS and have complete control over the look and feel of your store
27
  * Easy to modify templates
28
 
29
  = Amazing Support =
156
 
157
 
158
  == Changelog ==
159
+ = 3.8.7.6 =
160
+ * New: Default hook to filter sessionid for previously selected payment gateways.
161
+ * Change: Stock notification emails are now sent to "purchase log email address" rather than admin address.
162
+ * Fix: SQL injection vulnerability.
163
+ * Fix: 3.7 -> 3.8 Database Upgrade Routine fails when importing variations sets with the same name.
164
+ * Fix: Category link structure is not correct in pagination links with hierarchical category permalink.
165
+ * Fix: Fix SQL error when using "?items_per_page=all" query.
166
+ * Fix: Missing "Use as product thumbnail" on WordPress 3.3.
167
+ * Fix: Products Page does not support custom page template - uses page.php instead.
168
+ * Fix: Products page, category items per page is broken, relies on 'posts per page' setting in Settings -> reading.
169
+ * Fix: Sticky post view broken due to deprecated query_string filter.
170
+ * Fix: Sub-pages of Products Page aren't supported.
171
+ * Fix: Total Quantity check for coupons.
172
+ * Fix: Use ->add_help_tab() to support WP 3.3 admin screen API.
173
+ * Fix: [wpsc_products] shortcode does not use 'Sort Product By' setting - it defaults to date-based ordering.
174
+ * Fix: dashboard.css is loaded for WordPress > 3.3 (404 error).
175
+
176
  = 3.8.7.5 =
177
  * Fix XSS vulnerability.
178
 
wp-shopping-cart.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WP e-Commerce
4
  * Plugin URI: http://getshopped.org/
5
  * Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://getshopped.org" target="_blank">GetShopped.org</a> | <a href="http://getshopped.org/forums/" target="_blank">Support Forum</a> | <a href="http://docs.getshopped.org/" target="_blank">Documentation</a>
6
- * Version: 3.8.7.5
7
  * Author: Instinct Entertainment
8
  * Author URI: http://getshopped.org/
9
  **/
3
  * Plugin Name: WP e-Commerce
4
  * Plugin URI: http://getshopped.org/
5
  * Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://getshopped.org" target="_blank">GetShopped.org</a> | <a href="http://getshopped.org/forums/" target="_blank">Support Forum</a> | <a href="http://docs.getshopped.org/" target="_blank">Documentation</a>
6
+ * Version: 3.8.7.6
7
  * Author: Instinct Entertainment
8
  * Author URI: http://getshopped.org/
9
  **/
wpsc-admin/admin.php CHANGED
@@ -168,16 +168,6 @@ function wpsc_admin_pages() {
168
  if ( ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( WPSC_ADD_DEBUG_PAGE == true ) ) || ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( true == $_SESSION['wpsc_activate_debug_page'] ) ) )
169
  $page_hooks[] = add_options_page( __( 'Store Debug', 'wpsc' ), __( 'Store Debug', 'wpsc' ), 'administrator', 'wpsc-debug', 'wpsc_debug_page' );
170
 
171
-
172
- $header = '<p><strong>' . __( 'For More Information', 'wpsc' ) . '</strong></p>';
173
-
174
- add_contextual_help( 'toplevel_page_wpsc-sales-logs', $header . __( "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/sales/'>About the Sales Page</a>", 'wpsc' ) );
175
- add_contextual_help( 'toplevel_page_wpsc-edit-products', $header . __( "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/products'>About the Products Page</a>", 'wpsc' ) );
176
- add_contextual_help( 'products_page_wpsc-edit-groups', $header . __( "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/categories/'>About the Categories Page</a>", 'wpsc' ) );
177
- add_contextual_help( 'products_page_edit-tags', $header . __( "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/variations/'>About the Variations Page</a>", 'wpsc' ) );
178
- add_contextual_help( 'settings_page_wpsc-settings', $header . __( "<a target='_blank' href='http://getshopped.org/resources/docs/store-settings/general/'>General Settings</a><br /> <a target='_blank' href='http://getshopped.org/resources/docs/store-settings/checkout/'>Checkout Options</a> <br />", 'wpsc' ) );
179
- add_contextual_help( 'products_page_wpsc-edit-coupons', $header . __( "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/marketing'>Marketing Options</a><br />", 'wpsc' ) );
180
-
181
  $page_hooks = apply_filters( 'wpsc_additional_pages', $page_hooks, $products_page );
182
 
183
  do_action( 'wpsc_add_submenu' );
@@ -210,8 +200,117 @@ function wpsc_admin_pages() {
210
  update_option( 'wpsc_trackingid_message', __( "Track & Trace means you may track the progress of your parcel with our online parcel tracker, just login to our website and enter the following Tracking ID to view the status of your order.\n\nTracking ID: %trackid%\n", 'wpsc' ) );
211
  }
212
 
213
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  }
 
215
  function wpsc_product_log_rss_feed() {
216
  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'/>";
217
  }
@@ -279,7 +378,7 @@ function wpsc_admin_include_css_and_js_refac( $pagehook ) {
279
  if ( is_ssl ( ) )
280
  $siteurl = str_replace( "http://", "https://", $siteurl );
281
 
282
- if ( version_compare( '3.3', get_bloginfo( 'version' ), '<' ) )
283
  wp_admin_css( 'dashboard' );
284
 
285
  if($current_screen->id == 'dashboard_page_wpsc-sales-logs'){
168
  if ( ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( WPSC_ADD_DEBUG_PAGE == true ) ) || ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( true == $_SESSION['wpsc_activate_debug_page'] ) ) )
169
  $page_hooks[] = add_options_page( __( 'Store Debug', 'wpsc' ), __( 'Store Debug', 'wpsc' ), 'administrator', 'wpsc-debug', 'wpsc_debug_page' );
170
 
 
 
 
 
 
 
 
 
 
 
171
  $page_hooks = apply_filters( 'wpsc_additional_pages', $page_hooks, $products_page );
172
 
173
  do_action( 'wpsc_add_submenu' );
200
  update_option( 'wpsc_trackingid_message', __( "Track & Trace means you may track the progress of your parcel with our online parcel tracker, just login to our website and enter the following Tracking ID to view the status of your order.\n\nTracking ID: %trackid%\n", 'wpsc' ) );
201
  }
202
 
203
+ add_action( 'load-' . $edit_options_page, 'wpsc_load_settings_page', 1 );
204
+
205
+ // Help tabs
206
+ add_action( 'load-' . $edit_options_page , 'wpsc_add_help_tabs' );
207
+ add_action( 'load-' . $purchase_log_page, 'wpsc_add_help_tabs' );
208
+ add_action( 'load-' . $edit_coupons_page , 'wpsc_add_help_tabs' );
209
+ add_action( 'load-edit.php' , 'wpsc_add_help_tabs' );
210
+ add_action( 'load-post.php' , 'wpsc_add_help_tabs' );
211
+ add_action( 'load-post-new.php' , 'wpsc_add_help_tabs' );
212
+ add_action( 'load-edit-tags.php' , 'wpsc_add_help_tabs' );
213
+ }
214
+
215
+ /**
216
+ * This function adds contextual help to all WPEC screens.
217
+ * add_contextual_help() is supported as well as $screen->add_help_tab().
218
+ *
219
+ * @since 3.8.8
220
+ */
221
+ function wpsc_add_help_tabs() {
222
+ $tabs = array(
223
+ // Store Settings Page
224
+ 'settings_page_wpsc-settings' => array(
225
+ 'title' => _x( 'Store Settings', 'contextual help tab', 'wpsc' ),
226
+ 'links' => array(
227
+ 'category/configuring-your-store/store-settings/' => _x( 'Store Settings Overview' , 'contextual help link', 'wpsc' ),
228
+ 'category/configuring-your-store/payment-gateways/' => _x( 'Configuring Your Payment Gateways', 'contextual help link', 'wpsc' ),
229
+ 'category/configuring-your-store/shipping/' => _x( 'Configuring Your Shipping Modules', 'contextual help link', 'wpsc' ),
230
+ ),
231
+ ),
232
+
233
+ // Sales Log Page
234
+ 'dashboard_page_wpsc-purchase-logs' => array(
235
+ 'title' => _x( 'Sales Log', 'contextual help tab', 'wpsc' ),
236
+ 'links' => array(
237
+ 'documentation/sales/' => _x( 'Monitor and Manage Your Sales', 'contextual help link', 'wpsc' ),
238
+ ),
239
+ ),
240
+
241
+ // Main Products Listing Admin Page (edit.php?post_type=wpsc-product)
242
+ 'edit-wpsc-product' => array(
243
+ 'title' => _x( 'Product Catalog', 'contextual help tab', 'wpsc' ),
244
+ 'links' => array(
245
+ 'category/managing-your-store/' => _x( 'Managing Your Store', 'contextual help link', 'wpsc' ),
246
+ ),
247
+ ),
248
+
249
+ // Add and Edit Product Pages
250
+ 'wpsc-product' => array(
251
+ 'title' => _x( 'Add and Edit Product', 'contextual help tab', 'wpsc' ),
252
+ 'links' => array(
253
+ 'category/managing-your-store/' => _x( 'Managing Your Store', 'contextual help link', 'wpsc' ),
254
+ 'resource/video-adding-products/' => _x( 'Video: Adding Products', 'contextual help link', 'wpsc' ),
255
+ ),
256
+ ),
257
+
258
+ // Product Tags Page
259
+ 'edit-product_tag' => array(
260
+ 'title' => _x( 'Product Tags', 'contextual help tab', 'wpsc' ),
261
+ 'links' =>array(
262
+ 'resource/video-product-tags/' => _x( 'Video: Product Tags', 'contextual help link', 'wpsc' ),
263
+ ),
264
+ ),
265
+
266
+ // Product Category Page
267
+ 'edit-wpsc_product_category' => array(
268
+ 'title' => _x( 'Product Categories', 'contextual help tab', 'wpsc' ),
269
+ 'links' => array(
270
+ 'resource/video-creating-product-categories/' => _x( 'Video: Creating Product Categories', 'contextual help link', 'wpsc' ),
271
+ ),
272
+ ),
273
+
274
+ // Product Variations Page
275
+ 'edit-wpsc-variation' => array(
276
+ 'title' => _x( 'Product Variations', 'contextual help tab', 'wpsc' ),
277
+ 'links' => array(
278
+ 'category/managing-your-store/' => _x( 'Managing Your Store', 'contextual help link', 'wpsc' ),
279
+ ),
280
+ ),
281
+
282
+ // Coupon Page
283
+ 'wpsc-product_page_wpsc-edit-coupons' => array(
284
+ 'title' => _x( 'Coupons', 'contextual help tab', 'wpsc' ),
285
+ 'links' => array(
286
+ 'resource/video-creating-coupons/' => _x( 'Video: Creating Coupons', 'contextual help link', 'wpsc' ),
287
+ ),
288
+ ),
289
+ );
290
+
291
+ $screen = get_current_screen();
292
+ if ( array_key_exists( $screen->id, $tabs ) ) {
293
+ $tab = $tabs[$screen->id];
294
+ $content = '<p><strong>' . __( 'For More Information', 'wpsc' ) . '</strong></p>';
295
+ $links = array();
296
+ foreach( $tab['links'] as $link => $link_title ) {
297
+ $link = 'http://docs.getshopped.org/' . $link;
298
+ $links[] = '<a target="_blank" href="' . esc_url( $link ) . '">' . esc_html( $link_title ) . '</a>';
299
+ }
300
+ $content .= '<p>' . implode( '<br />', $links ) . '</p>';
301
+
302
+ if ( version_compare( get_bloginfo( 'version' ), '3.3', '<' ) ) {
303
+ add_contextual_help( $screen->id, $content );
304
+ } else {
305
+ $screen->add_help_tab( array(
306
+ 'id' => $screen->id . '_help',
307
+ 'title' => $tab['title'],
308
+ 'content' => $content,
309
+ ) );
310
+ }
311
+ }
312
  }
313
+
314
  function wpsc_product_log_rss_feed() {
315
  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'/>";
316
  }
378
  if ( is_ssl ( ) )
379
  $siteurl = str_replace( "http://", "https://", $siteurl );
380
 
381
+ if ( version_compare( get_bloginfo( 'version' ), '3.3', '<' ) )
382
  wp_admin_css( 'dashboard' );
383
 
384
  if($current_screen->id == 'dashboard_page_wpsc-sales-logs'){
wpsc-admin/includes/updating-functions.php CHANGED
@@ -316,12 +316,18 @@ function wpsc_convert_variation_sets() {
316
  $variation_set_id = wpsc_get_meta($variation_set->id, 'variation_set_id', 'wpsc_variation_set');
317
 
318
  if(!is_numeric($variation_set_id) || ( $variation_set_id < 1)) {
319
- $new_variation_set = wp_insert_term( $variation_set->name, 'wpsc-variation',array('parent' => 0));
320
- if(!is_wp_error($new_variation_set))
 
 
 
 
 
 
321
  $variation_set_id = $new_variation_set['term_id'];
322
  }
323
 
324
- if(is_numeric($variation_set_id)) {
325
  wpsc_update_meta($variation_set->id, 'variation_set_id', $variation_set_id, 'wpsc_variation_set');
326
 
327
 
316
  $variation_set_id = wpsc_get_meta($variation_set->id, 'variation_set_id', 'wpsc_variation_set');
317
 
318
  if(!is_numeric($variation_set_id) || ( $variation_set_id < 1)) {
319
+ $slug = sanitize_title( $variation_set->name );
320
+ $dummy_term = (object) array(
321
+ 'taxonomy' => 'wpsc-variation',
322
+ 'parent' => 0,
323
+ );
324
+ $slug = wp_unique_term_slug( $slug, $dummy_term );
325
+ $new_variation_set = wp_insert_term( $variation_set->name, 'wpsc-variation',array('parent' => 0, 'slug' => $slug ) );
326
+ if( ! is_wp_error( $new_variation_set ) )
327
  $variation_set_id = $new_variation_set['term_id'];
328
  }
329
 
330
+ if( ! empty( $variation_set_id ) && is_numeric($variation_set_id)) {
331
  wpsc_update_meta($variation_set->id, 'variation_set_id', $variation_set_id, 'wpsc_variation_set');
332
 
333
 
wpsc-core/wpsc-constants.php CHANGED
@@ -26,9 +26,9 @@ function wpsc_core_constants() {
26
  if(!defined('WPSC_URL'))
27
  define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
28
  // Define Plugin version
29
- define( 'WPSC_VERSION', '3.8.7.5' );
30
- define( 'WPSC_MINOR_VERSION', '485433' );
31
- define( 'WPSC_PRESENTABLE_VERSION', '3.8.7.5' );
32
 
33
  // Define Debug Variables for developers
34
  define( 'WPSC_DEBUG', false );
26
  if(!defined('WPSC_URL'))
27
  define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
28
  // Define Plugin version
29
+ define( 'WPSC_VERSION', '3.8.7.6' );
30
+ define( 'WPSC_MINOR_VERSION', '493073' );
31
+ define( 'WPSC_PRESENTABLE_VERSION', '3.8.7.6' );
32
 
33
  // Define Debug Variables for developers
34
  define( 'WPSC_DEBUG', false );
wpsc-core/wpsc-functions.php CHANGED
@@ -287,6 +287,7 @@ function wpsc_register_post_types() {
287
  // Products
288
  register_post_type( 'wpsc-product', array(
289
  'capability_type' => 'post',
 
290
  'hierarchical' => true,
291
  'exclude_from_search' => false,
292
  'public' => true,
@@ -462,30 +463,79 @@ function wpsc_serialize_shopping_cart() {
462
  }
463
  add_action( 'shutdown', 'wpsc_serialize_shopping_cart' );
464
 
465
- add_filter( 'query_string', 'wpsc_filter_query_string' );
466
 
467
  /**
468
- * Fixes for some inconsistencies about $wp_query when viewing WPEC pages
 
 
 
 
 
 
 
 
 
469
  *
470
  * @param string $q Query String
471
  */
472
- function wpsc_filter_query_string( $q ) {
473
  global $wpsc_page_titles;
474
- parse_str( $q, $args );
475
-
476
- // Make sure no 404 error is thrown for products-page's sub pages
477
- if ( ! empty( $args['wpsc_product_category'] ) && in_array( $args['wpsc_product_category'], $wpsc_page_titles ) ) {
478
- $q = "pagename={$wpsc_page_titles['products']}/{$args['wpsc_product_category']}";
 
 
 
 
 
 
 
479
  }
480
 
481
  // When product page is set to display all products or a category, and pagination is enabled, $wp_query is messed up
482
  // and is_home() is true. This fixes that.
483
- if ( ! is_admin() && isset( $args['post_type'] ) && $args['post_type'] == 'wpsc-product' && ! empty( $args['paged'] ) && empty( $args['wpsc_product_category'] ) ) {
484
  $default_category = get_option( 'wpsc_default_category' );
485
- if ( $default_category == 'all' || $default_category != 'list' )
486
- $q = "pagename={$wpsc_page_titles['products']}&page={$args['paged']}";
 
 
 
 
487
  }
488
- return $q;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
  }
490
 
491
  /**
@@ -502,17 +552,18 @@ function wpsc_filter_query_string( $q ) {
502
  * @param mixed $stuff
503
  * @return mixed
504
  */
505
- function wpsc_switch_the_query( $stuff ) {
506
  global $wp_query, $wpsc_query;
507
  $qv = $wpsc_query->query_vars;
508
- if ( ! empty( $qv['wpsc_product_category'] ) && ! empty( $qv['taxonomy'] ) && ! empty( $qv['term'] ) && ! is_single() )
509
- list( $wp_query, $wpsc_query ) = array( $wpsc_query, $wp_query );
510
- return $stuff;
 
 
511
  }
512
 
513
  // switch $wp_query and $wpsc_query at the beginning and the end of wp_nav_menu()
514
- add_filter( 'wp_nav_menu_args', 'wpsc_switch_the_query' );
515
- add_filter( 'wp_nav_menu', 'wpsc_switch_the_query' );
516
 
517
  /**
518
  * wpsc_start_the_query
@@ -562,6 +613,7 @@ function wpsc_start_the_query() {
562
  $wpsc_query_vars['nopaging'] = false;
563
 
564
  $wpsc_query_vars['posts_per_page'] = get_option('wpsc_products_per_page');
 
565
  $wpsc_query_vars['paged'] = get_query_var('paged');
566
  if(isset($wpsc_query_vars['paged']) && empty($wpsc_query_vars['paged'])){
567
  $wpsc_query_vars['paged'] = get_query_var('page');
@@ -569,32 +621,9 @@ function wpsc_start_the_query() {
569
  }
570
 
571
  }
572
- $orderby = get_option( 'wpsc_sort_by' );
573
- if( isset( $_GET['product_order'] ) )
574
- $orderby = 'title';
575
-
576
- switch ( $orderby ) {
577
-
578
- case "dragndrop":
579
- $wpsc_query_vars["orderby"] = 'menu_order';
580
- break;
581
-
582
- case "name":
583
- $wpsc_query_vars["orderby"] = 'title';
584
- break;
585
 
586
- //This only works in WP 3.0.
587
- case "price":
588
- add_filter( 'posts_join', 'wpsc_add_meta_table' );
589
- add_filter( 'posts_where', 'wpsc_add_meta_table_where' );
590
- $wpsc_query_vars["meta_key"] = '_wpsc_price';
591
- $wpsc_query_vars["orderby"] = 'meta_value_num';
592
- break;
593
-
594
- case "id":
595
- $wpsc_query_vars["orderby"] = 'ID';
596
- break;
597
- }
598
 
599
  add_filter( 'pre_get_posts', 'wpsc_generate_product_query', 11 );
600
 
@@ -612,7 +641,6 @@ function wpsc_start_the_query() {
612
  }
613
  $wpsc_query = new WP_Query( $wpsc_query_vars );
614
 
615
-
616
  }
617
  }
618
  }
@@ -637,6 +665,50 @@ function wpsc_start_the_query() {
637
  }
638
  add_action( 'template_redirect', 'wpsc_start_the_query', 8 );
639
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
640
  /**
641
  * add meta table where section for ordering by price
642
  *
@@ -877,13 +949,16 @@ function wpsc_generate_product_query( $query ) {
877
  if(1 == get_option('use_pagination')){
878
  $query->query_vars['posts_per_page'] = get_option('wpsc_products_per_page');
879
  if( isset( $_GET['items_per_page'] ) ) {
880
- if ( is_numeric( $_GET['items_per_page'] ) )
881
  $query->query_vars['posts_per_page'] = (int) $_GET['items_per_page'];
882
- elseif ( $_GET['items_per_page'] == 'all' )
883
  $query->query_vars['posts_per_page'] = -1;
 
 
884
  }
885
  } else {
886
- $query->query_vars['posts_per_page'] = '-1';
 
887
  }
888
  if ( $query->is_tax == true )
889
  new wpsc_products_by_category( $query );
287
  // Products
288
  register_post_type( 'wpsc-product', array(
289
  'capability_type' => 'post',
290
+ 'supports' => array( 'title', 'editor', 'thumbnail' ),
291
  'hierarchical' => true,
292
  'exclude_from_search' => false,
293
  'public' => true,
463
  }
464
  add_action( 'shutdown', 'wpsc_serialize_shopping_cart' );
465
 
466
+ add_filter( 'request', 'wpsc_filter_query_request' );
467
 
468
  /**
469
+ * Fixes for some inconsistencies about $wp_query when viewing WPEC pages.
470
+ *
471
+ * Causes the following URLs to work (with pagination enabled):
472
+ *
473
+ * /products-page/ (product listing)
474
+ * /products-page/car-audio/ (existing product category)
475
+ * /products-page/car-audio/page/2/ (existing product category, page 2)
476
+ * /products-page/page/2/ (product listing, page 2)
477
+ * /products-page/checkout/ (existing built-in sub page)
478
+ * /products-page/anotherpage/ (another sub page that may exist)
479
  *
480
  * @param string $q Query String
481
  */
482
+ function wpsc_filter_query_request( $args ) {
483
  global $wpsc_page_titles;
484
+ if ( is_admin() )
485
+ return $args;
486
+
487
+ // Make sure no 404 error is thrown for any sub pages of products-page
488
+ if ( ! empty( $args['wpsc_product_category'] ) && 'page' != $args['wpsc_product_category'] && ! term_exists($args['wpsc_product_category'], 'wpsc_product_category') ) {
489
+ // Probably requesting a page that is a sub page of products page
490
+ $pagename = "{$wpsc_page_titles['products']}/{$args['wpsc_product_category']}";
491
+ if ( isset($args['name']) ) {
492
+ $pagename .= "/{$args['name']}";
493
+ }
494
+ $args = array();
495
+ $args['pagename'] = $pagename;
496
  }
497
 
498
  // When product page is set to display all products or a category, and pagination is enabled, $wp_query is messed up
499
  // and is_home() is true. This fixes that.
500
+ if ( isset( $args['post_type'] ) && 'wpsc-product' == $args['post_type'] && ! empty( $args['wpsc-product'] ) && 'page' == $args['wpsc_product_category'] ) {
501
  $default_category = get_option( 'wpsc_default_category' );
502
+ if ( $default_category == 'all' || $default_category != 'list' ) {
503
+ $page = $args['wpsc-product'];
504
+ $args = array();
505
+ $args['pagename'] = "{$wpsc_page_titles['products']}";
506
+ $args['page'] = $page;
507
+ }
508
  }
509
+ return $args;
510
+ }
511
+
512
+ function _wpsc_menu_exists( $args ) {
513
+ $args = (object) $args;
514
+ // Get the nav menu based on the requested menu
515
+ $menu = wp_get_nav_menu_object( $args->menu );
516
+
517
+ // Get the nav menu based on the theme_location
518
+ if ( ! $menu && $args->theme_location && ( $locations = get_nav_menu_locations() ) && isset( $locations[ $args->theme_location ] ) )
519
+ $menu = wp_get_nav_menu_object( $locations[ $args->theme_location ] );
520
+
521
+ // get the first menu that has items if we still can't find a menu
522
+ if ( ! $menu && !$args->theme_location ) {
523
+ $menus = wp_get_nav_menus();
524
+ foreach ( $menus as $menu_maybe ) {
525
+ if ( $menu_items = wp_get_nav_menu_items($menu_maybe->term_id) ) {
526
+ $menu = $menu_maybe;
527
+ break;
528
+ }
529
+ }
530
+ }
531
+
532
+ return (bool) $menu;
533
+ }
534
+
535
+ function _wpsc_switch_the_query( $stuff = '' ) {
536
+ global $wp_query, $wpsc_query;
537
+ list( $wp_query, $wpsc_query ) = array( $wpsc_query, $wp_query );
538
+ return $stuff;
539
  }
540
 
541
  /**
552
  * @param mixed $stuff
553
  * @return mixed
554
  */
555
+ function wpsc_switch_the_query( $args ) {
556
  global $wp_query, $wpsc_query;
557
  $qv = $wpsc_query->query_vars;
558
+ if ( ! empty( $qv['wpsc_product_category'] ) && ! empty( $qv['taxonomy'] ) && ! empty( $qv['term'] ) && ! is_single() && _wpsc_menu_exists( $args ) ) {
559
+ _wpsc_switch_the_query();
560
+ add_filter( 'wp_nav_menu', '_wpsc_switch_the_query', 99 );
561
+ }
562
+ return $args;
563
  }
564
 
565
  // switch $wp_query and $wpsc_query at the beginning and the end of wp_nav_menu()
566
+ add_filter( 'wp_nav_menu_args', 'wpsc_switch_the_query', 99 );
 
567
 
568
  /**
569
  * wpsc_start_the_query
613
  $wpsc_query_vars['nopaging'] = false;
614
 
615
  $wpsc_query_vars['posts_per_page'] = get_option('wpsc_products_per_page');
616
+
617
  $wpsc_query_vars['paged'] = get_query_var('paged');
618
  if(isset($wpsc_query_vars['paged']) && empty($wpsc_query_vars['paged'])){
619
  $wpsc_query_vars['paged'] = get_query_var('page');
621
  }
622
 
623
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
624
 
625
+ $orderby = ( isset( $_GET['product_order'] ) ) ? 'title' : null;
626
+ $wpsc_query_vars = array_merge( $wpsc_query_vars, wpsc_product_sort_order_query_vars($orderby) );
 
 
 
 
 
 
 
 
 
 
627
 
628
  add_filter( 'pre_get_posts', 'wpsc_generate_product_query', 11 );
629
 
641
  }
642
  $wpsc_query = new WP_Query( $wpsc_query_vars );
643
 
 
644
  }
645
  }
646
  }
665
  }
666
  add_action( 'template_redirect', 'wpsc_start_the_query', 8 );
667
 
668
+
669
+ /**
670
+ * Obtain the necessary product sort order query variables based on the specified product sort order.
671
+ * If no sort order is specified, the sort order configured in Dashboard -> Settings -> Store -> Presentation -> 'Sort Product By' is used.
672
+ *
673
+ * @param string $orderby optional product sort order
674
+ * @return array Array of query variables
675
+ */
676
+ function wpsc_product_sort_order_query_vars( $orderby = null ) {
677
+ if ( is_null($orderby) )
678
+ $orderby = get_option( 'wpsc_sort_by' );
679
+
680
+ $query_vars = array();
681
+
682
+ switch ( $orderby ) {
683
+
684
+ case "dragndrop":
685
+ $query_vars["orderby"] = 'menu_order';
686
+ break;
687
+
688
+ case "name":
689
+ $query_vars["orderby"] = 'title';
690
+ break;
691
+
692
+ //This only works in WP 3.0.
693
+ case "price":
694
+ add_filter( 'posts_join', 'wpsc_add_meta_table' );
695
+ add_filter( 'posts_where', 'wpsc_add_meta_table_where' );
696
+ $query_vars["meta_key"] = '_wpsc_price';
697
+ $query_vars["orderby"] = 'meta_value_num';
698
+ break;
699
+
700
+ case "id":
701
+ $query_vars["orderby"] = 'ID';
702
+ break;
703
+ default:
704
+ // Allow other WordPress 'ordery' values as defined in http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
705
+ $query_vars["orderby"] = $orderby;
706
+ break;
707
+ }
708
+ return $query_vars;
709
+ }
710
+
711
+
712
  /**
713
  * add meta table where section for ordering by price
714
  *
949
  if(1 == get_option('use_pagination')){
950
  $query->query_vars['posts_per_page'] = get_option('wpsc_products_per_page');
951
  if( isset( $_GET['items_per_page'] ) ) {
952
+ if ( is_numeric( $_GET['items_per_page'] ) ) {
953
  $query->query_vars['posts_per_page'] = (int) $_GET['items_per_page'];
954
+ } elseif ( $_GET['items_per_page'] == 'all' ) {
955
  $query->query_vars['posts_per_page'] = -1;
956
+ $query->query_vars['nopaging'] = 1;
957
+ }
958
  }
959
  } else {
960
+ $query->query_vars['posts_per_page'] = -1;
961
+ $query->query_vars['nopaging'] = 1;
962
  }
963
  if ( $query->is_tax == true )
964
  new wpsc_products_by_category( $query );
wpsc-core/wpsc-installer.php CHANGED
@@ -34,13 +34,9 @@ function wpsc_install() {
34
 
35
  $table_name = $wpdb->prefix . "wpsc_product_list";
36
  $first_install = false;
37
- $result = mysql_list_tables( DB_NAME );
38
- $tables = array();
39
 
40
- while ( $row = mysql_fetch_row( $result ) )
41
- $tables[] = $row[0];
42
-
43
- if ( !in_array( $table_name, $tables ) ) {
44
  $first_install = true;
45
  add_option( 'wpsc_purchaselogs_fixed', true );
46
  }
34
 
35
  $table_name = $wpdb->prefix . "wpsc_product_list";
36
  $first_install = false;
 
 
37
 
38
+ if( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") !== $table_name ) {
39
+ // Table doesn't exist
 
 
40
  $first_install = true;
41
  add_option( 'wpsc_purchaselogs_fixed', true );
42
  }
wpsc-includes/coupons.class.php CHANGED
@@ -332,7 +332,7 @@ class wpsc_coupons {
332
  return false;
333
  }
334
  } else if ($c['property'] == 'total_quantity'){
335
- $total_quantity = $product_obj->quantity;
336
  switch($c['logic']) {
337
  case 'equal'://Checks if the quantity of products in the cart equals condition value
338
  if ($total_quantity == $c['value'])
332
  return false;
333
  }
334
  } else if ($c['property'] == 'total_quantity'){
335
+ $total_quantity = wpsc_cart_item_count();
336
  switch($c['logic']) {
337
  case 'equal'://Checks if the quantity of products in the cart equals condition value
338
  if ($total_quantity == $c['value'])
wpsc-includes/processing.functions.php CHANGED
@@ -130,7 +130,7 @@ function wpsc_decrement_claimed_stock($purchase_log_id) {
130
  update_product_meta($product->ID, 'stock', $remaining_stock);
131
  $product_meta = get_product_meta($product->ID,'product_metadata',true);
132
  if( $remaining_stock < 1 && $product_meta["unpublish_when_none_left"] == 1){
133
- wp_mail(get_option('admin_email'), sprintf(__('%s is out of stock', 'wpsc'), $product->post_title), sprintf(__('Remaining stock of %s is 0. Product was unpublished.', 'wpsc'), $product->post_title) );
134
  $wpdb->query("UPDATE `".$wpdb->posts."` SET `post_status` = 'draft' WHERE `ID` = '{$product->ID}'");
135
  }
136
  }
130
  update_product_meta($product->ID, 'stock', $remaining_stock);
131
  $product_meta = get_product_meta($product->ID,'product_metadata',true);
132
  if( $remaining_stock < 1 && $product_meta["unpublish_when_none_left"] == 1){
133
+ wp_mail(get_option('purch_log_email'), sprintf(__('%s is out of stock', 'wpsc'), $product->post_title), sprintf(__('Remaining stock of %s is 0. Product was unpublished.', 'wpsc'), $product->post_title) );
134
  $wpdb->query("UPDATE `".$wpdb->posts."` SET `post_status` = 'draft' WHERE `ID` = '{$product->ID}'");
135
  }
136
  }
wpsc-includes/product-template.php CHANGED
@@ -113,12 +113,12 @@ function wpsc_pagination($totalpages = '', $per_page = '', $current_page = '', $
113
 
114
  $separator = '=';
115
  }else{
116
- // This will need changing when we get product categories sorted
117
- if(isset($wp_query->query_vars['wpsc_product_category']))
118
- $page_link = trailingslashit(get_option('product_list_url')).$wp_query->query_vars['wpsc_product_category'].'/';
119
- else
120
- $page_link = trailingslashit(get_option('product_list_url'));
121
-
122
  $separator = 'page/';
123
  }
124
 
113
 
114
  $separator = '=';
115
  }else{
116
+ if ( isset( $wp_query->query_vars['wpsc_product_category'] ) ) {
117
+ $category_id = get_term_by( 'slug', $wp_query->query_vars['wpsc_product_category'], 'wpsc_product_category' );
118
+ $page_link = trailingslashit( get_term_link( $category_id, 'wpsc_product_category' ) );
119
+ } else {
120
+ $page_link = trailingslashit( get_option( 'product_list_url' ) );
121
+ }
122
  $separator = 'page/';
123
  }
124
 
wpsc-includes/shortcode.functions.php CHANGED
@@ -26,7 +26,7 @@ function wpsc_products_shorttag($atts) {
26
  'tag' => null,
27
  'price' => 0, //if price = 'sale' it shows all sale products
28
  'limit_of_items' => 0,
29
- 'sort_order' => null, // author,date,title,modified,parent,ID,rand,comment_count
30
  'order' => 'ASC', // ASC or DESC
31
  'number_per_page' => 0,
32
  'page' => 0,
26
  'tag' => null,
27
  'price' => 0, //if price = 'sale' it shows all sale products
28
  'limit_of_items' => 0,
29
+ 'sort_order' => null, // name,dragndrop,price,ID,author,date,title,modified,parent,rand,comment_count
30
  'order' => 'ASC', // ASC or DESC
31
  'number_per_page' => 0,
32
  'page' => 0,
wpsc-includes/theme.functions.php CHANGED
@@ -896,9 +896,10 @@ function wpsc_display_products_page( $query ) {
896
  if(!empty($query['category_url_name'])){
897
  $args['wpsc_product_category'] = $query['category_url_name'];
898
  }
899
- if(!empty($query['sort_order'])){
900
- $args['orderby'] = $query['sort_order'];
901
- }
 
902
  if(!empty($query['order'])){
903
  $args['order'] = $query['order'];
904
  }
@@ -1065,6 +1066,11 @@ function wpsc_all_products_on_page(){
1065
  array_push( $templates, "taxonomy-product_tag-{$tax_term}.php", 'taxonomy-product_tag.php' );
1066
  }
1067
 
 
 
 
 
 
1068
  array_push( $templates, 'page.php', 'single.php' );
1069
 
1070
  if ( is_single() )
896
  if(!empty($query['category_url_name'])){
897
  $args['wpsc_product_category'] = $query['category_url_name'];
898
  }
899
+ $orderby = ( !empty($query['sort_order']) ) ? $query['sort_order'] : null;
900
+
901
+ $args = array_merge( $args, wpsc_product_sort_order_query_vars($orderby) );
902
+
903
  if(!empty($query['order'])){
904
  $args['order'] = $query['order'];
905
  }
1066
  array_push( $templates, "taxonomy-product_tag-{$tax_term}.php", 'taxonomy-product_tag.php' );
1067
  }
1068
 
1069
+
1070
+ // Attempt to use the [productspage]'s custom page template as a higher priority than the normal page.php template
1071
+ if ( false !== $productspage_page_template = get_post_meta($products_page_id, '_wp_page_template', true) )
1072
+ array_push( $templates, $productspage_page_template );
1073
+
1074
  array_push( $templates, 'page.php', 'single.php' );
1075
 
1076
  if ( is_single() )
wpsc-theme/functions/wpsc-transaction_results_functions.php CHANGED
@@ -35,9 +35,9 @@ function wpsc_transaction_theme() {
35
  echo $_SESSION['payflow_message'];
36
  $_SESSION['payflow_message'] = '';
37
  }
38
-
39
  $dont_show_transaction_results = false;
40
-
41
  if ( isset( $_SESSION['wpsc_previous_selected_gateway'] ) ) {
42
  // Replaces the ugly if else for gateways
43
  switch($_SESSION['wpsc_previous_selected_gateway']){
@@ -48,7 +48,7 @@ function wpsc_transaction_theme() {
48
  if(isset($_SESSION['reshash']['PAYMENTINFO_0_TRANSACTIONTYPE']) && in_array( $_SESSION['reshash']['PAYMENTINFO_0_TRANSACTIONTYPE'], array( 'expresscheckout', 'cart' ) ) )
49
  $dont_show_transaction_results = false;
50
  else
51
- $dont_show_transaction_results = true;
52
  break;
53
  case 'dps':
54
  $sessionid = decrypt_dps_response();
@@ -57,30 +57,48 @@ function wpsc_transaction_theme() {
57
  case 'paystation':
58
  $ec = $_GET['ec'];
59
  $result= $_GET['em'];
60
-
61
  if($result == 'Transaction successful' && $ec == 0)
62
- $processed_id = '3';
63
-
64
  if($result == 'Insufficient Funds' && $ec == 5){
65
  $processed_id = '6';
66
-
67
  $payment_instructions = printf( __( 'Sorry your transaction was not accepted due to insufficient funds <br /><a href="%1$s">Click here to go back to checkout page</a>.', 'wpsc' ), get_option( "shopping_cart_url" ) );
68
  }
69
  if($processed_id){
70
  $wpdb->update( WPSC_TABLE_PURCHASE_LOGS, array('processed' => $processed_id),array('sessionid'=>$sessionid), array('%f') );
71
- }
72
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
  }
75
-
76
  if(!$dont_show_transaction_results ) {
77
  if ( !empty($sessionid) ){
78
- $cart_log_id = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1" );
79
  return transaction_results( $sessionid, true );
80
  }else
81
  printf( __( 'Sorry your transaction was not accepted.<br /><a href="%1$s">Click here to go back to checkout page</a>.', 'wpsc' ), get_option( "shopping_cart_url" ) );
82
  }
83
-
84
  }
85
 
86
 
@@ -95,13 +113,13 @@ function wpsc_transaction_theme() {
95
  */
96
  function transaction_results( $sessionid, $display_to_screen = true, $transaction_id = null ) {
97
  // Do we seriously need this many globals?
98
- global $wpdb, $wpsc_cart, $echo_to_screen, $purchase_log, $order_url;
99
  global $message_html, $cart, $errorcode,$wpsc_purchlog_statuses, $wpsc_gateways;
100
-
101
  $wpec_taxes_controller = new wpec_taxes_controller();
102
  $is_transaction = false;
103
  $errorcode = 0;
104
- $purchase_log = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1", ARRAY_A );
105
  $order_status = $purchase_log['processed'];
106
  $curgateway = $purchase_log['gateway'];
107
  //new variable to check whether function is being called from resen_email
@@ -109,20 +127,20 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
109
  $resend_email = true;
110
  else
111
  $resend_email = false;
112
-
113
  if( !is_bool( $display_to_screen ) )
114
  $display_to_screen = true;
115
-
116
  $echo_to_screen = $display_to_screen;
117
 
118
  if ( is_numeric( $sessionid ) ) {
119
  if ( $echo_to_screen )
120
  echo apply_filters( 'wpsc_pre_transaction_results', '' );
121
-
122
  // New code to check whether transaction is processed, true if accepted false if pending or incomplete
123
  $is_transaction = wpsc_check_purchase_processed($purchase_log['processed']);
124
  $message_html = $message = stripslashes( get_option( 'wpsc_email_receipt' ) );
125
-
126
  if( $is_transaction ){
127
  $message = __('The Transaction was successful', 'wpsc')."\r\n".$message;
128
  $message_html = __('The Transaction was successful', 'wpsc')."<br />".$message_html;
@@ -135,7 +153,7 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
135
  $shipping_country = $purchase_log['shipping_country'];
136
  } elseif ( !empty($country) ) {
137
  $country = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $purchase_log['id'] . " AND `form_id` = '" . get_option( 'country_form_field' ) . "' LIMIT 1" );
138
-
139
  $billing_country = $country;
140
  $shipping_country = $country;
141
  }
@@ -143,7 +161,7 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
143
  $email = wpsc_get_buyers_email($purchase_log['id']);
144
  $previous_download_ids = array( );
145
  $product_list = $product_list_html = $report_product_list = '';
146
-
147
  $cart = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = '{$purchase_log['id']}'" , ARRAY_A );
148
  if ( ($cart != null) && ($errorcode == 0) ) {
149
  $total_shipping = '';
@@ -172,7 +190,7 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
172
  );
173
 
174
  $download_file_posts = (array)get_posts( $argsdl );
175
-
176
  foreach((array)$download_file_posts as $single_file_post){
177
  if($single_file_post->ID == $single_download['fileid']){
178
  $current_Dl_product_file_post = $single_file_post;
@@ -180,12 +198,12 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
180
  }
181
  }
182
  $file_name = $current_Dl_product_file_post->post_title;
183
-
184
  if ( $single_download['uniqueid'] == null )
185
  $link[] = array( "url" => site_url( "?downloadid=" . $single_download['id'] ), "name" => $file_name );
186
  else
187
  $link[] = array( "url" => site_url( "?downloadid=" . $single_download['uniqueid'] ), "name" => $file_name );
188
-
189
  }
190
  } else {
191
  $order_status = $purchase_log['processed'];
@@ -228,7 +246,7 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
228
  $product_list .= $additional_content;
229
  $product_list_html .= $additional_content;
230
  } else {
231
-
232
  $product_list.= " - " . $row['quantity'] . " " . $row['name'] . " " . $message_price . "\n\r";
233
  if ( $shipping > 0 )
234
  $product_list .= sprintf(__( ' - Shipping: %s
@@ -266,7 +284,7 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
266
  $total_shipping += $purchase_log['base_shipping'];
267
 
268
  $total = $purchase_log['totalprice'];
269
-
270
  $total_price_email = '';
271
  $total_price_html = '';
272
  $total_tax_html = '';
@@ -280,8 +298,8 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
280
  ', 'wpsc' ), wpsc_currency_display( $total, array( 'display_as_html' => false ) ));
281
  if ( $purchase_log['discount_value'] > 0 ) {
282
  $discount_email = __( 'Discount', 'wpsc' ) . "\n\r: ";
283
- $discount_email .=$purchase_log['discount_data'] . ' : ' . wpsc_currency_display( $purchase_log['discount_value'], array( 'display_as_html' => false ) ) . "\n\r";
284
-
285
  $report.= $discount_email . "\n\r";
286
  $total_shipping_email .= $discount_email;
287
  $total_shipping_html.= __( 'Discount', 'wpsc' ) . ": " . wpsc_currency_display( $purchase_log['discount_value'] ) . "\n\r";
@@ -290,7 +308,7 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
290
  //only show total tax if tax is not included
291
  if($wpec_taxes_controller->wpec_taxes_isenabled() && !$wpec_taxes_controller->wpec_taxes_isincluded()){
292
  $total_tax_html .= __('Total Tax', 'wpsc').': '. wpsc_currency_display( $purchase_log['wpec_taxes_total'] )."\n\r";
293
- $total_tax .= __('Total Tax', 'wpsc').': '. wpsc_currency_display( $purchase_log['wpec_taxes_total'] , array( 'display_as_html' => false ) )."\n\r";
294
  }
295
  if ( wpsc_uses_shipping() )
296
  $total_shipping_html.= '<hr>' . sprintf(__( 'Total Shipping: %s
@@ -299,12 +317,12 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
299
  ', 'wpsc' ), wpsc_currency_display( $total ) );
300
  $report_id = sprintf(__("Purchase # %s
301
  ", 'wpsc'), $purchase_log['id']);
302
-
303
  if ( isset( $_GET['ti'] ) ) {
304
  $message.= "\n\r" . __( 'Your Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
305
  $message_html.= "\n\r" . __( 'Your Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
306
  $report.= "\n\r" . __( 'Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
307
- }
308
  $message = apply_filters( 'wpsc_transaction_result_message', $message );
309
  $message = str_replace( '%purchase_id%', $report_id, $message );
310
  $message = str_replace( '%product_list%', $product_list, $message );
@@ -313,7 +331,7 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
313
  $message = str_replace( '%total_price%', $total_price_email, $message );
314
  $message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
315
  $message = str_replace( '%find_us%', $purchase_log['find_us'], $message );
316
-
317
  $report = apply_filters( 'wpsc_transaction_result_report', $report );
318
  $report = str_replace( '%purchase_id%', $report_id, $report );
319
  $report = str_replace( '%product_list%', $report_product_list, $report );
@@ -322,7 +340,7 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
322
  $report = str_replace( '%total_price%', $total_price_email, $report );
323
  $report = str_replace( '%shop_name%', get_option( 'blogname' ), $report );
324
  $report = str_replace( '%find_us%', $purchase_log['find_us'], $report );
325
-
326
  $message_html = apply_filters( 'wpsc_transaction_result_message_html', $message_html );
327
  $message_html = str_replace( '%purchase_id%', $report_id, $message_html );
328
  $message_html = str_replace( '%product_list%', $product_list_html, $message_html );
@@ -338,13 +356,13 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
338
  $message = apply_filters('wpsc_email_message', $message, $report_id, $product_list, $total_tax, $total_shipping_email, $total_price_email);
339
 
340
  if ( !$is_transaction ) {
341
-
342
  $payment_instructions = strip_tags( stripslashes( get_option( 'payment_instructions' ) ) );
343
  if(!empty($payment_instructions))
344
- $payment_instructions .= "\n\r";
345
  $message = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . $message;
346
  $message_html = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . $message_html;
347
-
348
  // prevent email duplicates
349
  if ( ! get_transient( "{$sessionid}_pending_email_sent" ) ) {
350
  wp_mail( $email, __( 'Order Pending: Payment Required', 'wpsc' ), $message );
@@ -362,11 +380,11 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
362
  $report_user = __( 'Customer Details', 'wpsc' ) . "\n\r";
363
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = '" . $purchase_log['id'] . "'";
364
  $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
365
-
366
  if ( $form_data != null ) {
367
  foreach ( $form_data as $form_field ) {
368
  $form_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `id` = '" . $form_field['form_id'] . "' LIMIT 1", ARRAY_A );
369
-
370
  switch ( $form_data['type'] ) {
371
  case "country":
372
  $country_code = $form_field['value'];
@@ -378,9 +396,9 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
378
  break;
379
 
380
  case "delivery_country":
381
- $report_user .= $form_data['name'] . ": " . wpsc_get_country( $form_field['value'] ) . "\n";
382
  break;
383
-
384
  default:
385
  if ($form_data['name'] == 'State' && is_numeric($form_field['value'])){
386
  $report_user .= __( 'Delivery State', 'wpsc' ) . ": " . wpsc_get_state_by_id( $form_field['value'], 'name' ) . "\n";
35
  echo $_SESSION['payflow_message'];
36
  $_SESSION['payflow_message'] = '';
37
  }
38
+
39
  $dont_show_transaction_results = false;
40
+
41
  if ( isset( $_SESSION['wpsc_previous_selected_gateway'] ) ) {
42
  // Replaces the ugly if else for gateways
43
  switch($_SESSION['wpsc_previous_selected_gateway']){
48
  if(isset($_SESSION['reshash']['PAYMENTINFO_0_TRANSACTIONTYPE']) && in_array( $_SESSION['reshash']['PAYMENTINFO_0_TRANSACTIONTYPE'], array( 'expresscheckout', 'cart' ) ) )
49
  $dont_show_transaction_results = false;
50
  else
51
+ $dont_show_transaction_results = true;
52
  break;
53
  case 'dps':
54
  $sessionid = decrypt_dps_response();
57
  case 'paystation':
58
  $ec = $_GET['ec'];
59
  $result= $_GET['em'];
60
+
61
  if($result == 'Transaction successful' && $ec == 0)
62
+ $processed_id = '3';
63
+
64
  if($result == 'Insufficient Funds' && $ec == 5){
65
  $processed_id = '6';
66
+
67
  $payment_instructions = printf( __( 'Sorry your transaction was not accepted due to insufficient funds <br /><a href="%1$s">Click here to go back to checkout page</a>.', 'wpsc' ), get_option( "shopping_cart_url" ) );
68
  }
69
  if($processed_id){
70
  $wpdb->update( WPSC_TABLE_PURCHASE_LOGS, array('processed' => $processed_id),array('sessionid'=>$sessionid), array('%f') );
71
+ }
72
  break;
73
+ case 'wpsc_merchant_paymentexpress' :
74
+ // Payment Express sends back there own session id, which is temporarily stored in the Auth field
75
+ // so just swapping that over here
76
+ $query = $wpdb->prepare( "SELECT `sessionid` FROM `" .WPSC_TABLE_PURCHASE_LOGS. "` WHERE `authcode` =%s", $sessionid );
77
+ $result = $wpdb->get_var($query);
78
+ if($result != null){
79
+ // just in case they are using an older version old gold cart (pre 2.9.5)
80
+ $sessionid = $result;
81
+ $dont_show_transaction_results = true;
82
+ }
83
+ break;
84
+ case 'eway_hosted':
85
+ $sessionid = decrypt_eway_uk_response();
86
+ break;
87
+ //default filter for other payment gateways to use
88
+ default:
89
+ $sessionid = apply_filters('wpsc_previous_selected_gateway_' . $_SESSION['wpsc_previous_selected_gateway']);
90
+ break;
91
  }
92
  }
93
+
94
  if(!$dont_show_transaction_results ) {
95
  if ( !empty($sessionid) ){
96
+ $cart_log_id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= %s LIMIT 1", $sessionid ) );
97
  return transaction_results( $sessionid, true );
98
  }else
99
  printf( __( 'Sorry your transaction was not accepted.<br /><a href="%1$s">Click here to go back to checkout page</a>.', 'wpsc' ), get_option( "shopping_cart_url" ) );
100
  }
101
+
102
  }
103
 
104
 
113
  */
114
  function transaction_results( $sessionid, $display_to_screen = true, $transaction_id = null ) {
115
  // Do we seriously need this many globals?
116
+ global $wpdb, $wpsc_cart, $echo_to_screen, $purchase_log, $order_url;
117
  global $message_html, $cart, $errorcode,$wpsc_purchlog_statuses, $wpsc_gateways;
118
+
119
  $wpec_taxes_controller = new wpec_taxes_controller();
120
  $is_transaction = false;
121
  $errorcode = 0;
122
+ $purchase_log = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= %s LIMIT 1", $sessionid ), ARRAY_A );
123
  $order_status = $purchase_log['processed'];
124
  $curgateway = $purchase_log['gateway'];
125
  //new variable to check whether function is being called from resen_email
127
  $resend_email = true;
128
  else
129
  $resend_email = false;
130
+
131
  if( !is_bool( $display_to_screen ) )
132
  $display_to_screen = true;
133
+
134
  $echo_to_screen = $display_to_screen;
135
 
136
  if ( is_numeric( $sessionid ) ) {
137
  if ( $echo_to_screen )
138
  echo apply_filters( 'wpsc_pre_transaction_results', '' );
139
+
140
  // New code to check whether transaction is processed, true if accepted false if pending or incomplete
141
  $is_transaction = wpsc_check_purchase_processed($purchase_log['processed']);
142
  $message_html = $message = stripslashes( get_option( 'wpsc_email_receipt' ) );
143
+
144
  if( $is_transaction ){
145
  $message = __('The Transaction was successful', 'wpsc')."\r\n".$message;
146
  $message_html = __('The Transaction was successful', 'wpsc')."<br />".$message_html;
153
  $shipping_country = $purchase_log['shipping_country'];
154
  } elseif ( !empty($country) ) {
155
  $country = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $purchase_log['id'] . " AND `form_id` = '" . get_option( 'country_form_field' ) . "' LIMIT 1" );
156
+
157
  $billing_country = $country;
158
  $shipping_country = $country;
159
  }
161
  $email = wpsc_get_buyers_email($purchase_log['id']);
162
  $previous_download_ids = array( );
163
  $product_list = $product_list_html = $report_product_list = '';
164
+
165
  $cart = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = '{$purchase_log['id']}'" , ARRAY_A );
166
  if ( ($cart != null) && ($errorcode == 0) ) {
167
  $total_shipping = '';
190
  );
191
 
192
  $download_file_posts = (array)get_posts( $argsdl );
193
+
194
  foreach((array)$download_file_posts as $single_file_post){
195
  if($single_file_post->ID == $single_download['fileid']){
196
  $current_Dl_product_file_post = $single_file_post;
198
  }
199
  }
200
  $file_name = $current_Dl_product_file_post->post_title;
201
+
202
  if ( $single_download['uniqueid'] == null )
203
  $link[] = array( "url" => site_url( "?downloadid=" . $single_download['id'] ), "name" => $file_name );
204
  else
205
  $link[] = array( "url" => site_url( "?downloadid=" . $single_download['uniqueid'] ), "name" => $file_name );
206
+
207
  }
208
  } else {
209
  $order_status = $purchase_log['processed'];
246
  $product_list .= $additional_content;
247
  $product_list_html .= $additional_content;
248
  } else {
249
+
250
  $product_list.= " - " . $row['quantity'] . " " . $row['name'] . " " . $message_price . "\n\r";
251
  if ( $shipping > 0 )
252
  $product_list .= sprintf(__( ' - Shipping: %s
284
  $total_shipping += $purchase_log['base_shipping'];
285
 
286
  $total = $purchase_log['totalprice'];
287
+
288
  $total_price_email = '';
289
  $total_price_html = '';
290
  $total_tax_html = '';
298
  ', 'wpsc' ), wpsc_currency_display( $total, array( 'display_as_html' => false ) ));
299
  if ( $purchase_log['discount_value'] > 0 ) {
300
  $discount_email = __( 'Discount', 'wpsc' ) . "\n\r: ";
301
+ $discount_email .=$purchase_log['discount_data'] . ' : ' . wpsc_currency_display( $purchase_log['discount_value'], array( 'display_as_html' => false ) ) . "\n\r";
302
+
303
  $report.= $discount_email . "\n\r";
304
  $total_shipping_email .= $discount_email;
305
  $total_shipping_html.= __( 'Discount', 'wpsc' ) . ": " . wpsc_currency_display( $purchase_log['discount_value'] ) . "\n\r";
308
  //only show total tax if tax is not included
309
  if($wpec_taxes_controller->wpec_taxes_isenabled() && !$wpec_taxes_controller->wpec_taxes_isincluded()){
310
  $total_tax_html .= __('Total Tax', 'wpsc').': '. wpsc_currency_display( $purchase_log['wpec_taxes_total'] )."\n\r";
311
+ $total_tax .= __('Total Tax', 'wpsc').': '. wpsc_currency_display( $purchase_log['wpec_taxes_total'] , array( 'display_as_html' => false ) )."\n\r";
312
  }
313
  if ( wpsc_uses_shipping() )
314
  $total_shipping_html.= '<hr>' . sprintf(__( 'Total Shipping: %s
317
  ', 'wpsc' ), wpsc_currency_display( $total ) );
318
  $report_id = sprintf(__("Purchase # %s
319
  ", 'wpsc'), $purchase_log['id']);
320
+
321
  if ( isset( $_GET['ti'] ) ) {
322
  $message.= "\n\r" . __( 'Your Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
323
  $message_html.= "\n\r" . __( 'Your Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
324
  $report.= "\n\r" . __( 'Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
325
+ }
326
  $message = apply_filters( 'wpsc_transaction_result_message', $message );
327
  $message = str_replace( '%purchase_id%', $report_id, $message );
328
  $message = str_replace( '%product_list%', $product_list, $message );
331
  $message = str_replace( '%total_price%', $total_price_email, $message );
332
  $message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
333
  $message = str_replace( '%find_us%', $purchase_log['find_us'], $message );
334
+
335
  $report = apply_filters( 'wpsc_transaction_result_report', $report );
336
  $report = str_replace( '%purchase_id%', $report_id, $report );
337
  $report = str_replace( '%product_list%', $report_product_list, $report );
340
  $report = str_replace( '%total_price%', $total_price_email, $report );
341
  $report = str_replace( '%shop_name%', get_option( 'blogname' ), $report );
342
  $report = str_replace( '%find_us%', $purchase_log['find_us'], $report );
343
+
344
  $message_html = apply_filters( 'wpsc_transaction_result_message_html', $message_html );
345
  $message_html = str_replace( '%purchase_id%', $report_id, $message_html );
346
  $message_html = str_replace( '%product_list%', $product_list_html, $message_html );
356
  $message = apply_filters('wpsc_email_message', $message, $report_id, $product_list, $total_tax, $total_shipping_email, $total_price_email);
357
 
358
  if ( !$is_transaction ) {
359
+
360
  $payment_instructions = strip_tags( stripslashes( get_option( 'payment_instructions' ) ) );
361
  if(!empty($payment_instructions))
362
+ $payment_instructions .= "\n\r";
363
  $message = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . $message;
364
  $message_html = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . $message_html;
365
+
366
  // prevent email duplicates
367
  if ( ! get_transient( "{$sessionid}_pending_email_sent" ) ) {
368
  wp_mail( $email, __( 'Order Pending: Payment Required', 'wpsc' ), $message );
380
  $report_user = __( 'Customer Details', 'wpsc' ) . "\n\r";
381
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = '" . $purchase_log['id'] . "'";
382
  $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
383
+
384
  if ( $form_data != null ) {
385
  foreach ( $form_data as $form_field ) {
386
  $form_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `id` = '" . $form_field['form_id'] . "' LIMIT 1", ARRAY_A );
387
+
388
  switch ( $form_data['type'] ) {
389
  case "country":
390
  $country_code = $form_field['value'];
396
  break;
397
 
398
  case "delivery_country":
399
+ $report_user .= $form_data['name'] . ": " . wpsc_get_country( $form_field['value'] ) . "\n";
400
  break;
401
+
402
  default:
403
  if ($form_data['name'] == 'State' && is_numeric($form_field['value'])){
404
  $report_user .= __( 'Delivery State', 'wpsc' ) . ": " . wpsc_get_state_by_id( $form_field['value'], 'name' ) . "\n";