MailChimp for WooCommerce - Version 2.5.4

Version Description

Download this release

Release Info

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

Code changes from version 2.5.3 to 2.5.4

CHANGELOG.txt CHANGED
@@ -1,4 +1,8 @@
1
  == Changelog ==
 
 
 
 
2
  = 2.5.3 =
3
  * remove order_total and total_spent from customer submission
4
  = 2.5.2 =
1
  == Changelog ==
2
+ = 2.5.4 =
3
+ * enhanced api error parsing
4
+ * adds site transient for tracking cart
5
+ * tested for woocommerce v5.8
6
  = 2.5.3 =
7
  * remove order_total and total_spent from customer submission
8
  = 2.5.2 =
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: 5.8
7
- Stable tag: 2.5.3
8
  Requires PHP: 7.0
9
  WC requires at least: 3.5
10
- WC tested up to: 5.7
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,8 +78,10 @@ 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.5.3 =
82
- * remove order_total and total_spent from customer submission
 
 
83
 
84
  [Historical Changelog](https://raw.githubusercontent.com/mailchimp/mc-woocommerce/master/CHANGELOG.txt)
85
 
4
  Donate link: https://mailchimp.com
5
  Requires at least: 4.9
6
  Tested up to: 5.8
7
+ Stable tag: 2.5.4
8
  Requires PHP: 7.0
9
  WC requires at least: 3.5
10
+ WC tested up to: 5.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.5.4 =
82
+ * enhanced api error parsing
83
+ * adds site transient for tracking cart
84
+ * tested for woocommerce v5.8
85
 
86
  [Historical Changelog](https://raw.githubusercontent.com/mailchimp/mc-woocommerce/master/CHANGELOG.txt)
87
 
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.5.3',
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.5.4',
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
@@ -1850,16 +1850,20 @@ class MailChimp_WooCommerce_MailChimpApi
1850
  return $data;
1851
  }
1852
 
 
 
1853
  if ($http_code >= 400 && $http_code <= 500) {
1854
  if ($http_code == 403) {
1855
  throw new MailChimp_WooCommerce_RateLimitError();
1856
  }
1857
-
1858
- throw new MailChimp_WooCommerce_Error($data['title'] .' :: '.$data['detail'], (int) $data['status']);
 
1859
  }
1860
 
1861
  if ($http_code >= 500) {
1862
- throw new MailChimp_WooCommerce_ServerError($data['detail'], $data['status']);
 
1863
  }
1864
 
1865
  if (!is_array($data)) {
1850
  return $data;
1851
  }
1852
 
1853
+ $error_status = isset($data['status']) ? (int) $data['status'] : (int) $http_code;
1854
+
1855
  if ($http_code >= 400 && $http_code <= 500) {
1856
  if ($http_code == 403) {
1857
  throw new MailChimp_WooCommerce_RateLimitError();
1858
  }
1859
+ $error_message = isset($data['title']) ? $data['title'] : '';
1860
+ $error_message .= isset($data['detail']) ? $data['detail'] : '';
1861
+ throw new MailChimp_WooCommerce_Error($error_message, $error_status);
1862
  }
1863
 
1864
  if ($http_code >= 500) {
1865
+ $error_message = isset($data['detail']) ? $data['detail'] : '';
1866
+ throw new MailChimp_WooCommerce_ServerError($error_message, $error_status);
1867
  }
1868
 
1869
  if (!is_array($data)) {
includes/class-mailchimp-woocommerce-service.php CHANGED
@@ -877,6 +877,17 @@ class MailChimp_Service extends MailChimp_WooCommerce_Options
877
  {
878
  if (!$this->validated_cart_db) return false;
879
 
 
 
 
 
 
 
 
 
 
 
 
880
  global $wpdb;
881
 
882
  $table = "{$wpdb->prefix}mailchimp_carts";
@@ -891,6 +902,7 @@ class MailChimp_Service extends MailChimp_WooCommerce_Options
891
  $sql = $wpdb->prepare($statement, array(maybe_serialize($this->cart), $email, $user_id, $uid));
892
  try {
893
  $wpdb->query($sql);
 
894
  } catch (\Exception $e) {
895
  return false;
896
  }
@@ -903,6 +915,7 @@ class MailChimp_Service extends MailChimp_WooCommerce_Options
903
  'cart' => maybe_serialize($this->cart),
904
  'created_at' => gmdate('Y-m-d H:i:s', time()),
905
  ));
 
906
  } catch (\Exception $e) {
907
  return false;
908
  }
877
  {
878
  if (!$this->validated_cart_db) return false;
879
 
880
+ $hash = md5(strtolower($email));
881
+ $transient_key = "mailchimp-woocommerce-cart-{$hash}";
882
+
883
+ // let's set a transient here to block dup inserts
884
+ if (get_site_transient($transient_key)) {
885
+ return false;
886
+ }
887
+
888
+ // insert the transient
889
+ set_site_transient($transient_key, true, 5);
890
+
891
  global $wpdb;
892
 
893
  $table = "{$wpdb->prefix}mailchimp_carts";
902
  $sql = $wpdb->prepare($statement, array(maybe_serialize($this->cart), $email, $user_id, $uid));
903
  try {
904
  $wpdb->query($sql);
905
+ delete_site_transient($transient_key);
906
  } catch (\Exception $e) {
907
  return false;
908
  }
915
  'cart' => maybe_serialize($this->cart),
916
  'created_at' => gmdate('Y-m-d H:i:s', time()),
917
  ));
918
+ delete_site_transient($transient_key);
919
  } catch (\Exception $e) {
920
  return false;
921
  }
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.5.3
20
  * Author: Mailchimp
21
  * Author URI: https://mailchimp.com
22
  * License: GPL-2.0+
@@ -24,9 +24,9 @@
24
  * Text Domain: mailchimp-for-woocommerce
25
  * Domain Path: /languages
26
  * Requires at least: 4.9
27
- * Tested up to: 5.8
28
  * WC requires at least: 3.5
29
- * WC tested up to: 5.7
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.5.4
20
  * Author: Mailchimp
21
  * Author URI: https://mailchimp.com
22
  * License: GPL-2.0+
24
  * Text Domain: mailchimp-for-woocommerce
25
  * Domain Path: /languages
26
  * Requires at least: 4.9
27
+ * Tested up to: 5.7
28
  * WC requires at least: 3.5
29
+ * WC tested up to: 5.9
30
  */
31
 
32
  // If this file is called directly, abort.