MailChimp for WooCommerce - Version 2.4.5

Version Description

Download this release

Release Info

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

Code changes from version 2.4.4 to 2.4.5

CHANGELOG.txt CHANGED
@@ -1,4 +1,26 @@
1
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  = 2.4.2 =
3
  * WooCommerce Version 4.3 tested
4
  * adds Mailchimp support form
1
  == Changelog ==
2
+ = 2.4.5 =
3
+ * fixed disconnect/reconnect list issue
4
+ * fixed rest api doing it wrong alert
5
+ = 2.4.4 =
6
+ * add filter for managing woocommerce plugins
7
+ = 2.4.3 =
8
+ * WooCommerce Version 4.3 tested
9
+ * adds Mailchimp support form
10
+ * moves navigation to WooCommerce nav as a sub-item
11
+ * removes bubble h1 title element
12
+ * log tab ui enhancements
13
+ * next button for setup wizard moved to bottom of page
14
+ * required field ui enhancement
15
+ * adds a banner for setup completion in Wordpress
16
+ * overview tab ui enhancements
17
+ * audience settings tab ux improvements
18
+ * fix for cart non-numeric error
19
+ * fix for woocommerce setup wizard redirect
20
+ * fix for abandoned cart on product variations
21
+ * fix for invalid session object
22
+ * adds customer filter for on-hold orders
23
+ * fix cart posts with product variations
24
  = 2.4.2 =
25
  * WooCommerce Version 4.3 tested
26
  * adds Mailchimp support form
README.txt CHANGED
@@ -4,7 +4,7 @@ Tags: ecommerce,email,workflows,mailchimp
4
  Donate link: https://mailchimp.com
5
  Requires at least: 4.9
6
  Tested up to: 5.5
7
- Stable tag: 2.4.4
8
  Requires PHP: 7.0
9
  WC requires at least: 3.5
10
  WC tested up to: 4.4
@@ -77,8 +77,9 @@ At this time, the synchronization of product categories from WooCommerce to Mail
77
  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.
78
 
79
  == Changelog ==
80
- = 2.4.4 =
81
- * add filter for managing woocommerce plugins
 
82
 
83
  [Historical Changelog](https://raw.githubusercontent.com/mailchimp/mc-woocommerce/master/CHANGELOG.txt)
84
 
4
  Donate link: https://mailchimp.com
5
  Requires at least: 4.9
6
  Tested up to: 5.5
7
+ Stable tag: 2.4.5
8
  Requires PHP: 7.0
9
  WC requires at least: 3.5
10
  WC tested up to: 4.4
77
  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.
78
 
79
  == Changelog ==
80
+ = 2.4.5 =
81
+ * fixed disconnect/reconnect list issue
82
+ * fixed rest api doing it wrong alert
83
 
84
  [Historical Changelog](https://raw.githubusercontent.com/mailchimp/mc-woocommerce/master/CHANGELOG.txt)
85
 
admin/class-mailchimp-woocommerce-admin.php CHANGED
@@ -50,28 +50,30 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
50
  return static::instance();
51
  }
52
 
53
- /**
54
- * @return bool
55
- */
56
  private function disconnect_store()
57
  {
58
- $options = array();
59
- $options['mailchimp_api_key'] = null;
60
- $options['active_tab'] = 'api_key';
61
- $options['mailchimp_list'] = null;
62
-
63
- // clean database
64
- mailchimp_clean_database();
65
-
66
  // remove user from our marketing status audience
67
- mailchimp_remove_communication_status();
 
 
68
 
69
  if (($store_id = mailchimp_get_store_id()) && ($mc = mailchimp_get_api())) {
 
70
  if ($mc->deleteStore($store_id)) {
71
  mailchimp_log('store.disconnected', 'Store id ' . mailchimp_get_store_id() . ' has been disconnected');
 
 
72
  }
73
  }
74
 
 
 
 
 
 
75
  return $options;
76
  }
77
 
@@ -513,6 +515,14 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
513
  $data['store_currency_code'] = (string) $input['store_currency_code'];
514
  }
515
 
 
 
 
 
 
 
 
 
516
  switch ($active_tab) {
517
 
518
  case 'api_key':
@@ -533,18 +543,23 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
533
 
534
  case 'sync':
535
  // case disconnect
536
- if ($this->is_disconnecting()) {
537
  // Disconnect store!
538
- if ($data = $this->disconnect_store()) {
 
 
 
 
 
539
  add_settings_error('mailchimp_store_settings', '', __('Store Disconnected', 'mailchimp-for-woocommerce'), 'info');
540
- }
541
- else {
542
  $data['active_tab'] = 'sync';
543
  add_settings_error('mailchimp_store_settings', '', __('Store Disconnect Failed', 'mailchimp-for-woocommerce'), 'warning');
544
  }
545
  }
546
  //case sync
547
  elseif ($this->is_resyncing()) {
 
548
  // remove all the pointers to be sure
549
  $service = new MailChimp_Service();
550
  $service->removePointers(true, true);
@@ -1474,6 +1489,10 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
1474
  $store->setListId($list_id);
1475
 
1476
  try {
 
 
 
 
1477
  // let's create a new store for this user through the API
1478
  $this->api()->$call($store, false);
1479
 
@@ -1491,7 +1510,7 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
1491
 
1492
  } catch (\Exception $e) {
1493
  if (mailchimp_string_contains($e->getMessage(),'woocommerce already exists in the account' )) {
1494
- // retrieve Mailchimp store using domain
1495
  $stores = $this->api()->stores();
1496
  //iterate thru stores, find correct store ID and save it to db
1497
  foreach ($stores as $mc_store) {
50
  return static::instance();
51
  }
52
 
53
+ /**
54
+ * @return array
55
+ */
56
  private function disconnect_store()
57
  {
 
 
 
 
 
 
 
 
58
  // remove user from our marketing status audience
59
+ try {
60
+ mailchimp_remove_communication_status();
61
+ } catch (\Exception $e) {}
62
 
63
  if (($store_id = mailchimp_get_store_id()) && ($mc = mailchimp_get_api())) {
64
+ set_site_transient('mailchimp_disconnecting_store', true, 15);
65
  if ($mc->deleteStore($store_id)) {
66
  mailchimp_log('store.disconnected', 'Store id ' . mailchimp_get_store_id() . ' has been disconnected');
67
+ } else {
68
+ mailchimp_log('store.NOT DISCONNECTED', 'Store id ' . mailchimp_get_store_id() . ' has NOT been disconnected');
69
  }
70
  }
71
 
72
+ // clean database
73
+ mailchimp_clean_database();
74
+
75
+ $options = array();
76
+
77
  return $options;
78
  }
79
 
515
  $data['store_currency_code'] = (string) $input['store_currency_code'];
516
  }
517
 
518
+ if (get_site_transient('mailchimp_disconnecting_store')) {
519
+ return array(
520
+ 'active_tab' => 'api_key',
521
+ 'mailchimp_api_key' => null,
522
+ 'mailchimp_list' => null,
523
+ );
524
+ }
525
+
526
  switch ($active_tab) {
527
 
528
  case 'api_key':
543
 
544
  case 'sync':
545
  // case disconnect
546
+ if ($this->is_disconnecting()) {
547
  // Disconnect store!
548
+ if ($this->disconnect_store()) {
549
+ return array(
550
+ 'active_tab' => 'api_key',
551
+ 'mailchimp_api_key' => null,
552
+ 'mailchimp_list' => null,
553
+ );
554
  add_settings_error('mailchimp_store_settings', '', __('Store Disconnected', 'mailchimp-for-woocommerce'), 'info');
555
+ } else {
 
556
  $data['active_tab'] = 'sync';
557
  add_settings_error('mailchimp_store_settings', '', __('Store Disconnect Failed', 'mailchimp-for-woocommerce'), 'warning');
558
  }
559
  }
560
  //case sync
561
  elseif ($this->is_resyncing()) {
562
+
563
  // remove all the pointers to be sure
564
  $service = new MailChimp_Service();
565
  $service->removePointers(true, true);
1489
  $store->setListId($list_id);
1490
 
1491
  try {
1492
+ mailchimp_log('sync_store', 'posting data', array(
1493
+ 'store_post' => $store->toArray(),
1494
+ ));
1495
+
1496
  // let's create a new store for this user through the API
1497
  $this->api()->$call($store, false);
1498
 
1510
 
1511
  } catch (\Exception $e) {
1512
  if (mailchimp_string_contains($e->getMessage(),'woocommerce already exists in the account' )) {
1513
+ // retrieve Mailchimp store using domain
1514
  $stores = $this->api()->stores();
1515
  //iterate thru stores, find correct store ID and save it to db
1516
  foreach ($stores as $mc_store) {
admin/partials/mailchimp-woocommerce-admin-tabs.php CHANGED
@@ -6,8 +6,9 @@ $handler = MailChimp_WooCommerce_Admin::connect();
6
  $options = get_option($this->plugin_name, array());
7
 
8
  $active_tab = isset($_GET['tab']) ? $_GET['tab'] : (isset($options['active_tab']) ? $options['active_tab'] : 'api_key');
 
9
 
10
- if (!mailchimp_is_configured()) {
11
  if ($active_tab == 'sync' || $active_tab == 'logs' ) isset($options['active_tab']) ? $options['active_tab'] : 'api_key';
12
  }
13
 
@@ -16,7 +17,7 @@ $is_mailchimp_post = isset($_POST['mailchimp_woocommerce_settings_hidden']) && $
16
  $show_sync_tab = isset($_GET['resync']) ? $_GET['resync'] === '1' : false;
17
 
18
  // if we have a transient set to start the sync on this page view, initiate it now that the values have been saved.
19
- if (!$show_sync_tab && (bool) get_site_transient('mailchimp_woocommerce_start_sync', false)) {
20
  $show_sync_tab = true;
21
  $active_tab = 'sync';
22
  }
@@ -26,7 +27,7 @@ $has_valid_api_key = false;
26
  $allow_new_list = true;
27
  $only_one_list = false;
28
  $show_wizard = true;
29
- $clicked_sync_button = $is_mailchimp_post && $active_tab == 'sync';
30
  $has_api_error = isset($options['api_ping_error']) && !empty($options['api_ping_error']) ? $options['api_ping_error'] : null;
31
 
32
  if (isset($options['mailchimp_api_key'])) {
@@ -61,6 +62,9 @@ else {
61
  $active_tab = 'api_key';
62
  }
63
 
 
 
 
64
  ?>
65
 
66
  <?php if (!defined('PHP_VERSION_ID') || (PHP_VERSION_ID < 70000)): ?>
6
  $options = get_option($this->plugin_name, array());
7
 
8
  $active_tab = isset($_GET['tab']) ? $_GET['tab'] : (isset($options['active_tab']) ? $options['active_tab'] : 'api_key');
9
+ $mc_configured = mailchimp_is_configured();
10
 
11
+ if (!$mc_configured) {
12
  if ($active_tab == 'sync' || $active_tab == 'logs' ) isset($options['active_tab']) ? $options['active_tab'] : 'api_key';
13
  }
14
 
17
  $show_sync_tab = isset($_GET['resync']) ? $_GET['resync'] === '1' : false;
18
 
19
  // if we have a transient set to start the sync on this page view, initiate it now that the values have been saved.
20
+ if ($mc_configured && !$show_sync_tab && (bool) get_site_transient('mailchimp_woocommerce_start_sync', false)) {
21
  $show_sync_tab = true;
22
  $active_tab = 'sync';
23
  }
27
  $allow_new_list = true;
28
  $only_one_list = false;
29
  $show_wizard = true;
30
+ $clicked_sync_button = $mc_configured && $is_mailchimp_post && $active_tab == 'sync';
31
  $has_api_error = isset($options['api_ping_error']) && !empty($options['api_ping_error']) ? $options['api_ping_error'] : null;
32
 
33
  if (isset($options['mailchimp_api_key'])) {
62
  $active_tab = 'api_key';
63
  }
64
 
65
+
66
+ //var_dump(array('jordan' => array('active' => $active_tab, 'configured' => $mc_configured, 'api_key' => mailchimp_get_api_key()))); die();
67
+
68
  ?>
69
 
70
  <?php if (!defined('PHP_VERSION_ID') || (PHP_VERSION_ID < 70000)): ?>
bootstrap.php CHANGED
@@ -87,7 +87,7 @@ function mailchimp_environment_variables() {
87
  return (object) array(
88
  'repo' => 'master',
89
  'environment' => 'production', // staging or production
90
- 'version' => '2.4.4',
91
  'php_version' => phpversion(),
92
  'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
93
  'wc_version' => function_exists('WC') ? WC()->version : null,
87
  return (object) array(
88
  'repo' => 'master',
89
  'environment' => 'production', // staging or production
90
+ 'version' => '2.4.5',
91
  'php_version' => phpversion(),
92
  'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
93
  'wc_version' => function_exists('WC') ? WC()->version : null,
includes/api/class-mailchimp-api.php CHANGED
@@ -808,8 +808,10 @@ class MailChimp_WooCommerce_MailChimpApi
808
  try {
809
  return (bool) $this->delete("ecommerce/stores/$store_id");
810
  } catch (MailChimp_WooCommerce_Error $e) {
 
811
  return false;
812
  } catch (\Exception $e) {
 
813
  return false;
814
  }
815
  }
808
  try {
809
  return (bool) $this->delete("ecommerce/stores/$store_id");
810
  } catch (MailChimp_WooCommerce_Error $e) {
811
+ mailchimp_error("delete_store {$store_id}", $e->getMessage());
812
  return false;
813
  } catch (\Exception $e) {
814
+ mailchimp_error("delete_store {$store_id}", $e->getMessage());
815
  return false;
816
  }
817
  }
includes/class-mailchimp-woocommerce-rest-api.php CHANGED
@@ -21,12 +21,14 @@ class MailChimp_WooCommerce_Rest_Api
21
  register_rest_route(static::$namespace, '/ping', array(
22
  'methods' => 'GET',
23
  'callback' => array($this, 'ping'),
 
24
  ));
25
 
26
  // Right now we only have a survey disconnect endpoint.
27
  register_rest_route(static::$namespace, "/survey/disconnect", array(
28
  'methods' => 'POST',
29
  'callback' => array($this, 'post_disconnect_survey'),
 
30
  ));
31
 
32
  // Sync Stats
@@ -34,6 +36,7 @@ class MailChimp_WooCommerce_Rest_Api
34
  register_rest_route(static::$namespace, '/sync/stats', array(
35
  'methods' => 'GET',
36
  'callback' => array($this, 'get_sync_stats'),
 
37
  ));
38
  }
39
 
@@ -41,6 +44,7 @@ class MailChimp_WooCommerce_Rest_Api
41
  register_rest_route(static::$namespace, "/review-banner", array(
42
  'methods' => 'GET',
43
  'callback' => array($this, 'dismiss_review_banner'),
 
44
  ));
45
  }
46
 
21
  register_rest_route(static::$namespace, '/ping', array(
22
  'methods' => 'GET',
23
  'callback' => array($this, 'ping'),
24
+ 'permission_callback' => '__return_true',
25
  ));
26
 
27
  // Right now we only have a survey disconnect endpoint.
28
  register_rest_route(static::$namespace, "/survey/disconnect", array(
29
  'methods' => 'POST',
30
  'callback' => array($this, 'post_disconnect_survey'),
31
+ 'permission_callback' => '__return_true',
32
  ));
33
 
34
  // Sync Stats
36
  register_rest_route(static::$namespace, '/sync/stats', array(
37
  'methods' => 'GET',
38
  'callback' => array($this, 'get_sync_stats'),
39
+ 'permission_callback' => '__return_true',
40
  ));
41
  }
42
 
44
  register_rest_route(static::$namespace, "/review-banner", array(
45
  'methods' => 'GET',
46
  'callback' => array($this, 'dismiss_review_banner'),
47
+ 'permission_callback' => '__return_true',
48
  ));
49
  }
50
 
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.4.4
20
  * Author: Mailchimp
21
  * Author URI: https://mailchimp.com
22
  * License: GPL-2.0+
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.4.5
20
  * Author: Mailchimp
21
  * Author URI: https://mailchimp.com
22
  * License: GPL-2.0+