MailChimp for WooCommerce - Version 2.1.4

Version Description

  • updated wordpress compatibility
  • updated sync details tab to show more informative stats
  • queue job processing performance enhancement
  • added an integrity check for queued jobs that were not getting processed
Download this release

Release Info

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

Code changes from version 2.1.3 to 2.1.4

Files changed (70) hide show
  1. LICENSE.txt +0 -0
  2. README.md +0 -0
  3. README.txt +8 -3
  4. admin/class-mailchimp-woocommerce-admin.php +0 -0
  5. admin/css/mailchimp-woocommerce-admin.css +0 -0
  6. admin/index.php +0 -0
  7. admin/js/mailchimp-woocommerce-admin.js +0 -0
  8. admin/partials/mailchimp-woocommerce-admin-tabs.php +6 -6
  9. admin/partials/tabs/api_key.php +0 -0
  10. admin/partials/tabs/campaign_defaults.php +0 -0
  11. admin/partials/tabs/logs.php +0 -0
  12. admin/partials/tabs/newsletter_settings.php +0 -0
  13. admin/partials/tabs/notices.php +0 -0
  14. admin/partials/tabs/store_info.php +0 -0
  15. admin/partials/tabs/store_sync.php +25 -28
  16. includes/api/assets/class-mailchimp-address.php +0 -0
  17. includes/api/assets/class-mailchimp-cart.php +0 -0
  18. includes/api/assets/class-mailchimp-customer.php +0 -0
  19. includes/api/assets/class-mailchimp-line-item.php +0 -0
  20. includes/api/assets/class-mailchimp-order.php +19 -0
  21. includes/api/assets/class-mailchimp-product-variation.php +0 -0
  22. includes/api/assets/class-mailchimp-product.php +0 -0
  23. includes/api/assets/class-mailchimp-promo-code.php +0 -0
  24. includes/api/assets/class-mailchimp-promo-rule.php +0 -0
  25. includes/api/assets/class-mailchimp-store.php +0 -0
  26. includes/api/class-mailchimp-api.php +1 -1
  27. includes/api/class-mailchimp-woocommerce-api.php +0 -0
  28. includes/api/class-mailchimp-woocommerce-create-list-submission.php +0 -0
  29. includes/api/class-mailchimp-woocommerce-transform-coupons.php +0 -0
  30. includes/api/class-mailchimp-woocommerce-transform-orders-wc3.php +18 -20
  31. includes/api/class-mailchimp-woocommerce-transform-orders.php +17 -21
  32. includes/api/class-mailchimp-woocommerce-transform-products.php +0 -0
  33. includes/api/errors/class-mailchimp-error.php +0 -0
  34. includes/api/errors/class-mailchimp-server-error.php +0 -0
  35. includes/api/helpers/class-mailchimp-woocommerce-api-currency-codes.php +0 -0
  36. includes/api/helpers/class-mailchimp-woocommerce-api-locales.php +0 -0
  37. includes/class-mailchimp-woocommerce-activator.php +0 -0
  38. includes/class-mailchimp-woocommerce-deactivator.php +0 -0
  39. includes/class-mailchimp-woocommerce-i18n.php +0 -0
  40. includes/class-mailchimp-woocommerce-loader.php +0 -0
  41. includes/class-mailchimp-woocommerce-newsletter.php +0 -0
  42. includes/class-mailchimp-woocommerce-options.php +0 -0
  43. includes/class-mailchimp-woocommerce-service.php +0 -0
  44. includes/class-mailchimp-woocommerce.php +0 -0
  45. includes/index.php +0 -0
  46. includes/processes/class-mailchimp-woocommerce-abstract-sync.php +0 -0
  47. includes/processes/class-mailchimp-woocommerce-cart-update.php +0 -0
  48. includes/processes/class-mailchimp-woocommerce-process-coupons.php +0 -0
  49. includes/processes/class-mailchimp-woocommerce-process-orders.php +0 -0
  50. includes/processes/class-mailchimp-woocommerce-process-products.php +0 -0
  51. includes/processes/class-mailchimp-woocommerce-single-coupon.php +0 -0
  52. includes/processes/class-mailchimp-woocommerce-single-order.php +29 -0
  53. includes/processes/class-mailchimp-woocommerce-single-product.php +0 -0
  54. includes/processes/class-mailchimp-woocommerce-user-submit.php +0 -0
  55. includes/vendor/queue.php +20 -6
  56. includes/vendor/queue/classes/cli/queue-command.php +0 -0
  57. includes/vendor/queue/classes/worker/wp-http-worker.php +3 -15
  58. includes/vendor/queue/classes/worker/wp-worker.php +2 -4
  59. includes/vendor/queue/classes/wp-job.php +0 -0
  60. includes/vendor/queue/classes/wp-queue.php +0 -0
  61. index.php +0 -0
  62. languages/mailchimp-woocommerce.pot +0 -0
  63. mailchimp-woocommerce.php +53 -13
  64. public/class-mailchimp-woocommerce-public.php +0 -0
  65. public/css/mailchimp-woocommerce-public.css +0 -0
  66. public/index.php +0 -0
  67. public/js/mailchimp-woocommerce-public.js +0 -0
  68. public/js/mailchimp-woocommerce-public.min.js +0 -0
  69. public/partials/mailchimp-woocommerce-public-display.php +0 -0
  70. uninstall.php +2 -1
LICENSE.txt CHANGED
File without changes
README.md CHANGED
File without changes
README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: ryanhungate, MailChimp
3
  Tags: ecommerce,email,workflows,mailchimp
4
  Donate link: https://mailchimp.com
5
  Requires at least: 4.3
6
- Tested up to: 4.8
7
- Stable tag: 4.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -29,7 +29,7 @@ This plugin supports our most powerful API 3.0 features, and is intended for use
29
 
30
  You can run this new integration at the same time as your current WooCommerce integration for MailChimp. However, data from the older integration will display separately in subscriber profiles, and can’t be used with e-commerce features that require API 3.0.
31
 
32
- This plugin is not compatible for WordPress.com users at this time.
33
 
34
  == Installation ==
35
  ###Before You Start
@@ -52,6 +52,11 @@ You’ll need to do a few things to connect your WooCommerce store to MailChimp.
52
  For more information on settings and configuration, please visit our Knowledge Base: [http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce](http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce)
53
 
54
  == Changelog ==
 
 
 
 
 
55
 
56
  = 2.1.3 =
57
  * Fix subscriber status for repeat transactional customers to stay transactional.
3
  Tags: ecommerce,email,workflows,mailchimp
4
  Donate link: https://mailchimp.com
5
  Requires at least: 4.3
6
+ Tested up to: 4.9
7
+ Stable tag: 2.1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
29
 
30
  You can run this new integration at the same time as your current WooCommerce integration for MailChimp. However, data from the older integration will display separately in subscriber profiles, and can’t be used with e-commerce features that require API 3.0.
31
 
32
+ WordPress.com compatibility is limited to Business tier users only.
33
 
34
  == Installation ==
35
  ###Before You Start
52
  For more information on settings and configuration, please visit our Knowledge Base: [http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce](http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce)
53
 
54
  == Changelog ==
55
+ = 2.1.4 =
56
+ * updated wordpress compatibility
57
+ * updated sync details tab to show more informative stats
58
+ * queue job processing performance enhancement
59
+ * added an integrity check for queued jobs that were not getting processed
60
 
61
  = 2.1.3 =
62
  * Fix subscriber status for repeat transactional customers to stay transactional.
admin/class-mailchimp-woocommerce-admin.php CHANGED
File without changes
admin/css/mailchimp-woocommerce-admin.css CHANGED
File without changes
admin/index.php CHANGED
File without changes
admin/js/mailchimp-woocommerce-admin.js CHANGED
File without changes
admin/partials/mailchimp-woocommerce-admin-tabs.php CHANGED
@@ -132,12 +132,12 @@ if (isset($options['mailchimp_api_key']) && $handler->hasValidApiKey()) {
132
 
133
  <?php if ($active_tab == 'sync'): ?>
134
  <h2 style="padding-top: 1em;">More Information</h2>
135
- <p>
136
- Need help to connect your store? Visit the MailChimp
137
- <a href="http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce/" target="_blank">Knowledge Base</a>.<br/>
138
- Want to tell us how we're doing?
139
- <a href="https://wordpress.org/support/plugin/mailchimp-for-woocommerce/reviews/" target="_blank">Leave a review on Wordpress.org</a>.
140
- </p>
141
  <?php endif; ?>
142
 
143
  </div><!-- /.wrap -->
132
 
133
  <?php if ($active_tab == 'sync'): ?>
134
  <h2 style="padding-top: 1em;">More Information</h2>
135
+ <ul>
136
+ <li>Have a larger store or having issues syncing? Consider using <a href="https://github.com/mailchimp/mc-woocommerce/issues/158" target="_blank">WP-CLI</a>.</li>
137
+ <li>Order and customer information will not sync if they contain an Amazon or generic email address.</li>
138
+ <li>Need help to connect your store? Visit the MailChimp <a href="http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce/" target="_blank">Knowledge Base</a>.</li>
139
+ <li>Want to tell us how we're doing? <a href="https://wordpress.org/support/plugin/mailchimp-for-woocommerce/reviews/" target="_blank">Leave a review on Wordpress.org</a>.</li>
140
+ </ul>
141
  <?php endif; ?>
142
 
143
  </div><!-- /.wrap -->
admin/partials/tabs/api_key.php CHANGED
File without changes
admin/partials/tabs/campaign_defaults.php CHANGED
File without changes
admin/partials/tabs/logs.php CHANGED
File without changes
admin/partials/tabs/newsletter_settings.php CHANGED
File without changes
admin/partials/tabs/notices.php CHANGED
File without changes
admin/partials/tabs/store_info.php CHANGED
File without changes
admin/partials/tabs/store_sync.php CHANGED
@@ -1,72 +1,69 @@
1
  <?php
2
-
3
  $mailchimp_total_products = $mailchimp_total_orders = 0;
4
  $store_id = mailchimp_get_store_id();
5
  $product_count = mailchimp_get_product_count();
6
  $order_count = mailchimp_get_order_count();
7
  $store_syncing = false;
8
  $last_updated_time = get_option('mailchimp-woocommerce-resource-last-updated');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  $account_name = 'n/a';
10
  $mailchimp_list_name = 'n/a';
11
-
12
  if (!empty($last_updated_time)) {
13
  $last_updated_time = mailchimp_date_local($last_updated_time);
14
  }
15
-
16
  if (($mailchimp_api = mailchimp_get_api()) && ($store = $mailchimp_api->getStore($store_id))) {
17
-
18
  $store_syncing = $store->isSyncing();
19
-
20
  if (($account_details = $handler->getAccountDetails())) {
21
  $account_name = $account_details['account_name'];
22
  }
23
-
24
  try {
25
  $products = $mailchimp_api->products($store_id, 1, 1);
26
  $mailchimp_total_products = $products['total_items'];
27
  if ($mailchimp_total_products > $product_count) $mailchimp_total_products = $product_count;
28
  } catch (\Exception $e) { $mailchimp_total_products = 0; }
29
-
30
  try {
31
  $orders = $mailchimp_api->orders($store_id, 1, 1);
32
  $mailchimp_total_orders = $orders['total_items'];
33
  if ($mailchimp_total_orders > $order_count) $mailchimp_total_orders = $order_count;
34
  } catch (\Exception $e) { $mailchimp_total_orders = 0; }
35
-
36
  $mailchimp_list_name = $handler->getListName();
37
  }
38
  ?>
39
 
40
  <input type="hidden" name="mailchimp_active_settings_tab" value="store_sync"/>
41
 
42
- <?php if($store_syncing): ?>
43
- <h2 style="padding-top: 1em;">Sync Progress</h2>
44
- <?php endif; ?>
45
 
46
- <?php if(!$store_syncing): ?>
47
- <h2 style="padding-top: 1em;">Sync Status</h2>
48
  <?php endif; ?>
49
 
50
- <p>
51
- <strong>Account Connected:</strong> <?php echo $account_name; ?>
52
- </p>
53
-
54
- <p>
55
- <strong>List Connected:</strong> <?php echo $mailchimp_list_name; ?>
56
- </p>
57
-
58
- <p>
59
- <strong>Products:</strong> <?php echo $mailchimp_total_products; ?>/<?php echo $product_count; ?>
60
- </p>
61
-
62
- <p>
63
- <strong>Orders:</strong> <?php echo $mailchimp_total_orders; ?>/<?php echo $order_count; ?>
64
- </p>
65
 
66
  <?php if ($last_updated_time): ?>
67
  <p><strong>Last Updated:</strong> <i><?php echo $last_updated_time->format('D, M j, Y g:i A'); ?></i></p>
68
  <?php endif; ?>
69
 
 
 
 
 
 
70
  <?php if($mailchimp_api && (!$store_syncing || isset($_GET['resync']) && $_GET['resync'] === '1')): ?>
71
  <h2 style="padding-top: 1em;">Advanced</h2>
72
  <p>
1
  <?php
 
2
  $mailchimp_total_products = $mailchimp_total_orders = 0;
3
  $store_id = mailchimp_get_store_id();
4
  $product_count = mailchimp_get_product_count();
5
  $order_count = mailchimp_get_order_count();
6
  $store_syncing = false;
7
  $last_updated_time = get_option('mailchimp-woocommerce-resource-last-updated');
8
+ $sync_started_at = get_option('mailchimp-woocommerce-sync.started_at');
9
+ if (!empty($sync_started_at)) {
10
+ $sync_started_at = mailchimp_date_local($sync_started_at);
11
+ } else {
12
+ $sync_started_at = new \DateTime();
13
+ }
14
+
15
+ $sync_completed_at = get_option('mailchimp-woocommerce-sync.completed_at');
16
+ if (!empty($sync_completed_at)) {
17
+ $sync_completed_at = mailchimp_date_local($sync_completed_at);
18
+ } else {
19
+ $sync_completed_at = false;
20
+ }
21
+
22
  $account_name = 'n/a';
23
  $mailchimp_list_name = 'n/a';
 
24
  if (!empty($last_updated_time)) {
25
  $last_updated_time = mailchimp_date_local($last_updated_time);
26
  }
 
27
  if (($mailchimp_api = mailchimp_get_api()) && ($store = $mailchimp_api->getStore($store_id))) {
 
28
  $store_syncing = $store->isSyncing();
 
29
  if (($account_details = $handler->getAccountDetails())) {
30
  $account_name = $account_details['account_name'];
31
  }
 
32
  try {
33
  $products = $mailchimp_api->products($store_id, 1, 1);
34
  $mailchimp_total_products = $products['total_items'];
35
  if ($mailchimp_total_products > $product_count) $mailchimp_total_products = $product_count;
36
  } catch (\Exception $e) { $mailchimp_total_products = 0; }
 
37
  try {
38
  $orders = $mailchimp_api->orders($store_id, 1, 1);
39
  $mailchimp_total_orders = $orders['total_items'];
40
  if ($mailchimp_total_orders > $order_count) $mailchimp_total_orders = $order_count;
41
  } catch (\Exception $e) { $mailchimp_total_orders = 0; }
 
42
  $mailchimp_list_name = $handler->getListName();
43
  }
44
  ?>
45
 
46
  <input type="hidden" name="mailchimp_active_settings_tab" value="store_sync"/>
47
 
48
+ <h2 style="padding-top: 1em;">Sync Information</h2>
 
 
49
 
50
+ <?php if ($sync_started_at): ?>
51
+ <p><strong>Started:</strong> <i><?php echo $sync_started_at->format('D, M j, Y g:i A'); ?></i></p>
52
  <?php endif; ?>
53
 
54
+ <?php if ($sync_completed_at): ?>
55
+ <p><strong>Finished:</strong> <i><?php echo $sync_completed_at->format('D, M j, Y g:i A'); ?></i></p>
56
+ <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  <?php if ($last_updated_time): ?>
59
  <p><strong>Last Updated:</strong> <i><?php echo $last_updated_time->format('D, M j, Y g:i A'); ?></i></p>
60
  <?php endif; ?>
61
 
62
+ <p><strong>Account Connected:</strong> <?php echo $account_name; ?></p>
63
+ <p><strong>List Connected:</strong> <?php echo $mailchimp_list_name; ?></p>
64
+ <p><strong>Products Synced:</strong> <?php echo $mailchimp_total_products; ?></p>
65
+ <p><strong>Orders Synced:</strong> <?php echo $mailchimp_total_orders; ?></p>
66
+
67
  <?php if($mailchimp_api && (!$store_syncing || isset($_GET['resync']) && $_GET['resync'] === '1')): ?>
68
  <h2 style="padding-top: 1em;">Advanced</h2>
69
  <p>
includes/api/assets/class-mailchimp-address.php CHANGED
File without changes
includes/api/assets/class-mailchimp-cart.php CHANGED
File without changes
includes/api/assets/class-mailchimp-customer.php CHANGED
File without changes
includes/api/assets/class-mailchimp-line-item.php CHANGED
File without changes
includes/api/assets/class-mailchimp-order.php CHANGED
@@ -30,6 +30,25 @@ class MailChimp_WooCommerce_Order
30
  protected $lines = array();
31
  protected $confirm_and_paid = false;
32
  protected $promos = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  /**
35
  * @return array
30
  protected $lines = array();
31
  protected $confirm_and_paid = false;
32
  protected $promos = [];
33
+ protected $is_amazon_order = false;
34
+
35
+ /**
36
+ * @param $bool
37
+ * @return $this
38
+ */
39
+ public function flagAsAmazonOrder($bool)
40
+ {
41
+ $this->is_amazon_order = (bool) $bool;
42
+ return $this;
43
+ }
44
+
45
+ /**
46
+ * @return bool
47
+ */
48
+ public function isFlaggedAsAmazonOrder()
49
+ {
50
+ return (bool) $this->is_amazon_order;
51
+ }
52
 
53
  /**
54
  * @return array
includes/api/assets/class-mailchimp-product-variation.php CHANGED
File without changes
includes/api/assets/class-mailchimp-product.php CHANGED
File without changes
includes/api/assets/class-mailchimp-promo-code.php CHANGED
File without changes
includes/api/assets/class-mailchimp-promo-rule.php CHANGED
File without changes
includes/api/assets/class-mailchimp-store.php CHANGED
File without changes
includes/api/class-mailchimp-api.php CHANGED
@@ -1246,7 +1246,7 @@ class MailChimp_WooCommerce_MailChimpApi
1246
  CURLINFO_HEADER_OUT => true,
1247
  CURLOPT_HTTPHEADER => array_merge(array(
1248
  'content-type: application/json',
1249
- "user-agent: MailChimp for WooCommerce/{$env->version}; WordPress/{$env->wp_version}",
1250
  ), $headers)
1251
  );
1252
  }
1246
  CURLINFO_HEADER_OUT => true,
1247
  CURLOPT_HTTPHEADER => array_merge(array(
1248
  'content-type: application/json',
1249
+ "user-agent: MailChimp for WooCommerce/{$env->version}; PHP/{$env->php_version}; WordPress/{$env->wp_version}; Woo/{$env->wc_version};",
1250
  ), $headers)
1251
  );
1252
  }
includes/api/class-mailchimp-woocommerce-api.php CHANGED
File without changes
includes/api/class-mailchimp-woocommerce-create-list-submission.php CHANGED
File without changes
includes/api/class-mailchimp-woocommerce-transform-coupons.php CHANGED
File without changes
includes/api/class-mailchimp-woocommerce-transform-orders-wc3.php CHANGED
@@ -33,13 +33,17 @@ class MailChimp_WooCommerce_Transform_Orders
33
  if ((($orders = $this->getOrderPosts($page, $limit)) && !empty($orders))) {
34
  foreach ($orders as $post) {
35
  $response->count++;
 
36
  if ($post->post_status === 'auto-draft') {
37
  $response->drafts++;
38
  continue;
39
  }
40
 
41
- $response->valid++;
42
- $response->items[] = $this->transform($post);
 
 
 
43
  }
44
  }
45
 
@@ -58,6 +62,11 @@ class MailChimp_WooCommerce_Transform_Orders
58
 
59
  $order = new MailChimp_WooCommerce_Order();
60
 
 
 
 
 
 
61
  $order->setId($woo->get_order_number());
62
 
63
  // if we have a campaign id let's set it now.
@@ -284,33 +293,22 @@ class MailChimp_WooCommerce_Transform_Orders
284
  */
285
  public function getOrderPosts($page = 1, $posts = 5)
286
  {
287
- $orders = get_posts(array(
288
- 'post_type' => wc_get_order_types(),
289
  'post_status' => array_keys(wc_get_order_statuses()),
290
  'posts_per_page' => $posts,
291
  'paged' => $page,
292
  'orderby' => 'id',
293
- 'order' => 'ASC'
294
- ));
295
 
 
296
  if (empty($orders)) {
297
  sleep(2);
298
-
299
- $orders = get_posts(array(
300
- 'post_type' => wc_get_order_types(),
301
- 'post_status' => array_keys(wc_get_order_statuses()),
302
- 'posts_per_page' => $posts,
303
- 'paged' => $page,
304
- 'orderby' => 'id',
305
- 'order' => 'ASC'
306
- ));
307
-
308
- if (empty($orders)) {
309
- return false;
310
- }
311
  }
312
 
313
- return $orders;
314
  }
315
 
316
  /**
33
  if ((($orders = $this->getOrderPosts($page, $limit)) && !empty($orders))) {
34
  foreach ($orders as $post) {
35
  $response->count++;
36
+
37
  if ($post->post_status === 'auto-draft') {
38
  $response->drafts++;
39
  continue;
40
  }
41
 
42
+ $order = $this->transform($post);
43
+ if (!$order->isFlaggedAsAmazonOrder()) {
44
+ $response->valid++;
45
+ $response->items[] = $order;
46
+ }
47
  }
48
  }
49
 
62
 
63
  $order = new MailChimp_WooCommerce_Order();
64
 
65
+ // just skip these altogether because we can't submit any amazon orders anyway.
66
+ if (mailchimp_string_contains($woo->get_billing_email(), '@marketplace.amazon.com')) {
67
+ return $order->flagAsAmazonOrder(true);
68
+ }
69
+
70
  $order->setId($woo->get_order_number());
71
 
72
  // if we have a campaign id let's set it now.
293
  */
294
  public function getOrderPosts($page = 1, $posts = 5)
295
  {
296
+ $params = array(
297
+ 'post_type' => wc_get_order_types(),
298
  'post_status' => array_keys(wc_get_order_statuses()),
299
  'posts_per_page' => $posts,
300
  'paged' => $page,
301
  'orderby' => 'id',
302
+ 'order' => 'ASC',
303
+ );
304
 
305
+ $orders = get_posts($params);
306
  if (empty($orders)) {
307
  sleep(2);
308
+ $orders = get_posts($params);
 
 
 
 
 
 
 
 
 
 
 
 
309
  }
310
 
311
+ return empty($orders) ? false : $orders;
312
  }
313
 
314
  /**
includes/api/class-mailchimp-woocommerce-transform-orders.php CHANGED
@@ -39,8 +39,11 @@ class MailChimp_WooCommerce_Transform_Orders
39
  continue;
40
  }
41
 
42
- $response->valid++;
43
- $response->items[] = $this->transform($post);
 
 
 
44
  }
45
  }
46
 
@@ -80,6 +83,11 @@ class MailChimp_WooCommerce_Transform_Orders
80
 
81
  $order->setId($woo->get_order_number());
82
 
 
 
 
 
 
83
  // if we have a campaign id let's set it now.
84
  if (!empty($this->campaign_id)) {
85
  $order->setCampaignId($this->campaign_id);
@@ -358,34 +366,22 @@ class MailChimp_WooCommerce_Transform_Orders
358
  */
359
  public function getOrderPosts($page = 1, $posts = 5)
360
  {
361
- $orders = get_posts(array(
362
  'post_type' => 'shop_order',
363
- //'post_status' => 'publish',
364
  'posts_per_page' => $posts,
365
  'paged' => $page,
366
  'orderby' => 'id',
367
- 'order' => 'ASC'
368
- ));
369
 
370
- if (empty($orders)) {
371
 
 
372
  sleep(2);
373
-
374
- $orders = get_posts(array(
375
- 'post_type' => 'shop_order',
376
- //'post_status' => 'publish',
377
- 'posts_per_page' => $posts,
378
- 'paged' => $page,
379
- 'orderby' => 'id',
380
- 'order' => 'ASC'
381
- ));
382
-
383
- if (empty($orders)) {
384
- return false;
385
- }
386
  }
387
 
388
- return $orders;
389
  }
390
 
391
  /**
39
  continue;
40
  }
41
 
42
+ $order = $this->transform($post);
43
+ if (!$order->isFlaggedAsAmazonOrder()) {
44
+ $response->valid++;
45
+ $response->items[] = $order;
46
+ }
47
  }
48
  }
49
 
83
 
84
  $order->setId($woo->get_order_number());
85
 
86
+ // just skip these altogether because we can't submit any amazon orders anyway.
87
+ if (mailchimp_string_contains($woo->billing_email, '@marketplace.amazon.com')) {
88
+ return $order->flagAsAmazonOrder(true);
89
+ }
90
+
91
  // if we have a campaign id let's set it now.
92
  if (!empty($this->campaign_id)) {
93
  $order->setCampaignId($this->campaign_id);
366
  */
367
  public function getOrderPosts($page = 1, $posts = 5)
368
  {
369
+ $params = array(
370
  'post_type' => 'shop_order',
 
371
  'posts_per_page' => $posts,
372
  'paged' => $page,
373
  'orderby' => 'id',
374
+ 'order' => 'ASC',
375
+ );
376
 
377
+ $orders = get_posts($params);
378
 
379
+ if (empty($orders)) {
380
  sleep(2);
381
+ $orders = get_posts($params);
 
 
 
 
 
 
 
 
 
 
 
 
382
  }
383
 
384
+ return empty($orders) ? false : $orders;
385
  }
386
 
387
  /**
includes/api/class-mailchimp-woocommerce-transform-products.php CHANGED
File without changes
includes/api/errors/class-mailchimp-error.php CHANGED
File without changes
includes/api/errors/class-mailchimp-server-error.php CHANGED
File without changes
includes/api/helpers/class-mailchimp-woocommerce-api-currency-codes.php CHANGED
File without changes
includes/api/helpers/class-mailchimp-woocommerce-api-locales.php CHANGED
File without changes
includes/class-mailchimp-woocommerce-activator.php CHANGED
File without changes
includes/class-mailchimp-woocommerce-deactivator.php CHANGED
File without changes
includes/class-mailchimp-woocommerce-i18n.php CHANGED
File without changes
includes/class-mailchimp-woocommerce-loader.php CHANGED
File without changes
includes/class-mailchimp-woocommerce-newsletter.php CHANGED
File without changes
includes/class-mailchimp-woocommerce-options.php CHANGED
File without changes
includes/class-mailchimp-woocommerce-service.php CHANGED
File without changes
includes/class-mailchimp-woocommerce.php CHANGED
File without changes
includes/index.php CHANGED
File without changes
includes/processes/class-mailchimp-woocommerce-abstract-sync.php CHANGED
File without changes
includes/processes/class-mailchimp-woocommerce-cart-update.php CHANGED
File without changes
includes/processes/class-mailchimp-woocommerce-process-coupons.php CHANGED
File without changes
includes/processes/class-mailchimp-woocommerce-process-orders.php CHANGED
File without changes
includes/processes/class-mailchimp-woocommerce-process-products.php CHANGED
File without changes
includes/processes/class-mailchimp-woocommerce-single-coupon.php CHANGED
File without changes
includes/processes/class-mailchimp-woocommerce-single-order.php CHANGED
@@ -56,6 +56,12 @@ class MailChimp_WooCommerce_Single_Order extends WP_Job
56
  return false;
57
  }
58
 
 
 
 
 
 
 
59
  $job = new MailChimp_WooCommerce_Transform_Orders();
60
  $api = new MailChimp_WooCommerce_MailChimpApi($options['mailchimp_api_key']);
61
 
@@ -86,6 +92,12 @@ class MailChimp_WooCommerce_Single_Order extends WP_Job
86
  // transform the order
87
  $order = $job->transform($order_post);
88
 
 
 
 
 
 
 
89
  // if the order is in failed or cancelled status - and it's brand new, we shouldn't submit it.
90
  if ($call === 'addStoreOrder' && in_array($order->getFinancialStatus(), array('failed', 'cancelled'))) {
91
  return false;
@@ -205,5 +217,22 @@ class MailChimp_WooCommerce_Single_Order extends WP_Job
205
  return false;
206
  }
207
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  }
209
 
56
  return false;
57
  }
58
 
59
+ // skip amazon orders
60
+ if ($this->isAmazonOrder()) {
61
+ mailchimp_log('validation.amazon', "Order #{$woo_order_number} was placed through Amazon. Skipping!");
62
+ return false;
63
+ }
64
+
65
  $job = new MailChimp_WooCommerce_Transform_Orders();
66
  $api = new MailChimp_WooCommerce_MailChimpApi($options['mailchimp_api_key']);
67
 
92
  // transform the order
93
  $order = $job->transform($order_post);
94
 
95
+ // skip amazon orders
96
+ if ($order->isFlaggedAsAmazonOrder()) {
97
+ mailchimp_log('validation.amazon', "Order #{$woo_order_number} was placed through Amazon. Skipping!");
98
+ return false;
99
+ }
100
+
101
  // if the order is in failed or cancelled status - and it's brand new, we shouldn't submit it.
102
  if ($call === 'addStoreOrder' && in_array($order->getFinancialStatus(), array('failed', 'cancelled'))) {
103
  return false;
217
  return false;
218
  }
219
  }
220
+
221
+ /**
222
+ * @return bool
223
+ */
224
+ public function isAmazonOrder()
225
+ {
226
+ try {
227
+ if (empty($this->order_id) || !($order_post = get_post($this->order_id))) {
228
+ return false;
229
+ }
230
+ $woo = new WC_Order($order_post);
231
+ // just skip these altogether because we can't submit any amazon orders anyway.
232
+ return mailchimp_string_contains($woo->get_billing_email(), '@marketplace.amazon.com');
233
+ } catch (\Exception $e) {
234
+ return false;
235
+ }
236
+ }
237
  }
238
 
includes/processes/class-mailchimp-woocommerce-single-product.php CHANGED
File without changes
includes/processes/class-mailchimp-woocommerce-user-submit.php CHANGED
File without changes
includes/vendor/queue.php CHANGED
@@ -19,15 +19,29 @@ global $wp_queue;
19
  $wp_queue = new WP_Queue();
20
 
21
  // Add WP CLI commands
22
- if ( defined( 'WP_CLI' ) && WP_CLI ) {
23
- require_once $queue_folder_path . 'queue/classes/cli/queue-command.php';
24
- WP_CLI::add_command( 'queue', 'Queue_Command' );
 
 
25
  }
26
 
27
- // Instantiate HTTP queue worker
28
- new WP_Http_Worker($wp_queue);
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
- if ( ! function_exists( 'wp_queue' ) ) {
31
  /**
32
  * WP queue.
33
  *
19
  $wp_queue = new WP_Queue();
20
 
21
  // Add WP CLI commands
22
+ if (defined( 'WP_CLI' ) && WP_CLI) {
23
+ try {
24
+ require_once $queue_folder_path . 'queue/classes/cli/queue-command.php';
25
+ WP_CLI::add_command( 'queue', 'Queue_Command' );
26
+ } catch (\Exception $e) {}
27
  }
28
 
29
+ // if we're not running in the console, and the http_worker is not running
30
+ if (!mailchimp_running_in_console() && !mailchimp_http_worker_is_running()) {
31
+ try {
32
+ // fire up the http worker container
33
+ new WP_Http_Worker($wp_queue);
34
+ // if we do not have a site transient for the queue listener and we have available jobs
35
+ if (!get_site_transient('http_worker_queue_listen') && $wp_queue->available_jobs()) {
36
+ // set the site transient to expire in 60 seconds so this will not happen too many times.
37
+ set_site_transient( 'http_worker_queue_listen', microtime(), 60);
38
+ // call the http worker manually
39
+ mailchimp_call_http_worker_manually();
40
+ }
41
+ } catch (\Exception $e) {}
42
+ }
43
 
44
+ if (!function_exists( 'wp_queue')) {
45
  /**
46
  * WP queue.
47
  *
includes/vendor/queue/classes/cli/queue-command.php CHANGED
File without changes
includes/vendor/queue/classes/worker/wp-http-worker.php CHANGED
@@ -295,21 +295,9 @@ if ( ! class_exists( 'WP_Http_Worker' ) ) {
295
  * disabled and already scheduled.
296
  */
297
  public function maybe_schedule_cron() {
298
- if ( $this->is_http_worker_disabled() ) {
299
- die('http worker is disabled');
300
- // Remove health check cron event, if scheduled
301
- $timestamp = wp_next_scheduled( 'http_worker_cron' );
302
-
303
- if ( wp_next_scheduled( 'http_worker_cron' ) ) {
304
- wp_unschedule_event( $timestamp, 'http_worker_cron' );
305
- }
306
-
307
- return;
308
- }
309
-
310
- if ( ! wp_next_scheduled( 'http_worker_cron' ) ) {
311
- // Schedule health check
312
- wp_schedule_event( time(), 'http_worker_cron_interval', 'http_worker_cron' );
313
  }
314
  }
315
 
295
  * disabled and already scheduled.
296
  */
297
  public function maybe_schedule_cron() {
298
+ if ( !$this->is_http_worker_disabled() && ! wp_next_scheduled( 'http_worker_cron' )) {
299
+ // Schedule health check
300
+ wp_schedule_event( time(), 'http_worker_cron_interval', 'http_worker_cron' );
 
 
 
 
 
 
 
 
 
 
 
 
301
  }
302
  }
303
 
includes/vendor/queue/classes/worker/wp-worker.php CHANGED
@@ -44,7 +44,6 @@ if ( ! class_exists( 'WP_Worker' ) ) {
44
  $job = $this->queue->get_next_job();
45
 
46
  if (empty($job)) {
47
- mailchimp_debug('wp-worker@process_next_job', 'empty job data');
48
  return true;
49
  }
50
 
@@ -54,7 +53,9 @@ if ( ! class_exists( 'WP_Worker' ) ) {
54
  $this->payload->set_job( $job );
55
 
56
  try {
 
57
  $this->payload->handle();
 
58
 
59
  if ( $this->payload->is_released() ) {
60
  // Job manually released, release back onto queue
@@ -71,11 +72,8 @@ if ( ! class_exists( 'WP_Worker' ) ) {
71
  $this->queue->delete( $job );
72
  }
73
  } catch ( Exception $e ) {
74
-
75
  mailchimp_log('queue.error', "{$e->getMessage()} on {$e->getLine()} in {$e->getFile()}", array('job' => get_class($this->payload)));
76
-
77
  $this->queue->release( $job );
78
-
79
  return false;
80
  }
81
 
44
  $job = $this->queue->get_next_job();
45
 
46
  if (empty($job)) {
 
47
  return true;
48
  }
49
 
53
  $this->payload->set_job( $job );
54
 
55
  try {
56
+ //mailchimp_debug('mc_events', 'wp_worker.process_next_job.start', array('payload' => $this->payload));
57
  $this->payload->handle();
58
+ //mailchimp_debug('mc_events', 'wp_worker.process_next_job.complete', array('payload' => $this->payload));
59
 
60
  if ( $this->payload->is_released() ) {
61
  // Job manually released, release back onto queue
72
  $this->queue->delete( $job );
73
  }
74
  } catch ( Exception $e ) {
 
75
  mailchimp_log('queue.error', "{$e->getMessage()} on {$e->getLine()} in {$e->getFile()}", array('job' => get_class($this->payload)));
 
76
  $this->queue->release( $job );
 
77
  return false;
78
  }
79
 
includes/vendor/queue/classes/wp-job.php CHANGED
File without changes
includes/vendor/queue/classes/wp-queue.php CHANGED
File without changes
index.php CHANGED
File without changes
languages/mailchimp-woocommerce.pot CHANGED
File without changes
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: MailChimp - WooCommerce plugin
19
- * Version: 2.1.3
20
  * Author: MailChimp
21
  * Author URI: https://mailchimp.com
22
  * License: GPL-2.0+
@@ -24,7 +24,7 @@
24
  * Text Domain: mailchimp-woocommerce
25
  * Domain Path: /languages
26
  * Requires at least: 4.4
27
- * Tested up to: 4.9
28
  */
29
 
30
  // If this file is called directly, abort.
@@ -43,7 +43,8 @@ function mailchimp_environment_variables() {
43
  return (object) array(
44
  'repo' => 'master',
45
  'environment' => 'production',
46
- 'version' => '2.1.3',
 
47
  'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
48
  'wc_version' => class_exists('WC') ? WC()->version : null,
49
  'logging' => ($o && is_array($o) && isset($o['mailchimp_logging'])) ? $o['mailchimp_logging'] : 'none',
@@ -403,16 +404,44 @@ function mailchimp_get_connected_site_script_fragment() {
403
  return get_option('mailchimp-woocommerce-script_fragment', false);
404
  }
405
 
406
- register_activation_hook( __FILE__, 'activate_mailchimp_woocommerce' );
 
 
 
 
 
407
 
408
- // cancelling out the deactivation hook code for now.
409
- //register_deactivation_hook( __FILE__, 'deactivate_mailchimp_woocommerce' );
 
 
 
 
410
 
411
  /**
412
- * The core plugin class that is used to define internationalization,
413
- * admin-specific hooks, and public-facing site hooks.
414
  */
415
- require plugin_dir_path( __FILE__ ) . 'includes/class-mailchimp-woocommerce.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
 
417
  /**
418
  *
@@ -439,8 +468,19 @@ function mailchimp_woocommerce_add_meta_tags() {
439
  echo '<meta name="referrer" content="always"/>';
440
  }
441
 
442
- if (mailchimp_check_woocommerce_plugin_status()) {
443
- add_action('wp_head', 'mailchimp_woocommerce_add_meta_tags');
444
- /** Add all the MailChimp hooks. */
445
- run_mailchimp_woocommerce();
 
 
 
 
 
 
 
 
 
446
  }
 
 
16
  * Plugin Name: MailChimp for WooCommerce
17
  * Plugin URI: https://mailchimp.com/connect-your-store/
18
  * Description: MailChimp - WooCommerce plugin
19
+ * Version: 2.1.4
20
  * Author: MailChimp
21
  * Author URI: https://mailchimp.com
22
  * License: GPL-2.0+
24
  * Text Domain: mailchimp-woocommerce
25
  * Domain Path: /languages
26
  * Requires at least: 4.4
27
+ * Tested up to: 4.9.2
28
  */
29
 
30
  // If this file is called directly, abort.
43
  return (object) array(
44
  'repo' => 'master',
45
  'environment' => 'production',
46
+ 'version' => '2.1.4',
47
+ 'php_version' => phpversion(),
48
  'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
49
  'wc_version' => class_exists('WC') ? WC()->version : null,
50
  'logging' => ($o && is_array($o) && isset($o['mailchimp_logging'])) ? $o['mailchimp_logging'] : 'none',
404
  return get_option('mailchimp-woocommerce-script_fragment', false);
405
  }
406
 
407
+ /**
408
+ * @return bool
409
+ */
410
+ function mailchimp_running_in_console() {
411
+ return (bool) (defined( 'DISABLE_WP_HTTP_WORKER' ) && true === DISABLE_WP_HTTP_WORKER);
412
+ }
413
 
414
+ /**
415
+ * @return bool
416
+ */
417
+ function mailchimp_http_worker_is_running() {
418
+ return (bool) get_site_transient('http_worker_lock');
419
+ }
420
 
421
  /**
422
+ * @return array|WP_Error
 
423
  */
424
+ function mailchimp_call_http_worker_manually() {
425
+ $action = 'http_worker';
426
+ $query_args = apply_filters('http_worker_query_args', array(
427
+ 'action' => $action,
428
+ 'nonce' => wp_create_nonce($action),
429
+ ));
430
+ $query_url = apply_filters('http_worker_query_url', admin_url('admin-ajax.php'));
431
+ $post_args = apply_filters('http_worker_post_args', array(
432
+ 'timeout' => 0.01,
433
+ 'blocking' => false,
434
+ 'cookies' => $_COOKIE,
435
+ 'sslverify' => apply_filters('https_local_ssl_verify', false),
436
+ ));
437
+ $url = add_query_arg($query_args, $query_url);
438
+ return wp_remote_post(esc_url_raw($url), $post_args);
439
+ }
440
+
441
+ register_activation_hook( __FILE__, 'activate_mailchimp_woocommerce' );
442
+
443
+ // cancelling out the deactivation hook code for now.
444
+ //register_deactivation_hook( __FILE__, 'deactivate_mailchimp_woocommerce' );
445
 
446
  /**
447
  *
468
  echo '<meta name="referrer" content="always"/>';
469
  }
470
 
471
+ function mailchimp_on_all_plugins_loaded() {
472
+ if (mailchimp_check_woocommerce_plugin_status()) {
473
+
474
+ /**
475
+ * The core plugin class that is used to define internationalization,
476
+ * admin-specific hooks, and public-facing site hooks.
477
+ */
478
+ require plugin_dir_path( __FILE__ ) . 'includes/class-mailchimp-woocommerce.php';
479
+
480
+ add_action('wp_head', 'mailchimp_woocommerce_add_meta_tags');
481
+ /** Add all the MailChimp hooks. */
482
+ run_mailchimp_woocommerce();
483
+ }
484
  }
485
+
486
+ add_action( 'plugins_loaded', 'mailchimp_on_all_plugins_loaded' );
public/class-mailchimp-woocommerce-public.php CHANGED
File without changes
public/css/mailchimp-woocommerce-public.css CHANGED
File without changes
public/index.php CHANGED
File without changes
public/js/mailchimp-woocommerce-public.js CHANGED
File without changes
public/js/mailchimp-woocommerce-public.min.js CHANGED
File without changes
public/partials/mailchimp-woocommerce-public-display.php CHANGED
File without changes
uninstall.php CHANGED
@@ -42,7 +42,8 @@ if (!function_exists('mailchimp_environment_variables')) {
42
  return (object) array(
43
  'repo' => 'master',
44
  'environment' => 'production',
45
- 'version' => '2.1.2',
 
46
  'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
47
  'wc_version' => class_exists('WC') ? WC()->version : null,
48
  'logging' => ($o && is_array($o) && isset($o['mailchimp_logging'])) ? $o['mailchimp_logging'] : 'none',
42
  return (object) array(
43
  'repo' => 'master',
44
  'environment' => 'production',
45
+ 'version' => '2.1.4',
46
+ 'php_version' => phpversion(),
47
  'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
48
  'wc_version' => class_exists('WC') ? WC()->version : null,
49
  'logging' => ($o && is_array($o) && isset($o['mailchimp_logging'])) ? $o['mailchimp_logging'] : 'none',