MailChimp for WooCommerce - Version 2.7.5

Version Description

Download this release

Release Info

Developer ryanhungate
Plugin Icon wp plugin MailChimp for WooCommerce
Version 2.7.5
Comparing to
See all releases

Code changes from version 2.7.4 to 2.7.5

CHANGELOG.txt CHANGED
@@ -1,4 +1,7 @@
1
  == Changelog ==
 
 
 
2
  = 2.7.4 =
3
  * wiki article for webhook setup issues
4
  * new filter for my account newsletter field with wiki
1
  == Changelog ==
2
+ = 2.7.5 =
3
+ * fix admin subscription status checkbox flow
4
+ * remove support flag on plugin uninstall
5
  = 2.7.4 =
6
  * wiki article for webhook setup issues
7
  * new filter for my account newsletter field with wiki
README.txt CHANGED
@@ -4,10 +4,10 @@ Tags: ecommerce,email,workflows,mailchimp
4
  Donate link: https://mailchimp.com
5
  Requires at least: 4.9
6
  Tested up to: 6.0
7
- Stable tag: 2.7.4
8
  Requires PHP: 7.4
9
  WC requires at least: 3.5
10
- WC tested up to: 6.8
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
  Connect your store to your Mailchimp audience to track sales, create targeted emails, send abandoned cart emails, and more.
@@ -78,10 +78,8 @@ At this time, the synchronization of product categories from WooCommerce to Mail
78
  If you are unable to sync or connect with Mailchimp, you can open a ticket on our [Github plugin page](https://github.com/mailchimp/mc-woocommerce/issues). Please provide the version of the plugin and PHP you're using, any fatal errors in the WooCommerce logs (WooCommerce -> Status -> Logs) you're seeing, along with relevant information to the problem you're experiencing.
79
 
80
  == Changelog ==
81
- = 2.7.4 =
82
- * wiki article for webhook setup issues
83
- * new filter for my account newsletter field with wiki
84
- * add filter for products to be pushed or not
85
- * add filter for orders to be pushed or not
86
 
87
  [Historical Changelog](https://raw.githubusercontent.com/mailchimp/mc-woocommerce/master/CHANGELOG.txt)
4
  Donate link: https://mailchimp.com
5
  Requires at least: 4.9
6
  Tested up to: 6.0
7
+ Stable tag: 2.7.5
8
  Requires PHP: 7.4
9
  WC requires at least: 3.5
10
+ WC tested up to: 6.9
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
  Connect your store to your Mailchimp audience to track sales, create targeted emails, send abandoned cart emails, and more.
78
  If you are unable to sync or connect with Mailchimp, you can open a ticket on our [Github plugin page](https://github.com/mailchimp/mc-woocommerce/issues). Please provide the version of the plugin and PHP you're using, any fatal errors in the WooCommerce logs (WooCommerce -> Status -> Logs) you're seeing, along with relevant information to the problem you're experiencing.
79
 
80
  == Changelog ==
81
+ = 2.7.5 =
82
+ * fix admin subscription status checkbox flow
83
+ * remove support flag on plugin uninstall
 
 
84
 
85
  [Historical Changelog](https://raw.githubusercontent.com/mailchimp/mc-woocommerce/master/CHANGELOG.txt)
admin/class-mailchimp-woocommerce-admin.php CHANGED
@@ -279,6 +279,10 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
279
  if ( empty( $user ) || ! is_email( $user->user_email ) || ! mailchimp_is_configured() ) {
280
  return false;
281
  }
 
 
 
 
282
  if ( ( $status = mailchimp_get_api()->getCachedSubscriberStatusForAdminProfileView( mailchimp_get_list_id(), $user->user_email ) ) ) {
283
  $subscribed = is_string( $status ) && in_array( $status, array( 'subscribed', 'pending' ) ) ? '1' : '0';
284
  $saved = (bool) get_user_meta( $user->ID, 'mailchimp_woocommerce_is_subscribed', true );
279
  if ( empty( $user ) || ! is_email( $user->user_email ) || ! mailchimp_is_configured() ) {
280
  return false;
281
  }
282
+ // if we're setting the subscriber status in an admin update this might still be in limbo.
283
+ if ( mailchimp_get_transient("updating_subscriber_status.{$user->ID}", false) ) {
284
+ return false;
285
+ }
286
  if ( ( $status = mailchimp_get_api()->getCachedSubscriberStatusForAdminProfileView( mailchimp_get_list_id(), $user->user_email ) ) ) {
287
  $subscribed = is_string( $status ) && in_array( $status, array( 'subscribed', 'pending' ) ) ? '1' : '0';
288
  $saved = (bool) get_user_meta( $user->ID, 'mailchimp_woocommerce_is_subscribed', true );
bootstrap.php CHANGED
@@ -94,7 +94,7 @@ function mailchimp_environment_variables() {
94
  return (object) array(
95
  'repo' => 'master',
96
  'environment' => 'production', // staging or production
97
- 'version' => '2.7.4',
98
  'php_version' => phpversion(),
99
  'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
100
  'wc_version' => function_exists('WC') ? WC()->version : null,
94
  return (object) array(
95
  'repo' => 'master',
96
  'environment' => 'production', // staging or production
97
+ 'version' => '2.7.5',
98
  'php_version' => phpversion(),
99
  'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
100
  'wc_version' => function_exists('WC') ? WC()->version : null,
includes/class-mailchimp-woocommerce-service.php CHANGED
@@ -1209,14 +1209,28 @@ class MailChimp_Service extends MailChimp_WooCommerce_Options
1209
  */
1210
  public function user_update_subscribe_status( $user_id )
1211
  {
1212
- $subscribed = isset($_POST['mailchimp_woocommerce_is_subscribed_checkbox']) &&
1213
  $_POST['mailchimp_woocommerce_is_subscribed_checkbox'] == 'on';
1214
  $gdpr_fields = isset($_POST['mailchimp_woocommerce_gdpr']) ? $_POST['mailchimp_woocommerce_gdpr'] : null;
 
 
 
 
1215
  mailchimp_log("profile", 'user_update_subscribe_status', array(
1216
  'subscribed' => $subscribed,
1217
  'user_id' => $user_id,
1218
  'gdpr_fields' => $gdpr_fields,
1219
  ));
 
 
 
 
 
 
 
 
 
 
1220
  update_user_meta($user_id, 'mailchimp_woocommerce_is_subscribed', $subscribed);
1221
  update_user_meta($user_id, 'mailchimp_woocommerce_gdpr_fields', $gdpr_fields);
1222
  mailchimp_set_transient("mailchimp_woocommerce_gdpr_fields_{$user_id}", $gdpr_fields, 300);
1209
  */
1210
  public function user_update_subscribe_status( $user_id )
1211
  {
1212
+ $subscribed = isset($_POST['mailchimp_woocommerce_is_subscribed_checkbox']) &&
1213
  $_POST['mailchimp_woocommerce_is_subscribed_checkbox'] == 'on';
1214
  $gdpr_fields = isset($_POST['mailchimp_woocommerce_gdpr']) ? $_POST['mailchimp_woocommerce_gdpr'] : null;
1215
+
1216
+ // set a site transient that will prevent overlapping updates from refreshing the page on the admin user view
1217
+ mailchimp_set_transient("updating_subscriber_status.{$user_id}", true, 300);
1218
+
1219
  mailchimp_log("profile", 'user_update_subscribe_status', array(
1220
  'subscribed' => $subscribed,
1221
  'user_id' => $user_id,
1222
  'gdpr_fields' => $gdpr_fields,
1223
  ));
1224
+
1225
+ $user = get_user_by('id', $user_id);
1226
+
1227
+ if ( $user && $user->user_email ) {
1228
+ $email_hash = md5( strtolower( trim( $user->user_email ) ) );
1229
+ $list_id = mailchimp_get_list_id();
1230
+ $transient = "mailchimp-woocommerce-subscribed.{$list_id}.{$email_hash}";
1231
+ delete_site_transient( $transient );
1232
+ }
1233
+
1234
  update_user_meta($user_id, 'mailchimp_woocommerce_is_subscribed', $subscribed);
1235
  update_user_meta($user_id, 'mailchimp_woocommerce_gdpr_fields', $gdpr_fields);
1236
  mailchimp_set_transient("mailchimp_woocommerce_gdpr_fields_{$user_id}", $gdpr_fields, 300);
includes/processes/class-mailchimp-woocommerce-user-submit.php CHANGED
@@ -272,6 +272,9 @@ class MailChimp_WooCommerce_User_Submit extends Mailchimp_Woocommerce_Job
272
  // ok let's update this member
273
  $api->update($list_id, $email, $member_data['status'], $merge_fields, null, $language, $gdpr_fields);
274
 
 
 
 
275
  // update the member tags but fail silently just in case.
276
  $api->updateMemberTags(mailchimp_get_list_id(), $email, true);
277
 
@@ -300,7 +303,10 @@ class MailChimp_WooCommerce_User_Submit extends Mailchimp_Woocommerce_Job
300
  $status_if_new = $uses_doi && $this->subscribed ? 'pending' : (bool) $this->subscribed;
301
 
302
  $api->subscribe($list_id, $user->user_email, $status_if_new, $merge_fields, null, $language, $gdpr_fields);
303
-
 
 
 
304
  // update the member tags but fail silently just in case.
305
  $api->updateMemberTags(mailchimp_get_list_id(), $email, true);
306
 
272
  // ok let's update this member
273
  $api->update($list_id, $email, $member_data['status'], $merge_fields, null, $language, $gdpr_fields);
274
 
275
+ // delete this admin transient if there was one
276
+ mailchimp_delete_transient("updating_subscriber_status.{$this->id}" );
277
+
278
  // update the member tags but fail silently just in case.
279
  $api->updateMemberTags(mailchimp_get_list_id(), $email, true);
280
 
303
  $status_if_new = $uses_doi && $this->subscribed ? 'pending' : (bool) $this->subscribed;
304
 
305
  $api->subscribe($list_id, $user->user_email, $status_if_new, $merge_fields, null, $language, $gdpr_fields);
306
+
307
+ // delete this admin transient if there was one
308
+ mailchimp_delete_transient("updating_subscriber_status.{$this->id}" );
309
+
310
  // update the member tags but fail silently just in case.
311
  $api->updateMemberTags(mailchimp_get_list_id(), $email, true);
312
 
mailchimp-woocommerce.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: Mailchimp for WooCommerce
17
  * Plugin URI: https://mailchimp.com/connect-your-store/
18
  * Description: Connects WooCommerce to Mailchimp to sync your store data, send targeted campaigns to your customers, and sell more stuff.
19
- * Version: 2.7.4
20
  * Author: Mailchimp
21
  * Author URI: https://mailchimp.com
22
  * License: GPL-2.0+
@@ -26,7 +26,7 @@
26
  * Requires at least: 4.9
27
  * Tested up to: 6.0
28
  * WC requires at least: 3.5
29
- * WC tested up to: 6.8
30
  */
31
 
32
  // If this file is called directly, abort.
16
  * Plugin Name: Mailchimp for WooCommerce
17
  * Plugin URI: https://mailchimp.com/connect-your-store/
18
  * Description: Connects WooCommerce to Mailchimp to sync your store data, send targeted campaigns to your customers, and sell more stuff.
19
+ * Version: 2.7.5
20
  * Author: Mailchimp
21
  * Author URI: https://mailchimp.com
22
  * License: GPL-2.0+
26
  * Requires at least: 4.9
27
  * Tested up to: 6.0
28
  * WC requires at least: 3.5
29
+ * WC tested up to: 6.9
30
  */
31
 
32
  // If this file is called directly, abort.
uninstall.php CHANGED
@@ -40,6 +40,10 @@ function mailchimp_woocommerce_uninstall() {
40
  if (isset($options['mailchimp_api_key'])) {
41
  $store_id = get_option('mailchimp-woocommerce-store_id', false);
42
  if (!empty($store_id)) {
 
 
 
 
43
  $api = new MailChimp_WooCommerce_MailChimpApi($options['mailchimp_api_key']);
44
  $result = $api->deleteStore($store_id) ? 'has been deleted' : 'did not delete';
45
  error_log("store id {$store_id} {$result} MailChimp");
40
  if (isset($options['mailchimp_api_key'])) {
41
  $store_id = get_option('mailchimp-woocommerce-store_id', false);
42
  if (!empty($store_id)) {
43
+ // disable support if they had it enabled
44
+ $tower = new MailChimp_WooCommerce_Tower($store_id);
45
+ $tower->toggle(false);
46
+ // delete the store if it's in Mailchimp
47
  $api = new MailChimp_WooCommerce_MailChimpApi($options['mailchimp_api_key']);
48
  $result = $api->deleteStore($store_id) ? 'has been deleted' : 'did not delete';
49
  error_log("store id {$store_id} {$result} MailChimp");