WooCommerce Services - Version 1.21.0

Version Description

  • Update WordPress compatibility to 5.2
  • When there's only one credit card available, select it as the default for purchases
  • Add ability to specify payment method during label purchase to enable choosing a credit card during purchase in the future
Download this release

Release Info

Developer woothemes
Plugin Icon 128x128 WooCommerce Services
Version 1.21.0
Comparing to
See all releases

Code changes from version 1.20.0 to 1.21.0

classes/class-wc-connect-payment-methods-store.php CHANGED
@@ -72,10 +72,10 @@ if ( ! class_exists( 'WC_Connect_Payment_Methods_Store' ) ) {
72
  return;
73
  }
74
 
75
- // Has the stored method ID been removed? Select the first available one
76
  $selected_payment_method_id = $this->service_settings_store->get_selected_payment_method_id();
77
  if (
78
- $selected_payment_method_id &&
79
  ! in_array( $selected_payment_method_id, $payment_method_ids )
80
  ) {
81
  $this->service_settings_store->set_selected_payment_method_id( $payment_method_ids[ 0 ] );
72
  return;
73
  }
74
 
75
+ // Has the stored method ID been removed, or is there only one available? Select the first available one
76
  $selected_payment_method_id = $this->service_settings_store->get_selected_payment_method_id();
77
  if (
78
+ ( $selected_payment_method_id || 1 === count( $payment_method_ids ) ) &&
79
  ! in_array( $selected_payment_method_id, $payment_method_ids )
80
  ) {
81
  $this->service_settings_store->set_selected_payment_method_id( $payment_method_ids[ 0 ] );
classes/class-wc-connect-service-settings-store.php CHANGED
@@ -103,6 +103,13 @@ if ( ! class_exists( 'WC_Connect_Service_Settings_Store' ) ) {
103
  $this->update_account_settings( $account_settings );
104
  }
105
 
 
 
 
 
 
 
 
106
  public function get_origin_address() {
107
  $wc_address_fields = array();
108
  $wc_address_fields['company'] = get_bloginfo( 'name' );
103
  $this->update_account_settings( $account_settings );
104
  }
105
 
106
+ public function can_user_manage_payment_methods() {
107
+ global $current_user;
108
+ $master_user = WC_Connect_Jetpack::get_master_user();
109
+ return WC_Connect_Jetpack::is_development_mode() ||
110
+ ( is_a( $master_user, 'WP_User' ) && $current_user->ID === $master_user->ID );
111
+ }
112
+
113
  public function get_origin_address() {
114
  $wc_address_fields = array();
115
  $wc_address_fields['company'] = get_bloginfo( 'name' );
classes/class-wc-rest-connect-account-settings-controller.php CHANGED
@@ -52,7 +52,7 @@ class WC_REST_Connect_Account_Settings_Controller extends WC_REST_Connect_Base_C
52
  'storeOptions' => $this->settings_store->get_store_options(),
53
  'formData' => $this->settings_store->get_account_settings(),
54
  'formMeta' => array(
55
- 'can_manage_payments' => $this->can_user_manage_payment_methods(),
56
  'can_edit_settings' => true,
57
  'master_user_name' => $master_user_name,
58
  'master_user_login' => $master_user_login,
@@ -67,8 +67,8 @@ class WC_REST_Connect_Account_Settings_Controller extends WC_REST_Connect_Base_C
67
  public function post( $request ) {
68
  $settings = $request->get_json_params();
69
 
70
- if ( ! $this->can_user_manage_payment_methods() ) {
71
- // Ignore the user-provided payment method ID if he doesn't have permission to change it
72
  $old_settings = $this->settings_store->get_account_settings();
73
  $settings['selected_payment_method_id'] = $old_settings['selected_payment_method_id'];
74
  }
@@ -92,11 +92,4 @@ class WC_REST_Connect_Account_Settings_Controller extends WC_REST_Connect_Base_C
92
 
93
  return new WP_REST_Response( array( 'success' => true ), 200 );
94
  }
95
-
96
- private function can_user_manage_payment_methods() {
97
- global $current_user;
98
- $master_user = WC_Connect_Jetpack::get_master_user();
99
- return WC_Connect_Jetpack::is_development_mode() ||
100
- ( is_a( $master_user, 'WP_User' ) && $current_user->ID === $master_user->ID );
101
- }
102
  }
52
  'storeOptions' => $this->settings_store->get_store_options(),
53
  'formData' => $this->settings_store->get_account_settings(),
54
  'formMeta' => array(
55
+ 'can_manage_payments' => $this->settings_store->can_user_manage_payment_methods(),
56
  'can_edit_settings' => true,
57
  'master_user_name' => $master_user_name,
58
  'master_user_login' => $master_user_login,
67
  public function post( $request ) {
68
  $settings = $request->get_json_params();
69
 
70
+ if ( ! $this->settings_store->can_user_manage_payment_methods() ) {
71
+ // Ignore the user-provided payment method ID if they don't have permission to change it
72
  $old_settings = $this->settings_store->get_account_settings();
73
  $settings['selected_payment_method_id'] = $old_settings['selected_payment_method_id'];
74
  }
92
 
93
  return new WP_REST_Response( array( 'success' => true ), 200 );
94
  }
 
 
 
 
 
 
 
95
  }
classes/class-wc-rest-connect-shipping-label-controller.php CHANGED
@@ -34,10 +34,14 @@ class WC_REST_Connect_Shipping_Label_Controller extends WC_REST_Connect_Base_Con
34
  public function post( $request ) {
35
  $settings = $request->get_json_params();
36
  $order_id = $request[ 'order_id' ];
37
-
38
- $settings[ 'payment_method_id' ] = $this->settings_store->get_selected_payment_method_id();
39
  $settings[ 'order_id' ] = $order_id;
40
 
 
 
 
 
 
 
41
  $service_names = array();
42
  foreach ( $settings[ 'packages' ] as $index => $package ) {
43
  $service_names[] = $package[ 'service_name' ];
34
  public function post( $request ) {
35
  $settings = $request->get_json_params();
36
  $order_id = $request[ 'order_id' ];
 
 
37
  $settings[ 'order_id' ] = $order_id;
38
 
39
+ if ( empty( $settings[ 'payment_method_id' ] ) || ! $this->settings_store->can_user_manage_payment_methods() ) {
40
+ $settings[ 'payment_method_id' ] = $this->settings_store->get_selected_payment_method_id();
41
+ } else {
42
+ $this->settings_store->set_selected_payment_method_id( $settings[ 'payment_method_id' ] );
43
+ }
44
+
45
  $service_names = array();
46
  foreach ( $settings[ 'packages' ] as $index => $package ) {
47
  $service_names[] = $package[ 'service_name' ];
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: automattic, woothemes, allendav, kellychoffman, jkudish, jeffstieler, nabsul, robobot3000, danreylop, mikeyarce, shaunkuschel, orangesareorange, pauldechov, dappermountain, radogeorgiev
3
  Tags: shipping, stamps, usps, woocommerce, taxes, payment, stripe
4
  Requires at least: 4.6
5
- Tested up to: 5.0.3
6
- Stable tag: 1.20.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -82,9 +82,15 @@ As of the WooCommerce 3.5 release, WooCommerce Services no longer provides shipp
82
 
83
  == Changelog ==
84
 
 
 
 
 
 
 
85
  = 1.20.0 =
86
 
87
- * Update WooCommerce compatiblity to 3.6
88
  * Improved wording for the Stripe Connect UI when disconnected
89
  * Improve detection of when a Stripe account is connected
90
  * Avoid overwriting Stripe keys after they've already been entered, and WooCommerce Services is connected for the first time
2
  Contributors: automattic, woothemes, allendav, kellychoffman, jkudish, jeffstieler, nabsul, robobot3000, danreylop, mikeyarce, shaunkuschel, orangesareorange, pauldechov, dappermountain, radogeorgiev
3
  Tags: shipping, stamps, usps, woocommerce, taxes, payment, stripe
4
  Requires at least: 4.6
5
+ Tested up to: 5.2
6
+ Stable tag: 1.21.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
82
 
83
  == Changelog ==
84
 
85
+ = 1.21.0 =
86
+
87
+ * Update WordPress compatibility to 5.2
88
+ * When there's only one credit card available, select it as the default for purchases
89
+ * Add ability to specify payment method during label purchase to enable choosing a credit card during purchase in the future
90
+
91
  = 1.20.0 =
92
 
93
+ * Update WooCommerce compatibility to 3.6
94
  * Improved wording for the Stripe Connect UI when disconnected
95
  * Improve detection of when a Stripe account is connected
96
  * Avoid overwriting Stripe keys after they've already been entered, and WooCommerce Services is connected for the first time
woocommerce-services.php CHANGED
@@ -7,7 +7,7 @@
7
  * Author URI: https://woocommerce.com/
8
  * Text Domain: woocommerce-services
9
  * Domain Path: /i18n/languages/
10
- * Version: 1.20.0
11
  * WC requires at least: 3.0.0
12
  * WC tested up to: 3.6.*
13
  *
7
  * Author URI: https://woocommerce.com/
8
  * Text Domain: woocommerce-services
9
  * Domain Path: /i18n/languages/
10
+ * Version: 1.21.0
11
  * WC requires at least: 3.0.0
12
  * WC tested up to: 3.6.*
13
  *