WP eCommerce - Version 3.9.1

Version Description

  • Fix: Disable 3.0 payment gateway API gateways. Will be re-enabled after more vigorous testing.
  • Fix: Check that $wpsc_cart->cart_items is an array, not an object.
  • Fix: Improve shipping method property checks in wpsc_cart class. See #1683.
  • Fix: Add asterix class to required fields for PayPal Pro 2.0.
  • Fix: Ensure taxable checkbox can be unchecked. 3.9 regression. See #1685.
  • Fix: Only show completed purchases in the user account area.
  • Fix: Use is_email(), rather than a faulty regex, for checkout email field validation.
  • Fix: More than a handful of faulty variables were referenced in wpsc_coupons.
  • Fix: Function wpsc_string_to_boolean was essentially non functional.
  • Fix: Send country and state through to PayPal only if they actually exist.
  • Fix: Broken theme-engine activation routine. Would always fail, running 1.0 engine.
Download this release

Release Info

Developer JustinSainton
Plugin Icon 128x128 WP eCommerce
Version 3.9.1
Comparing to
See all releases

Code changes from version 3.9 to 3.9.1

readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpecommerce.org
4
  Tags: e-commerce, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
5
  Requires at least: 3.9
6
  Tested up to: 4.1
7
- Stable tag: 3.9
8
 
9
  WP eCommerce is a free, powerful plugin that empowers you to sell anything online, quickly and easily.
10
 
@@ -36,6 +36,20 @@ After upgrading from earlier versions look for link "Update Store". This will up
36
 
37
  == Changelog ==
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  = 3.9 =
40
 
41
  * Fix: Eliminate most usage of number-based inputs in product UI.
4
  Tags: e-commerce, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
5
  Requires at least: 3.9
6
  Tested up to: 4.1
7
+ Stable tag: 3.9.1
8
 
9
  WP eCommerce is a free, powerful plugin that empowers you to sell anything online, quickly and easily.
10
 
36
 
37
  == Changelog ==
38
 
39
+ = 3.9.1 =
40
+
41
+ * Fix: Disable 3.0 payment gateway API gateways. Will be re-enabled after more vigorous testing.
42
+ * Fix: Check that $wpsc_cart->cart_items is an array, not an object.
43
+ * Fix: Improve shipping method property checks in wpsc_cart class. See [#1683](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1683).
44
+ * Fix: Add asterix class to required fields for PayPal Pro 2.0.
45
+ * Fix: Ensure taxable checkbox can be unchecked. 3.9 regression. See [#1685](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1685).
46
+ * Fix: Only show completed purchases in the user account area.
47
+ * Fix: Use is_email(), rather than a faulty regex, for checkout email field validation.
48
+ * Fix: More than a [handful of faulty variables](https://github.com/wp-e-commerce/WP-e-Commerce/commit/58f2d3ad9698ef496a27a701e5a926e412d55c05) were referenced in wpsc_coupons.
49
+ * Fix: Function `wpsc_string_to_boolean` was essentially non functional.
50
+ * Fix: Send country and state through to PayPal only if they actually exist.
51
+ * Fix: Broken theme-engine activation routine. Would always fail, running 1.0 engine.
52
+
53
  = 3.9 =
54
 
55
  * Fix: Eliminate most usage of number-based inputs in product UI.
wp-shopping-cart.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WP eCommerce
4
  * Plugin URI: http://wpecommerce.org/
5
  * Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://wpecommerce.org" target="_blank">WPeCommerce.org</a> | <a href="https://wordpress.org/support/plugin/wp-e-commerce/" target="_blank">Support Forum</a> | <a href="http://docs.wpecommerce.org/" target="_blank">Documentation</a>
6
- * Version: 3.9
7
  * Author: WP eCommerce
8
  * Author URI: http://wpecommerce.org/
9
  **/
3
  * Plugin Name: WP eCommerce
4
  * Plugin URI: http://wpecommerce.org/
5
  * Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://wpecommerce.org" target="_blank">WPeCommerce.org</a> | <a href="https://wordpress.org/support/plugin/wp-e-commerce/" target="_blank">Support Forum</a> | <a href="http://docs.wpecommerce.org/" target="_blank">Documentation</a>
6
+ * Version: 3.9.1
7
  * Author: WP eCommerce
8
  * Author URI: http://wpecommerce.org/
9
  **/
wpsc-admin/includes/display-items-functions.php CHANGED
@@ -472,6 +472,9 @@ function wpsc_product_taxes_forms() {
472
  }
473
 
474
  echo $output;
 
 
 
475
  }
476
 
477
  function wpsc_product_variation_forms() {
472
  }
473
 
474
  echo $output;
475
+
476
+ wp_nonce_field( 'update', 'wpsc_product_tax_nonce' );
477
+
478
  }
479
 
480
  function wpsc_product_variation_forms() {
wpsc-admin/includes/product-functions.php CHANGED
@@ -18,13 +18,10 @@ function wpsc_get_max_upload_size(){
18
  * @return nothing
19
  */
20
  function wpsc_admin_submit_product( $post_ID, $post ) {
21
- if ( ! is_admin() )
22
- return;
23
-
24
- global $wpdb;
25
 
26
- if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || $post->post_type != 'wpsc-product' )
27
  return;
 
28
 
29
  //Type-casting ( not so much sanitization, which would be good to do )
30
  $post_data = stripslashes_deep( $_POST );
@@ -36,6 +33,7 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
36
  $post_data['meta'] = (array) $_POST['meta'];
37
  }
38
 
 
39
  if ( isset( $post_data['meta']['_wpsc_price'] ) )
40
  $post_data['meta']['_wpsc_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_price'] );
41
 
@@ -138,10 +136,19 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
138
  $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = wpsc_string_to_float( $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] );
139
  }
140
 
141
- if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] ) )
142
- $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] = wpsc_string_to_float(
143
- $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount']
144
- );
 
 
 
 
 
 
 
 
 
145
 
146
  // External Link Options
147
  if ( isset( $_POST['wpsc_product_external_link_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_external_link_nonce'], 'update' ) ) {
@@ -188,6 +195,7 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
188
  'engraved' => 0,
189
  'can_have_uploaded_image' => 0
190
  ) );
 
191
  $post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], $default_meta_values );
192
 
193
  $post_data['files'] = $_FILES;
@@ -238,6 +246,7 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
238
  // and the custom meta
239
  wpsc_update_custom_meta($product_id, $post_data);
240
 
 
241
  // Update the alternative currencies
242
  if ( isset( $post_data['wpsc-update-currency-layers'] ) && wp_verify_nonce( $post_data['wpsc-update-currency-layers'], 'update-options' ) ) {
243
 
18
  * @return nothing
19
  */
20
  function wpsc_admin_submit_product( $post_ID, $post ) {
 
 
 
 
21
 
22
+ if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || $post->post_type != 'wpsc-product' ) {
23
  return;
24
+ }
25
 
26
  //Type-casting ( not so much sanitization, which would be good to do )
27
  $post_data = stripslashes_deep( $_POST );
33
  $post_data['meta'] = (array) $_POST['meta'];
34
  }
35
 
36
+
37
  if ( isset( $post_data['meta']['_wpsc_price'] ) )
38
  $post_data['meta']['_wpsc_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_price'] );
39
 
136
  $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = wpsc_string_to_float( $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] );
137
  }
138
 
139
+ // Update product taxes
140
+ if ( isset( $_POST['wpsc_product_tax_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_tax_nonce'], 'update' ) ) {
141
+
142
+ $post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], array(
143
+ 'wpec_taxes_taxable_amount' => '',
144
+ 'wpec_taxes_taxable' => ''
145
+ ) );
146
+ if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] ) ) {
147
+ $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] = wpsc_string_to_float($post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] );
148
+ }
149
+ $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable'] = $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable'];
150
+
151
+ }
152
 
153
  // External Link Options
154
  if ( isset( $_POST['wpsc_product_external_link_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_external_link_nonce'], 'update' ) ) {
195
  'engraved' => 0,
196
  'can_have_uploaded_image' => 0
197
  ) );
198
+
199
  $post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], $default_meta_values );
200
 
201
  $post_data['files'] = $_FILES;
246
  // and the custom meta
247
  wpsc_update_custom_meta($product_id, $post_data);
248
 
249
+
250
  // Update the alternative currencies
251
  if ( isset( $post_data['wpsc-update-currency-layers'] ) && wp_verify_nonce( $post_data['wpsc-update-currency-layers'], 'update-options' ) ) {
252
 
wpsc-components/merchant-core-v2/helpers/admin.php CHANGED
@@ -30,6 +30,7 @@ add_filter(
30
  * Filters deprecated gateways out of available gateways list.
31
  *
32
  * Only occurs if there is a 3.0 API replacement for the gateway and it is not currently active.
 
33
  *
34
  * @since 3.9.0
35
  *
@@ -39,9 +40,9 @@ add_filter(
39
  function wpsc_filter_deprecated_v2_gateways( $gateways ) {
40
 
41
  $deprecated_gateways = array(
42
- 'wpsc_merchant_paypal_express',
43
- 'wpsc_merchant_paypal_pro',
44
- 'wpsc_merchant_testmode'
45
  );
46
 
47
  // Loops through available gateways, checks if available gateway is both inactive and deprecated, and removes it.
30
  * Filters deprecated gateways out of available gateways list.
31
  *
32
  * Only occurs if there is a 3.0 API replacement for the gateway and it is not currently active.
33
+ * Note: Pro Hosted and Pro are not the same thing.
34
  *
35
  * @since 3.9.0
36
  *
40
  function wpsc_filter_deprecated_v2_gateways( $gateways ) {
41
 
42
  $deprecated_gateways = array(
43
+ 'manual',
44
+ 'paypal-pro',
45
+ 'paypal-express-checkout'
46
  );
47
 
48
  // Loops through available gateways, checks if available gateway is both inactive and deprecated, and removes it.
wpsc-components/merchant-core-v3/classes/payment-gateway.php CHANGED
@@ -222,8 +222,9 @@ final class WPSC_Payment_Gateways {
222
  }
223
 
224
  /**
225
- * Updates the payment gateway cache when it's changed. This function is hooked
226
- * into WordPress' wp_loaded action
 
227
  *
228
  * @access public
229
  * @static
222
  }
223
 
224
  /**
225
+ * Updates the payment gateway cache when it's changed.
226
+ *
227
+ * This function is hooked into WordPress' wp_loaded action
228
  *
229
  * @access public
230
  * @static
wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php CHANGED
@@ -552,7 +552,7 @@ class WPSC_Payment_Gateway_Paypal_Express_Checkout extends WPSC_Payment_Gateway
552
  </tr>
553
 
554
  <!-- Currency Conversion -->
555
- <?php if ( ! $this->is_currency_supported() ): ?>
556
  <tr>
557
  <td colspan="2">
558
  <h4><?php _e( 'Currency Conversion', 'wpsc' ); ?></h4>
552
  </tr>
553
 
554
  <!-- Currency Conversion -->
555
+ <?php if ( ! $this->is_currency_supported() ) : ?>
556
  <tr>
557
  <td colspan="2">
558
  <h4><?php _e( 'Currency Conversion', 'wpsc' ); ?></h4>
wpsc-components/merchant-core-v3/gateways/paypal-pro.php CHANGED
@@ -18,7 +18,7 @@ class WPSC_Payment_Gateway_Paypal_Pro extends WPSC_Payment_Gateway {
18
  public function __construct( $options ) {
19
  parent::__construct();
20
 
21
- $this->title = __( 'PayPal Pro 3.0', 'wpsc' );
22
 
23
  require_once( 'php-merchant/gateways/paypal-pro.php' );
24
 
18
  public function __construct( $options ) {
19
  parent::__construct();
20
 
21
+ $this->title = __( 'PayPal Pro Hosted', 'wpsc' );
22
 
23
  require_once( 'php-merchant/gateways/paypal-pro.php' );
24
 
wpsc-components/theme-engine-v1/helpers/ajax.php CHANGED
@@ -425,10 +425,12 @@ function wpsc_update_product_price() {
425
  }
426
 
427
  if ( $change_price ) {
428
- $old_price = wpsc_calculate_price( $product_id, $variations, false );
429
- $you_save_amount = wpsc_you_save( array( 'product_id' => $product_id, 'type' => 'amount', 'variations' => $variations ) );
430
  $you_save_percentage = wpsc_you_save( array( 'product_id' => $product_id, 'variations' => $variations ) );
 
431
  $price = wpsc_calculate_price( $product_id, $variations, true );
 
432
  $response += array(
433
  'old_price' => wpsc_currency_display( $old_price, array( 'display_as_html' => false ) ),
434
  'numeric_old_price' => (float) $old_price,
425
  }
426
 
427
  if ( $change_price ) {
428
+ $old_price = wpsc_calculate_price( $product_id, $variations, false );
429
+ $you_save_amount = wpsc_you_save( array( 'product_id' => $product_id, 'type' => 'amount', 'variations' => $variations ) );
430
  $you_save_percentage = wpsc_you_save( array( 'product_id' => $product_id, 'variations' => $variations ) );
431
+
432
  $price = wpsc_calculate_price( $product_id, $variations, true );
433
+
434
  $response += array(
435
  'old_price' => wpsc_currency_display( $old_price, array( 'display_as_html' => false ) ),
436
  'numeric_old_price' => (float) $old_price,
wpsc-components/theme-engine-v1/templates/functions/wpsc-user_log_functions.php CHANGED
@@ -166,7 +166,7 @@ function wpsc_has_purchases() {
166
  if ( $earliest_record[0]['date'] != null ) {
167
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `display_log` = '1';";
168
  $col_count = 4; //+ count( $form_data );
169
- $sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `user_ID` IN ('" . $user_ID . "') ORDER BY `date` DESC";
170
  $purchase_log = $wpdb->get_results( $sql, ARRAY_A );
171
 
172
  return true;
166
  if ( $earliest_record[0]['date'] != null ) {
167
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `display_log` = '1';";
168
  $col_count = 4; //+ count( $form_data );
169
+ $sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `user_ID` IN ('" . $user_ID . "') AND `processed` IN (3,4,5) ORDER BY `date` DESC";
170
  $purchase_log = $wpdb->get_results( $sql, ARRAY_A );
171
 
172
  return true;
wpsc-core/js/wp-e-commerce.js CHANGED
@@ -1,3 +1,4 @@
 
1
  ///////////////////////////////////////////////////////////////////////////////////////////////
2
  // This section is used to create the globals that were originally defined in the
3
  // dynamic-js file pre 3.8.14. Note that variables also also exist in the "wpsc_ajax" structure.
@@ -23,13 +24,13 @@
23
  *
24
  */
25
  if ( typeof wpsc_vars !== 'undefined' ) {
26
- var wpsc_ajax = wpsc_vars['wpsc_ajax'];
27
- var base_url = wpsc_vars['base_url'];
28
- var WPSC_URL = wpsc_vars['WPSC_URL'];
29
- var WPSC_IMAGE_URL = wpsc_vars['WPSC_IMAGE_URL'];
30
- var WPSC_IMAGE_URL = wpsc_vars['WPSC_IMAGE_URL'];
31
- var WPSC_CORE_IMAGES_URL = wpsc_vars['WPSC_CORE_IMAGES_URL'];
32
- var fileThickboxLoadingImage = wpsc_vars['fileThickboxLoadingImage'];
33
  }
34
  // end of variable definitions
35
  ///////////////////////////////////////////////////////////////////////////////////////////////
@@ -134,8 +135,8 @@ function wpsc_var_set( name, value ) {
134
  // if you are going to user it always check to be sure it is not false
135
  var wpsc_visitor_id = false;
136
 
137
- if ( ! ( document.cookie.indexOf("wpsc_customer_cookie") >= 0 ) ) {
138
- if ( ! ( document.cookie.indexOf("wpsc_attempted_validate") >= 0 ) ) {
139
  // create a cookie to signal that we have attempted validation. If we find the cookie is set
140
  // we don't re-attempt validation. This means will only try to validate once and not slow down
141
  // subsequent page views.
@@ -191,7 +192,9 @@ function wpsc_update_customer_data( meta_key, meta_value, response_callback ) {
191
  var ajax_data = {action: 'wpsc_customer_updated_data', meta_key : meta_key, meta_value : meta_value };
192
  wpsc_do_ajax_request( ajax_data, response_callback );
193
  } catch ( err ) {
194
- ; // we could handle the error here, or use it as a convenient place to set a breakpoint when debugging/testing
 
 
195
  }
196
 
197
  }
@@ -210,7 +213,9 @@ function wpsc_get_customer_data( response_callback ) {
210
  var ajax_data = {action: 'wpsc_get_customer_meta' };
211
  wpsc_do_ajax_request( ajax_data, response_callback );
212
  } catch ( err ) {
213
- ; // we could handle the error here, or use it as a convenient place to set a breakpoint when debugging/testing
 
 
214
  }
215
  }
216
 
@@ -251,7 +256,6 @@ function wpsc_update_customer_meta( response ) {
251
  // the value of other meta, specifically the billing or shipping country.
252
  // rather than enforce a field order in the response we will take care of it by doing
253
  // a second pass through the updates looking for only the region drop downs
254
- ;
255
  } else if ( jQuery(this).hasClass('wpsc-country-dropdown') ) {
256
  var current_value = jQuery( this ).val();
257
  if ( current_value != meta_value ) {
@@ -389,7 +393,7 @@ function wpsc_update_checkout_info( checkout_info ) {
389
  */
390
  function wpsc_meta_item_change_response( response ) {
391
 
392
- jQuery( ".wpsc-visitor-meta").off( "change", wpsc_meta_item_change );
393
 
394
  if ( response.hasOwnProperty('success') && response.success && response.hasOwnProperty('data') ) {
395
 
@@ -455,10 +459,10 @@ function wpsc_get_element_meta_key( element ) {
455
 
456
  var meta_key = element.attr( "data-wpsc-meta-key" );
457
 
458
- if ( meta_key == undefined ) {
459
  meta_key = element.attr( "title" );
460
 
461
- if ( meta_key == undefined ) {
462
  meta_key = element.attr( "id" );
463
  }
464
  }
@@ -677,7 +681,7 @@ function wpsc_update_regions_list_to_match_country( country_select ) {
677
  }
678
 
679
  function wpsc_string_to_boolean( string ) {
680
- return a.trim( string ) !== '';
681
  }
682
 
683
  /*
1
+ /* globals jQuery */
2
  ///////////////////////////////////////////////////////////////////////////////////////////////
3
  // This section is used to create the globals that were originally defined in the
4
  // dynamic-js file pre 3.8.14. Note that variables also also exist in the "wpsc_ajax" structure.
24
  *
25
  */
26
  if ( typeof wpsc_vars !== 'undefined' ) {
27
+ var wpsc_ajax = wpsc_vars.wpsc_ajax;
28
+ var base_url = wpsc_vars.base_url;
29
+ var WPSC_URL = wpsc_vars.WPSC_URL;
30
+ var WPSC_IMAGE_URL = wpsc_vars.WPSC_IMAGE_URL;
31
+ var WPSC_IMAGE_URL = wpsc_vars.WPSC_IMAGE_URL;
32
+ var WPSC_CORE_IMAGES_URL = wpsc_vars.WPSC_CORE_IMAGES_URL;
33
+ var fileThickboxLoadingImage = wpsc_vars.fileThickboxLoadingImage;
34
  }
35
  // end of variable definitions
36
  ///////////////////////////////////////////////////////////////////////////////////////////////
135
  // if you are going to user it always check to be sure it is not false
136
  var wpsc_visitor_id = false;
137
 
138
+ if ( document.cookie.indexOf("wpsc_customer_cookie") < 0 ) {
139
+ if ( document.cookie.indexOf("wpsc_attempted_validate") < 0 ) {
140
  // create a cookie to signal that we have attempted validation. If we find the cookie is set
141
  // we don't re-attempt validation. This means will only try to validate once and not slow down
142
  // subsequent page views.
192
  var ajax_data = {action: 'wpsc_customer_updated_data', meta_key : meta_key, meta_value : meta_value };
193
  wpsc_do_ajax_request( ajax_data, response_callback );
194
  } catch ( err ) {
195
+ if ( window.console && window.console.log ) {
196
+ console.log( err );
197
+ }
198
  }
199
 
200
  }
213
  var ajax_data = {action: 'wpsc_get_customer_meta' };
214
  wpsc_do_ajax_request( ajax_data, response_callback );
215
  } catch ( err ) {
216
+ if ( window.console && window.console.log ) {
217
+ console.log( err );
218
+ }
219
  }
220
  }
221
 
256
  // the value of other meta, specifically the billing or shipping country.
257
  // rather than enforce a field order in the response we will take care of it by doing
258
  // a second pass through the updates looking for only the region drop downs
 
259
  } else if ( jQuery(this).hasClass('wpsc-country-dropdown') ) {
260
  var current_value = jQuery( this ).val();
261
  if ( current_value != meta_value ) {
393
  */
394
  function wpsc_meta_item_change_response( response ) {
395
 
396
+ jQuery( ".wpsc-visitor-meta").off( 'change', wpsc_meta_item_change );
397
 
398
  if ( response.hasOwnProperty('success') && response.success && response.hasOwnProperty('data') ) {
399
 
459
 
460
  var meta_key = element.attr( "data-wpsc-meta-key" );
461
 
462
+ if ( meta_key === undefined ) {
463
  meta_key = element.attr( "title" );
464
 
465
+ if ( meta_key === undefined ) {
466
  meta_key = element.attr( "id" );
467
  }
468
  }
681
  }
682
 
683
  function wpsc_string_to_boolean( string ) {
684
+ return string.trim() !== '';
685
  }
686
 
687
  /*
wpsc-core/wpsc-constants.php CHANGED
@@ -53,15 +53,15 @@ function wpsc_core_constants() {
53
 
54
  // Define Plugin version
55
  if ( ! defined( 'WPSC_VERSION' ) ) {
56
- define( 'WPSC_VERSION' , '3.9' );
57
  }
58
 
59
  if ( ! defined( 'WPSC_MINOR_VERSION' ) ) {
60
- define( 'WPSC_MINOR_VERSION' , '7b172ca71a' );
61
  }
62
 
63
  if ( ! defined( 'WPSC_PRESENTABLE_VERSION' ) ) {
64
- define( 'WPSC_PRESENTABLE_VERSION', '3.9' );
65
  }
66
 
67
  // Define a salt to use when we hash, WPSC_SALT may be defined for us in our config file, so check first
53
 
54
  // Define Plugin version
55
  if ( ! defined( 'WPSC_VERSION' ) ) {
56
+ define( 'WPSC_VERSION' , '3.9.1' );
57
  }
58
 
59
  if ( ! defined( 'WPSC_MINOR_VERSION' ) ) {
60
+ define( 'WPSC_MINOR_VERSION' , '66518b9' );
61
  }
62
 
63
  if ( ! defined( 'WPSC_PRESENTABLE_VERSION' ) ) {
64
+ define( 'WPSC_PRESENTABLE_VERSION', '3.9.1' );
65
  }
66
 
67
  // Define a salt to use when we hash, WPSC_SALT may be defined for us in our config file, so check first
wpsc-includes/cart-item.class.php CHANGED
@@ -5,7 +5,6 @@
5
  * This is the class for WP eCommerce Cart Items,
6
  * The Cart Items class handles the same, but for cart items themselves.
7
  *
8
- *
9
  * @package wp-e-commerce
10
  * @since 3.8
11
  * @subpackage wpsc-cart-classes
@@ -96,7 +95,8 @@ class wpsc_cart_item {
96
  }
97
 
98
  /**
99
- * update or add cart item meta value
 
100
  * @access public
101
  * @param meta key name
102
  * @param meta key value
@@ -163,7 +163,7 @@ class wpsc_cart_item {
163
  *
164
  * @param integer the product ID
165
  * @param array parameters
166
- * @param objcet the cart object
167
  * @return boolean true on sucess, false on failure
168
  */
169
  function __construct( $product_id, $parameters, $cart ) {
5
  * This is the class for WP eCommerce Cart Items,
6
  * The Cart Items class handles the same, but for cart items themselves.
7
  *
 
8
  * @package wp-e-commerce
9
  * @since 3.8
10
  * @subpackage wpsc-cart-classes
95
  }
96
 
97
  /**
98
+ * Update or add cart item meta value
99
+ *
100
  * @access public
101
  * @param meta key name
102
  * @param meta key value
163
  *
164
  * @param integer the product ID
165
  * @param array parameters
166
+ * @param object the cart object
167
  * @return boolean true on sucess, false on failure
168
  */
169
  function __construct( $product_id, $parameters, $cart ) {
wpsc-includes/cart.class.php CHANGED
@@ -119,6 +119,8 @@ class wpsc_cart {
119
 
120
  public function update_location() {
121
 
 
 
122
  $delivery_country = wpsc_get_customer_meta( 'shippingcountry' );
123
  $billing_country = wpsc_get_customer_meta( 'billingcountry' );
124
  $delivery_region = wpsc_get_customer_meta( 'shippingregion' );
@@ -142,7 +144,7 @@ class wpsc_cart {
142
  public function wpsc_refresh_cart_items() {
143
  global $wpsc_cart;
144
 
145
- if ( is_object( $wpsc_cart ) && is_object( $wpsc_cart->cart_items ) ) {
146
  foreach ( $wpsc_cart->cart_items as $cart_item ) {
147
  $cart_item->refresh_item();
148
  }
@@ -429,16 +431,18 @@ class wpsc_cart {
429
  function get_shipping_option() {
430
  global $wpdb, $wpsc_shipping_modules;
431
 
432
- if ( ( count( $this->shipping_quotes ) < 1 ) && is_callable( array( $wpsc_shipping_modules[$this->selected_shipping_method], 'getQuote' ) ) ) {
 
 
433
  $this->shipping_quotes = $wpsc_shipping_modules[$this->selected_shipping_method]->getQuote();
434
  }
435
 
436
  if ( ! isset( $wpsc_shipping_modules[$this->selected_shipping_method] ) ) {
437
- $wpsc_shipping_modules[$this->selected_shipping_method] = '';
438
  }
439
 
440
  if ( count( $this->shipping_quotes ) < 1 ) {
441
- $this->selected_shipping_option = '';
442
  }
443
 
444
  // if the current shipping option is not valid, go back to no shipping option
@@ -693,7 +697,8 @@ class wpsc_cart {
693
  *
694
  * @param integer a product ID key
695
  * @param array variations on the product
696
- * @return boolean true on sucess, false on failure
 
697
  */
698
  function get_remaining_quantity( $product_id, $variations = array(), $quantity = 1 ) {
699
  return wpsc_get_remaining_quantity( $product_id, $variations, $quantity );
@@ -1188,7 +1193,7 @@ class wpsc_cart {
1188
  function rewind_shipping_methods() {
1189
  $this->current_shipping_method = - 1;
1190
  if ( $this->shipping_method_count > 0 ) {
1191
- $this->shipping_method = $this->shipping_methods [0];
1192
  }
1193
  }
1194
 
@@ -1202,8 +1207,8 @@ class wpsc_cart {
1202
  if ( $this->shipping_method == null ) {
1203
  $this->get_shipping_method();
1204
  }
1205
- if ( isset( $wpsc_shipping_modules [$this->shipping_method] ) && is_callable( array( $wpsc_shipping_modules [$this->shipping_method], 'getQuote' ) ) ) {
1206
- $unprocessed_shipping_quotes = $wpsc_shipping_modules [$this->shipping_method]->getQuote();
1207
  }
1208
  $num = 0;
1209
  if ( ! empty( $unprocessed_shipping_quotes ) ) {
119
 
120
  public function update_location() {
121
 
122
+ $this->clear_cache();
123
+
124
  $delivery_country = wpsc_get_customer_meta( 'shippingcountry' );
125
  $billing_country = wpsc_get_customer_meta( 'billingcountry' );
126
  $delivery_region = wpsc_get_customer_meta( 'shippingregion' );
144
  public function wpsc_refresh_cart_items() {
145
  global $wpsc_cart;
146
 
147
+ if ( is_object( $wpsc_cart ) && is_array( $wpsc_cart->cart_items ) ) {
148
  foreach ( $wpsc_cart->cart_items as $cart_item ) {
149
  $cart_item->refresh_item();
150
  }
431
  function get_shipping_option() {
432
  global $wpdb, $wpsc_shipping_modules;
433
 
434
+ if ( ( count( $this->shipping_quotes ) < 1 ) &&
435
+ isset( $wpsc_shipping_modules[$this->selected_shipping_method] ) &&
436
+ is_callable( array( $wpsc_shipping_modules[$this->selected_shipping_method], 'getQuote' ) ) ) {
437
  $this->shipping_quotes = $wpsc_shipping_modules[$this->selected_shipping_method]->getQuote();
438
  }
439
 
440
  if ( ! isset( $wpsc_shipping_modules[$this->selected_shipping_method] ) ) {
441
+ $this->selected_shipping_option = null;
442
  }
443
 
444
  if ( count( $this->shipping_quotes ) < 1 ) {
445
+ $this->selected_shipping_option = null;
446
  }
447
 
448
  // if the current shipping option is not valid, go back to no shipping option
697
  *
698
  * @param integer a product ID key
699
  * @param array variations on the product
700
+ *
701
+ * @return int Number of product remaining.
702
  */
703
  function get_remaining_quantity( $product_id, $variations = array(), $quantity = 1 ) {
704
  return wpsc_get_remaining_quantity( $product_id, $variations, $quantity );
1193
  function rewind_shipping_methods() {
1194
  $this->current_shipping_method = - 1;
1195
  if ( $this->shipping_method_count > 0 ) {
1196
+ $this->shipping_method = $this->shipping_methods[0];
1197
  }
1198
  }
1199
 
1207
  if ( $this->shipping_method == null ) {
1208
  $this->get_shipping_method();
1209
  }
1210
+ if ( isset( $wpsc_shipping_modules[$this->shipping_method] ) && is_callable( array( $wpsc_shipping_modules [$this->shipping_method], 'getQuote' ) ) ) {
1211
+ $unprocessed_shipping_quotes = $wpsc_shipping_modules[$this->shipping_method]->getQuote();
1212
  }
1213
  $num = 0;
1214
  if ( ! empty( $unprocessed_shipping_quotes ) ) {
wpsc-includes/checkout.class.php CHANGED
@@ -493,7 +493,7 @@ class wpsc_checkout {
493
  switch ( $form_data->type ) {
494
  case 'email':
495
 
496
- if ( ! preg_match( '/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-.]+\.[a-zA-Z]{2,5}$/', $value ) ) {
497
  $any_bad_inputs = true;
498
  $bad_input = true;
499
  }
@@ -534,9 +534,9 @@ class wpsc_checkout {
534
  }
535
  }
536
 
537
- wpsc_update_customer_meta( 'checkout_error_messages' , $wpsc_checkout_error_messages );
538
- wpsc_update_customer_meta( 'gateway_error_messages' , $wpsc_gateway_error_messages );
539
- wpsc_update_customer_meta( 'registration_error_messages' , $wpsc_registration_error_messages );
540
 
541
  $filtered_checkout_details = apply_filters( 'wpsc_update_customer_checkout_details', $wpsc_customer_checkout_details );
542
 
493
  switch ( $form_data->type ) {
494
  case 'email':
495
 
496
+ if ( ! is_email( $value ) ) {
497
  $any_bad_inputs = true;
498
  $bad_input = true;
499
  }
534
  }
535
  }
536
 
537
+ wpsc_update_customer_meta( 'checkout_error_messages' , $wpsc_checkout_error_messages );
538
+ wpsc_update_customer_meta( 'gateway_error_messages' , $wpsc_gateway_error_messages );
539
+ wpsc_update_customer_meta( 'registration_error_messages', $wpsc_registration_error_messages );
540
 
541
  $filtered_checkout_details = apply_filters( 'wpsc_update_customer_checkout_details', $wpsc_customer_checkout_details );
542
 
wpsc-includes/coupons.class.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
- /**
3
  * The Coupons Class
4
- *
5
- * Holds the main coupon class amd other important coupon functions
6
- *
7
  * @package wp-e-commerce
8
- */
9
 
10
  /**
11
  * uses coupons function, no parameters
@@ -37,10 +37,7 @@ function wpsc_coupons_error(){
37
  /**
38
  * Coupons class.
39
  *
40
- * Conditional coupons use an 'ALL' logic. Now admins can achieve an 'ANY' logic by adding multiple coupons.
41
- *
42
- * TODO: Implement 'ANY' logic of conditional coupons.
43
- *
44
  * @package wp-e-commerce
45
  * @since 3.7
46
  */
@@ -118,7 +115,7 @@ class wpsc_coupons {
118
  *
119
  * Checks if the current coupon is valid to use (Expiry date, Active, Used).
120
  *
121
- * @return bool True if coupon is not expried, used and still active, False otherwise.
122
  */
123
  function validate_coupon() {
124
 
@@ -210,7 +207,7 @@ class wpsc_coupons {
210
  break;
211
 
212
  case 'ends'://Checks if the product name ends with condition value
213
- return preg_match( "/" . preg_quote( $c['value'], '/' ) . "$/", $product_data->post_title );
214
  break;
215
  }
216
 
@@ -228,6 +225,7 @@ class wpsc_coupons {
228
  */
229
  public function _callback_condition_item_quantity( $condition, $cart_item ) {
230
  $value = (int) $condition['value'];
 
231
  switch( $condition['logic'] ) {
232
  case 'equal': //Checks if the quantity of a product in the cart equals condition value
233
  return $cart_item->quantity == $value;
@@ -254,7 +252,7 @@ class wpsc_coupons {
254
  break;
255
 
256
  case 'ends'://Checks if the product name ends with condition value
257
- return preg_match( "/" . $value . "$/",$product_obj->quantity );
258
  break;
259
  }
260
 
@@ -271,8 +269,9 @@ class wpsc_coupons {
271
  * @return boolean
272
  */
273
  public function _callback_condition_total_quantity( $condition, $cart_item ) {
 
274
  $total_quantity = wpsc_cart_item_count();
275
- $value = (int) $condition['value'];
276
 
277
  switch( $condition['logic'] ) {
278
  case 'equal'://Checks if the quantity of products in the cart equals condition value
@@ -485,7 +484,7 @@ class wpsc_coupons {
485
  // if "Apply on all products" is not checked and the coupon is percentage, the discount
486
  // amount should be based on the eligible cart item with lowest unit price
487
  if ( $this->is_percentage() ) {
488
- $field = apply_filters( 'wpsc_coupon_select_item_field' , 'unit_price' );
489
  $item = array_shift( $items );
490
  return $item->$field * $this->value / 100;
491
  }
@@ -599,48 +598,52 @@ class wpsc_coupons {
599
  * @return float
600
  */
601
  public function calculate_discount() {
602
- global $wpdb, $wpsc_cart;
603
 
604
  $wpsc_cart->clear_cache();
605
 
606
- if ( $this->has_conditions() )
607
  return $this->calculate_discount_conditions();
 
 
 
608
 
609
- return $this->calculate_discount_without_conditions();
610
  }
611
 
612
  /**
613
  * Comparing logic with the product information
614
  *
615
- * Checks if the product matchs the logic
 
 
616
  *
617
  * @return bool True if all conditions are matched, False otherwise.
618
  */
619
- function compare_logic($c, $product_obj) {
620
  global $wpdb;
621
 
622
- if ( 'item_name' == $c['property'] ) {
623
- $product_data = $wpdb->get_results( "SELECT * FROM " . $wpdb->posts . " WHERE id='{$product_obj->product_id}'" );
624
  $product_data = $product_data[0];
625
 
626
- switch( $c['logic'] ) {
627
  case 'equal': //Checks if the product name is exactly the same as the condition value
628
- if ( $product_data->post_title == $c['value'] )
629
  return true;
630
  break;
631
 
632
  case 'greater'://Checks if the product name is not the same as the condition value
633
- if ( $product_data->post_title > $c['value'] )
634
  return true;
635
  break;
636
 
637
  case 'less'://Checks if the product name is not the same as the condition value
638
- if ( $product_data->post_title < $c['value'] )
639
  return true;
640
  break;
641
 
642
  case 'contains'://Checks if the product name contains the condition value
643
- preg_match( "/(.*)" . preg_quote( $c['value'], '/' ) . "(.*)/", $product_data->post_title, $match );
644
 
645
  if ( ! empty( $match ) )
646
  return true;
@@ -653,26 +656,26 @@ class wpsc_coupons {
653
  $categories = wpsc_get_product_terms( $product_data->ID, 'wpsc_product_category' );
654
  }
655
  foreach ( $categories as $cat ) {
656
- if ( strtolower( $cat->name ) == strtolower( $c['value'] ) )
657
  return true;
658
  }
659
  break;
660
 
661
  case 'not_contain'://Checks if the product name contains the condition value
662
- preg_match( "/(.*)" . preg_quote( $c['value'], '/' ) . "(.*)/", $product_data->post_title, $match );
663
 
664
  if ( empty( $match ) )
665
  return true;
666
  break;
667
 
668
  case 'begins'://Checks if the product name begins with condition value
669
- preg_match( "/^" . preg_quote( $c['value'], '/' ) . "/", $product_data->post_title, $match );
670
  if ( ! empty( $match ) )
671
  return true;
672
  break;
673
 
674
  case 'ends'://Checks if the product name ends with condition value
675
- preg_match( "/" . preg_quote( $c['value'], '/' ) . "$/", $product_data->post_title, $match );
676
  if ( ! empty( $match ) )
677
  return true;
678
  break;
@@ -680,65 +683,65 @@ class wpsc_coupons {
680
  default:
681
  return false;
682
  }
683
- } else if ( 'item_quantity' == $c['property'] ) {
684
 
685
- switch( $c['logic'] ) {
686
  case 'equal'://Checks if the quantity of a product in the cart equals condition value
687
- if ( $product_obj->quantity == (int) $c['value'] )
688
  return true;
689
  break;
690
 
691
  case 'greater'://Checks if the quantity of a product is greater than the condition value
692
- if ( $product_obj->quantity > $c['value'] )
693
  return true;
694
  break;
695
 
696
  case 'less'://Checks if the quantity of a product is less than the condition value
697
- if ( $product_obj->quantity < $c['value'] )
698
  return true;
699
  break;
700
 
701
  case 'contains'://Checks if the product name contains the condition value
702
- preg_match( "/(.*)" . $c['value'] . "(.*)/", $product_obj->quantity, $match );
703
  if ( ! empty( $match ) )
704
  return true;
705
  break;
706
 
707
  case 'not_contain'://Checks if the product name contains the condition value
708
- preg_match("/(.*)".$c['value']."(.*)/",$product_obj->quantity, $match );
709
  if ( empty( $match ) )
710
  return true;
711
  break;
712
 
713
  case 'begins'://Checks if the product name begins with condition value
714
- preg_match("/^".$c['value']."/", $product_obj->quantity, $match );
715
  if ( ! empty( $match ) )
716
  return true;
717
  break;
718
 
719
  case 'ends'://Checks if the product name ends with condition value
720
- preg_match( "/" . $c['value'] . "$/", $product_obj->quantity, $match );
721
  if ( ! empty( $match ) )
722
  return true;
723
  break;
724
  default:
725
  return false;
726
  }
727
- } else if ($c['property'] == 'total_quantity'){
728
  $total_quantity = wpsc_cart_item_count();
729
- switch($c['logic']) {
730
  case 'equal'://Checks if the quantity of products in the cart equals condition value
731
- if ($total_quantity == $c['value'])
732
  return true;
733
  break;
734
 
735
  case 'greater'://Checks if the quantity in the cart is greater than the condition value
736
- if ($total_quantity > $c['value'])
737
  return true;
738
  break;
739
 
740
  case 'less'://Checks if the quantity in the cart is less than the condition value
741
- if ($total_quantity < $c['value'])
742
  return true;
743
  break;
744
 
@@ -746,21 +749,21 @@ class wpsc_coupons {
746
  return false;
747
  }
748
 
749
- } else if ($c['property'] == 'subtotal_amount'){
750
  $subtotal = wpsc_cart_total(false);
751
- switch($c['logic']) {
752
  case 'equal'://Checks if the subtotal of products in the cart equals condition value
753
- if ($subtotal == $c['value'])
754
  return true;
755
  break;
756
 
757
  case 'greater'://Checks if the subtotal of the cart is greater than the condition value
758
- if ($subtotal > $c['value'])
759
  return true;
760
  break;
761
 
762
  case 'less'://Checks if the subtotal of the cart is less than the condition value
763
- if ($subtotal < $c['value']){
764
  return true;
765
  }else{
766
  return false;
@@ -772,7 +775,7 @@ class wpsc_coupons {
772
  return false;
773
  }
774
  } else {
775
- return apply_filters( 'wpsc_coupon_compare_logic', false, $c, $product_obj );
776
  }
777
  }
778
 
@@ -785,9 +788,6 @@ class wpsc_coupons {
785
 
786
  $num_active_coupons = $wpdb->get_var("SELECT COUNT(id) as c FROM `".WPSC_TABLE_COUPON_CODES."` WHERE active='1'");
787
 
788
- return ( $num_active_coupons > 0 );
789
  }
790
-
791
-
792
- }
793
- ?>
1
  <?php
2
+ /**
3
  * The Coupons Class
4
+ *
5
+ * Holds the main coupon class amd other important coupon functions
6
+ *
7
  * @package wp-e-commerce
8
+ */
9
 
10
  /**
11
  * uses coupons function, no parameters
37
  /**
38
  * Coupons class.
39
  *
40
+ * @todo Cleanup early in 4.0 / PHP5
 
 
 
41
  * @package wp-e-commerce
42
  * @since 3.7
43
  */
115
  *
116
  * Checks if the current coupon is valid to use (Expiry date, Active, Used).
117
  *
118
+ * @return bool True if coupon is not expired, used and still active, False otherwise.
119
  */
120
  function validate_coupon() {
121
 
207
  break;
208
 
209
  case 'ends'://Checks if the product name ends with condition value
210
+ return preg_match( "/" . preg_quote( $condition['value'], '/' ) . "$/", $product_data->post_title );
211
  break;
212
  }
213
 
225
  */
226
  public function _callback_condition_item_quantity( $condition, $cart_item ) {
227
  $value = (int) $condition['value'];
228
+
229
  switch( $condition['logic'] ) {
230
  case 'equal': //Checks if the quantity of a product in the cart equals condition value
231
  return $cart_item->quantity == $value;
252
  break;
253
 
254
  case 'ends'://Checks if the product name ends with condition value
255
+ return preg_match( "/" . $value . "$/",$cart_item->quantity );
256
  break;
257
  }
258
 
269
  * @return boolean
270
  */
271
  public function _callback_condition_total_quantity( $condition, $cart_item ) {
272
+
273
  $total_quantity = wpsc_cart_item_count();
274
+ $value = (int) $condition['value'];
275
 
276
  switch( $condition['logic'] ) {
277
  case 'equal'://Checks if the quantity of products in the cart equals condition value
484
  // if "Apply on all products" is not checked and the coupon is percentage, the discount
485
  // amount should be based on the eligible cart item with lowest unit price
486
  if ( $this->is_percentage() ) {
487
+ $field = apply_filters( 'wpsc_coupon_select_item_field', 'unit_price' );
488
  $item = array_shift( $items );
489
  return $item->$field * $this->value / 100;
490
  }
598
  * @return float
599
  */
600
  public function calculate_discount() {
601
+ global $wpsc_cart;
602
 
603
  $wpsc_cart->clear_cache();
604
 
605
+ if ( $this->has_conditions() ) {
606
  return $this->calculate_discount_conditions();
607
+ } else {
608
+ return $this->calculate_discount_without_conditions();
609
+ }
610
 
 
611
  }
612
 
613
  /**
614
  * Comparing logic with the product information
615
  *
616
+ * Checks if the product matches the logic
617
+ *
618
+ * @todo Is this ever even used?
619
  *
620
  * @return bool True if all conditions are matched, False otherwise.
621
  */
622
+ function compare_logic( $condition, $product ) {
623
  global $wpdb;
624
 
625
+ if ( 'item_name' == $condition['property'] ) {
626
+ $product_data = $wpdb->get_results( "SELECT * FROM " . $wpdb->posts . " WHERE id='{$product->product_id}'" );
627
  $product_data = $product_data[0];
628
 
629
+ switch( $condition['logic'] ) {
630
  case 'equal': //Checks if the product name is exactly the same as the condition value
631
+ if ( $product_data->post_title == $condition['value'] )
632
  return true;
633
  break;
634
 
635
  case 'greater'://Checks if the product name is not the same as the condition value
636
+ if ( $product_data->post_title > $condition['value'] )
637
  return true;
638
  break;
639
 
640
  case 'less'://Checks if the product name is not the same as the condition value
641
+ if ( $product_data->post_title < $condition['value'] )
642
  return true;
643
  break;
644
 
645
  case 'contains'://Checks if the product name contains the condition value
646
+ preg_match( "/(.*)" . preg_quote( $condition['value'], '/' ) . "(.*)/", $product_data->post_title, $match );
647
 
648
  if ( ! empty( $match ) )
649
  return true;
656
  $categories = wpsc_get_product_terms( $product_data->ID, 'wpsc_product_category' );
657
  }
658
  foreach ( $categories as $cat ) {
659
+ if ( strtolower( $cat->name ) == strtolower( $condition['value'] ) )
660
  return true;
661
  }
662
  break;
663
 
664
  case 'not_contain'://Checks if the product name contains the condition value
665
+ preg_match( "/(.*)" . preg_quote( $condition['value'], '/' ) . "(.*)/", $product_data->post_title, $match );
666
 
667
  if ( empty( $match ) )
668
  return true;
669
  break;
670
 
671
  case 'begins'://Checks if the product name begins with condition value
672
+ preg_match( "/^" . preg_quote( $condition['value'], '/' ) . "/", $product_data->post_title, $match );
673
  if ( ! empty( $match ) )
674
  return true;
675
  break;
676
 
677
  case 'ends'://Checks if the product name ends with condition value
678
+ preg_match( "/" . preg_quote( $condition['value'], '/' ) . "$/", $product_data->post_title, $match );
679
  if ( ! empty( $match ) )
680
  return true;
681
  break;
683
  default:
684
  return false;
685
  }
686
+ } else if ( 'item_quantity' == $condition['property'] ) {
687
 
688
+ switch( $condition['logic'] ) {
689
  case 'equal'://Checks if the quantity of a product in the cart equals condition value
690
+ if ( $product->quantity == (int) $condition['value'] )
691
  return true;
692
  break;
693
 
694
  case 'greater'://Checks if the quantity of a product is greater than the condition value
695
+ if ( $product->quantity > $condition['value'] )
696
  return true;
697
  break;
698
 
699
  case 'less'://Checks if the quantity of a product is less than the condition value
700
+ if ( $product->quantity < $condition['value'] )
701
  return true;
702
  break;
703
 
704
  case 'contains'://Checks if the product name contains the condition value
705
+ preg_match( "/(.*)" . $condition['value'] . "(.*)/", $product->quantity, $match );
706
  if ( ! empty( $match ) )
707
  return true;
708
  break;
709
 
710
  case 'not_contain'://Checks if the product name contains the condition value
711
+ preg_match("/(.*)".$condition['value']."(.*)/",$product->quantity, $match );
712
  if ( empty( $match ) )
713
  return true;
714
  break;
715
 
716
  case 'begins'://Checks if the product name begins with condition value
717
+ preg_match("/^".$condition['value']."/", $product->quantity, $match );
718
  if ( ! empty( $match ) )
719
  return true;
720
  break;
721
 
722
  case 'ends'://Checks if the product name ends with condition value
723
+ preg_match( "/" . $condition['value'] . "$/", $product->quantity, $match );
724
  if ( ! empty( $match ) )
725
  return true;
726
  break;
727
  default:
728
  return false;
729
  }
730
+ } else if ($condition['property'] == 'total_quantity') {
731
  $total_quantity = wpsc_cart_item_count();
732
+ switch($condition['logic']) {
733
  case 'equal'://Checks if the quantity of products in the cart equals condition value
734
+ if ($total_quantity == $condition['value'])
735
  return true;
736
  break;
737
 
738
  case 'greater'://Checks if the quantity in the cart is greater than the condition value
739
+ if ($total_quantity > $condition['value'])
740
  return true;
741
  break;
742
 
743
  case 'less'://Checks if the quantity in the cart is less than the condition value
744
+ if ($total_quantity < $condition['value'])
745
  return true;
746
  break;
747
 
749
  return false;
750
  }
751
 
752
+ } else if ( $condition['property'] == 'subtotal_amount' ) {
753
  $subtotal = wpsc_cart_total(false);
754
+ switch($condition['logic']) {
755
  case 'equal'://Checks if the subtotal of products in the cart equals condition value
756
+ if ($subtotal == $condition['value'])
757
  return true;
758
  break;
759
 
760
  case 'greater'://Checks if the subtotal of the cart is greater than the condition value
761
+ if ($subtotal > $condition['value'])
762
  return true;
763
  break;
764
 
765
  case 'less'://Checks if the subtotal of the cart is less than the condition value
766
+ if ($subtotal < $condition['value']){
767
  return true;
768
  }else{
769
  return false;
775
  return false;
776
  }
777
  } else {
778
+ return apply_filters( 'wpsc_coupon_compare_logic', false, $condition, $product );
779
  }
780
  }
781
 
788
 
789
  $num_active_coupons = $wpdb->get_var("SELECT COUNT(id) as c FROM `".WPSC_TABLE_COUPON_CODES."` WHERE active='1'");
790
 
791
+ return apply_filters( 'wpsc_uses_coupons', ( $num_active_coupons > 0 ) );
792
  }
793
+ }
 
 
 
wpsc-includes/purchase-log.helpers.php CHANGED
@@ -216,11 +216,14 @@ function wpsc_send_customer_email( $purchase_log ) {
216
  }
217
 
218
  function wpsc_send_admin_email( $purchase_log, $force = false ) {
219
- if ( ! is_object( $purchase_log ) )
 
220
  $purchase_log = new WPSC_Purchase_Log( $purchase_log );
 
221
 
222
- if ( $purchase_log->get( 'email_sent' ) && ! $force )
223
  return;
 
224
 
225
  $email = new WPSC_Purchase_Log_Admin_Notification( $purchase_log );
226
  $email_sent = $email->send();
@@ -231,6 +234,7 @@ function wpsc_send_admin_email( $purchase_log, $force = false ) {
231
  }
232
 
233
  do_action( 'wpsc_transaction_send_email_to_admin', $email, $email_sent );
 
234
  return $email_sent;
235
  }
236
 
216
  }
217
 
218
  function wpsc_send_admin_email( $purchase_log, $force = false ) {
219
+
220
+ if ( ! is_object( $purchase_log ) ) {
221
  $purchase_log = new WPSC_Purchase_Log( $purchase_log );
222
+ }
223
 
224
+ if ( $purchase_log->get( 'email_sent' ) && ! $force ) {
225
  return;
226
+ }
227
 
228
  $email = new WPSC_Purchase_Log_Admin_Notification( $purchase_log );
229
  $email_sent = $email->send();
234
  }
235
 
236
  do_action( 'wpsc_transaction_send_email_to_admin', $email, $email_sent );
237
+
238
  return $email_sent;
239
  }
240
 
wpsc-includes/wpsc-theme-engine-bootstrap.php CHANGED
@@ -73,7 +73,9 @@ function _wpsc_theme_engine_v1_has_actions() {
73
  if ( is_array( $core_exceptions[ $action ] ) ) {
74
 
75
  foreach ( $core_exceptions[ $action ] as $core_hook ) {
76
- remove_action( $action, $core_hook );
 
 
77
  }
78
 
79
  } else {
@@ -96,7 +98,7 @@ function _wpsc_theme_engine_v1_has_actions() {
96
  * Minimally redundant, though the comparable functions are only loaded in the 1.0 engine.
97
  *
98
  * @since 3.9
99
- * @return [type] [description]
100
  */
101
  function _wpsc_theme_engine_v2_has_old_templates() {
102
 
73
  if ( is_array( $core_exceptions[ $action ] ) ) {
74
 
75
  foreach ( $core_exceptions[ $action ] as $core_hook ) {
76
+ // Admitted hack until we build a better detection API.
77
+ $priority = ( '_wpsc_calculate_shipping_quotes_before_product_page' == $core_hook ) ? 1 : 10;
78
+ remove_action( $action, $core_hook, $priority );
79
  }
80
 
81
  } else {
98
  * Minimally redundant, though the comparable functions are only loaded in the 1.0 engine.
99
  *
100
  * @since 3.9
101
+ * @return bool Whether or not the active theme directory has old templates.
102
  */
103
  function _wpsc_theme_engine_v2_has_old_templates() {
104
 
wpsc-merchants/paypal-pro.merchant.php CHANGED
@@ -520,13 +520,13 @@ if ( in_array( 'wpsc_merchant_paypal_pro', (array)get_option( 'custom_gateway_op
520
 
521
  $output = "
522
  <tr>
523
- <td class='wpsc_CC_details'>" . __( 'Credit Card Number *', 'wpsc' ) . "</td>
524
  <td>
525
  <input type='text' value='' name='card_number' />
526
  </td>
527
  </tr>
528
  <tr>
529
- <td class='wpsc_CC_details'>" . __( 'Credit Card Expiry *', 'wpsc' ) . "</td>
530
  <td>
531
  <select class='wpsc_ccBox' name='expiry[month]'>
532
  " . $months . "
@@ -549,12 +549,12 @@ if ( in_array( 'wpsc_merchant_paypal_pro', (array)get_option( 'custom_gateway_op
549
  </td>
550
  </tr>
551
  <tr>
552
- <td class='wpsc_CC_details'>" . __( 'CVV *', 'wpsc' ) . "</td>
553
  <td><input type='text' size='4' value='' maxlength='4' name='card_code' />
554
  </td>
555
  </tr>
556
  <tr>
557
- <td class='wpsc_CC_details'>" . __( 'Card Type *', 'wpsc' ) . "</td>
558
  <td>
559
  <select class='wpsc_ccBox' name='cctype'>";
560
 
520
 
521
  $output = "
522
  <tr>
523
+ <td class='wpsc_CC_details'>" . __( 'Credit Card Number <span class="asterix">*</span>', 'wpsc' ) . "</td>
524
  <td>
525
  <input type='text' value='' name='card_number' />
526
  </td>
527
  </tr>
528
  <tr>
529
+ <td class='wpsc_CC_details'>" . __( 'Credit Card Expiry <span class="asterix">*</span>', 'wpsc' ) . "</td>
530
  <td>
531
  <select class='wpsc_ccBox' name='expiry[month]'>
532
  " . $months . "
549
  </td>
550
  </tr>
551
  <tr>
552
+ <td class='wpsc_CC_details'>" . __( 'CVV <span class="asterix">*</span>', 'wpsc' ) . "</td>
553
  <td><input type='text' size='4' value='' maxlength='4' name='card_code' />
554
  </td>
555
  </tr>
556
  <tr>
557
+ <td class='wpsc_CC_details'>" . __( 'Card Type <span class="asterix">*</span>', 'wpsc' ) . "</td>
558
  <td>
559
  <select class='wpsc_ccBox' name='cctype'>";
560
 
wpsc-merchants/paypal-standard.merchant.php CHANGED
@@ -143,9 +143,9 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
143
  'last_name' => $this->cart_data['billing_address']['last_name'],
144
  'address1' => $this->cart_data['billing_address']['address'],
145
  'city' => $this->cart_data['billing_address']['city'],
146
- 'state' => $this->cart_data['billing_address']['state'],
147
  'zip' => $this->cart_data['billing_address']['post_code'],
148
- 'country' => $this->cart_data['billing_address']['country'],
149
  );
150
 
151
  // Shipping
143
  'last_name' => $this->cart_data['billing_address']['last_name'],
144
  'address1' => $this->cart_data['billing_address']['address'],
145
  'city' => $this->cart_data['billing_address']['city'],
146
+ 'state' => isset( $this->cart_data['billing_address']['state'] ) ? $this->cart_data['billing_address']['state'] : '',
147
  'zip' => $this->cart_data['billing_address']['post_code'],
148
+ 'country' => isset( $this->cart_data['billing_address']['country'] ) ? $this->cart_data['billing_address']['country'] : '',
149
  );
150
 
151
  // Shipping