MailChimp for WooCommerce - Version 1.1.0

Version Description

  • Fix for persisting opt-in status
  • Pass order URLs to MailChimp
  • Pass partial refund status to MailChimp
Download this release

Release Info

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

Code changes from version 1.0.9 to 1.1.0

README.txt CHANGED
@@ -1,4 +1,4 @@
1
- === WooCommerce MailChimp® ===
2
  Contributors: ryanhungate, MailChimp
3
  Tags: ecommerce,email,workflows,mailchimp
4
  Donate link: https://mailchimp.com
@@ -49,6 +49,11 @@ You’ll need to do a few things to connect your WooCommerce store to MailChimp.
49
  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)
50
 
51
  == Changelog ==
 
 
 
 
 
52
  = 1.0.9 =
53
  * billing and shipping address support for orders
54
 
1
+ === MailChimp for WooCommerce ===
2
  Contributors: ryanhungate, MailChimp
3
  Tags: ecommerce,email,workflows,mailchimp
4
  Donate link: https://mailchimp.com
49
  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)
50
 
51
  == Changelog ==
52
+ = 1.1.0 =
53
+ * Fix for persisting opt-in status
54
+ * Pass order URLs to MailChimp
55
+ * Pass partial refund status to MailChimp
56
+
57
  = 1.0.9 =
58
  * billing and shipping address support for orders
59
 
admin/class-mailchimp-woocommerce-admin.php CHANGED
@@ -673,7 +673,11 @@ class MailChimp_Woocommerce_Admin extends MailChimp_Woocommerce_Options {
673
  // set the basics
674
  $store->setName($this->array_get($data, 'store_name'));
675
  $store->setDomain(get_option('siteurl'));
676
- $store->setEmailAddress($this->array_get($data, 'campaign_from_email'));
 
 
 
 
677
  $store->setAddress($this->address($data));
678
  $store->setPhone($this->array_get($data, 'store_phone'));
679
  $store->setListId($list_id);
673
  // set the basics
674
  $store->setName($this->array_get($data, 'store_name'));
675
  $store->setDomain(get_option('siteurl'));
676
+
677
+ // don't know why we did this before
678
+ //$store->setEmailAddress($this->array_get($data, 'campaign_from_email'));
679
+ $store->setEmailAddress($this->array_get($data, 'admin_email'));
680
+
681
  $store->setAddress($this->address($data));
682
  $store->setPhone($this->array_get($data, 'store_phone'));
683
  $store->setListId($list_id);
changelog.md CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  ** 1.0.9 **
2
  * billing and shipping address support for orders
3
 
1
+ ** 1.1.0 **
2
+ * Fix for persisting opt-in status
3
+ * Pass order URLs to MailChimp
4
+ * Pass partial refund status to MailChimp
5
+
6
  ** 1.0.9 **
7
  * billing and shipping address support for orders
8
 
includes/api/assets/class-mailchimp-order.php CHANGED
@@ -24,6 +24,7 @@ class MailChimp_WooCommerce_Order
24
  protected $updated_at_foreign = null;
25
  protected $processed_at_foreign = null;
26
  protected $cancelled_at_foreign = null;
 
27
  protected $shipping_address = null;
28
  protected $billing_address = null;
29
  protected $lines = array();
@@ -47,6 +48,7 @@ class MailChimp_WooCommerce_Order
47
  'processed_at_foreign' => 'date',
48
  'updated_at_foreign' => 'date',
49
  'cancelled_at_foreign' => 'date',
 
50
  'lines' => 'required|array',
51
  );
52
  }
@@ -224,6 +226,25 @@ class MailChimp_WooCommerce_Order
224
  return $this;
225
  }
226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  /**
228
  * @return mixed
229
  */
@@ -396,6 +417,7 @@ class MailChimp_WooCommerce_Order
396
  'fulfillment_status' => (string) $this->getFulfillmentStatus(),
397
  'currency_code' => (string) $this->getCurrencyCode(),
398
  'order_total' => floatval($this->getOrderTotal()),
 
399
  'tax_total' => floatval($this->getTaxTotal()),
400
  'discount_total' => floatval($this->getDiscountTotal()),
401
  'shipping_total' => floatval($this->getShippingTotal()),
@@ -419,7 +441,7 @@ class MailChimp_WooCommerce_Order
419
  {
420
  $singles = array(
421
  'id', 'landing_site', 'campaign_id', 'financial_status', 'fulfillment_status',
422
- 'currency_code', 'order_total', 'tax_total', 'discount_total', 'processed_at_foreign',
423
  'cancelled_at_foreign', 'updated_at_foreign'
424
  );
425
 
24
  protected $updated_at_foreign = null;
25
  protected $processed_at_foreign = null;
26
  protected $cancelled_at_foreign = null;
27
+ protected $order_url = null;
28
  protected $shipping_address = null;
29
  protected $billing_address = null;
30
  protected $lines = array();
48
  'processed_at_foreign' => 'date',
49
  'updated_at_foreign' => 'date',
50
  'cancelled_at_foreign' => 'date',
51
+ 'order_url' => 'string',
52
  'lines' => 'required|array',
53
  );
54
  }
226
  return $this;
227
  }
228
 
229
+ /**
230
+ * @param $url
231
+ * @return $this
232
+ */
233
+ public function setOrderURL($url)
234
+ {
235
+ $this->order_url = $url;
236
+
237
+ return $this;
238
+ }
239
+
240
+ /**
241
+ * @return string
242
+ */
243
+ public function getOrderURL()
244
+ {
245
+ return $this->order_url;
246
+ }
247
+
248
  /**
249
  * @return mixed
250
  */
417
  'fulfillment_status' => (string) $this->getFulfillmentStatus(),
418
  'currency_code' => (string) $this->getCurrencyCode(),
419
  'order_total' => floatval($this->getOrderTotal()),
420
+ 'order_url' => (string) $this->getOrderURL(),
421
  'tax_total' => floatval($this->getTaxTotal()),
422
  'discount_total' => floatval($this->getDiscountTotal()),
423
  'shipping_total' => floatval($this->getShippingTotal()),
441
  {
442
  $singles = array(
443
  'id', 'landing_site', 'campaign_id', 'financial_status', 'fulfillment_status',
444
+ 'currency_code', 'order_total', 'order_url', 'tax_total', 'discount_total', 'processed_at_foreign',
445
  'cancelled_at_foreign', 'updated_at_foreign'
446
  );
447
 
includes/api/class-mailchimp-woocommerce-transform-orders.php CHANGED
@@ -91,6 +91,9 @@ class MailChimp_WooCommerce_Transform_Orders
91
  // set the total
92
  $order->setOrderTotal($woo->get_total());
93
 
 
 
 
94
  // if we have any tax
95
  $order->setTaxTotal($woo->get_total_tax());
96
 
@@ -138,6 +141,10 @@ class MailChimp_WooCommerce_Transform_Orders
138
  $order->addItem($item);
139
  }
140
 
 
 
 
 
141
  return $order;
142
  }
143
 
91
  // set the total
92
  $order->setOrderTotal($woo->get_total());
93
 
94
+ // set the order URL
95
+ $order->setOrderURL($woo->get_view_order_url());
96
+
97
  // if we have any tax
98
  $order->setTaxTotal($woo->get_total_tax());
99
 
141
  $order->addItem($item);
142
  }
143
 
144
+ //if (($refund = $woo->get_total_refunded()) && $refund > 0){
145
+ // this is where we would be altering the submission to tell us about the refund.
146
+ //}
147
+
148
  return $order;
149
  }
150
 
includes/class-mailchimp-woocommerce-service.php CHANGED
@@ -103,6 +103,18 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
103
  }
104
  }
105
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  /**
107
  * @return bool
108
  */
@@ -195,8 +207,13 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
195
  function handleUserUpdated($user_id, $old_user_data)
196
  {
197
  // only update this person if they were marked as subscribed before
198
- $is_subscribed = (bool) get_user_meta($user_id, 'mailchimp_woocommerce_is_subscribed', true);
199
- wp_queue(new MailChimp_WooCommerce_User_Submit($user_id, $is_subscribed, $old_user_data));
 
 
 
 
 
200
  }
201
 
202
  /**
103
  }
104
  }
105
 
106
+ /**
107
+ * @param $order_id
108
+ */
109
+ public function onPartiallyRefunded($order_id)
110
+ {
111
+ if ($this->hasOption('mailchimp_api_key')) {
112
+ $handler = new MailChimp_WooCommerce_Single_Order($order_id, null, null, null);
113
+ $handler->partially_refunded = true;
114
+ wp_queue($handler);
115
+ }
116
+ }
117
+
118
  /**
119
  * @return bool
120
  */
207
  function handleUserUpdated($user_id, $old_user_data)
208
  {
209
  // only update this person if they were marked as subscribed before
210
+ $is_subscribed = get_user_meta($user_id, 'mailchimp_woocommerce_is_subscribed', true);
211
+
212
+ // if they don't have a meta set for is_subscribed, we will get a blank string, so just ignore this.
213
+ if ($is_subscribed === '' || $is_subscribed === null) return;
214
+
215
+ // only send this update if the user actually has a boolean value.
216
+ wp_queue(new MailChimp_WooCommerce_User_Submit($user_id, (bool) $is_subscribed, $old_user_data));
217
  }
218
 
219
  /**
includes/class-mailchimp-woocommerce.php CHANGED
@@ -329,6 +329,9 @@ class MailChimp_Woocommerce {
329
  $this->loader->add_action('woocommerce_api_create_order', $service, 'handleOrderStatusChanged', 10);
330
  $this->loader->add_action('woocommerce_order_status_changed', $service, 'handleOrderStatusChanged', 2);
331
 
 
 
 
332
  // cart hooks
333
  $this->loader->add_action('woocommerce_cart_updated', $service, 'handleCartUpdated');
334
  $this->loader->add_action('woocommerce_add_to_cart', $service, 'handleCartUpdated');
329
  $this->loader->add_action('woocommerce_api_create_order', $service, 'handleOrderStatusChanged', 10);
330
  $this->loader->add_action('woocommerce_order_status_changed', $service, 'handleOrderStatusChanged', 2);
331
 
332
+ // partially refunded
333
+ $this->loader->add_action('woocommerce_order_partially_refunded', $service, 'onPartiallyRefunded', 10);
334
+
335
  // cart hooks
336
  $this->loader->add_action('woocommerce_cart_updated', $service, 'handleCartUpdated');
337
  $this->loader->add_action('woocommerce_add_to_cart', $service, 'handleCartUpdated');
includes/processes/class-mailchimp-woocommerce-single-order.php CHANGED
@@ -15,6 +15,7 @@ class MailChimp_WooCommerce_Single_Order extends WP_Job
15
  public $campaign_id;
16
  public $landing_site;
17
  public $is_update = false;
 
18
 
19
  /**
20
  * MailChimp_WooCommerce_Single_Order constructor.
@@ -74,6 +75,11 @@ class MailChimp_WooCommerce_Single_Order extends WP_Job
74
  // transform the order
75
  $order = $job->transform(get_post($this->order_id));
76
 
 
 
 
 
 
77
  // will be the same as the customer id. an md5'd hash of a lowercased email.
78
  $this->cart_session_id = $order->getCustomer()->getId();
79
 
15
  public $campaign_id;
16
  public $landing_site;
17
  public $is_update = false;
18
+ public $partially_refunded = false;
19
 
20
  /**
21
  * MailChimp_WooCommerce_Single_Order constructor.
75
  // transform the order
76
  $order = $job->transform(get_post($this->order_id));
77
 
78
+ // if we're overriding this we need to set it here.
79
+ if ($this->partially_refunded) {
80
+ $order->setFinancialStatus('partially_refunded');
81
+ }
82
+
83
  // will be the same as the customer id. an md5'd hash of a lowercased email.
84
  $this->cart_session_id = $order->getCustomer()->getId();
85
 
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: 1.0.9
20
  * Author: MailChimp
21
  * Author URI: https://mailchimp.com
22
  * License: GPL-2.0+
@@ -39,7 +39,7 @@ function mailchimp_environment_variables() {
39
  return (object) array(
40
  'repo' => 'master',
41
  'environment' => 'production',
42
- 'version' => '1.0.9',
43
  'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
44
  );
45
  }
16
  * Plugin Name: MailChimp for WooCommerce
17
  * Plugin URI: https://mailchimp.com/connect-your-store/
18
  * Description: MailChimp - WooCommerce plugin
19
+ * Version: 1.1.0
20
  * Author: MailChimp
21
  * Author URI: https://mailchimp.com
22
  * License: GPL-2.0+
39
  return (object) array(
40
  'repo' => 'master',
41
  'environment' => 'production',
42
+ 'version' => '1.1.0',
43
  'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
44
  );
45
  }