WooCommerce MailChimp - Version 1.2.2

Version Description

  • WooCommerce 2.1 fix for order custom fields
Download this release

Release Info

Developer anderly
Plugin Icon 128x128 WooCommerce MailChimp
Version 1.2.2
Comparing to
See all releases

Code changes from version 1.2.1 to 1.2.2

README.md CHANGED
@@ -64,6 +64,9 @@ If you need help, have problems, want to leave feedback or want to provide const
64
 
65
  ### Changelog
66
 
 
 
 
67
  ##### 1.2.1
68
  * WooCommerce 2.1 integration: Change to use wc_enqueue_js instead of add_inline_js
69
  * WooCommerce 2.1 integration: Change to support new default checkout field filter for default opt-in checkbox status
64
 
65
  ### Changelog
66
 
67
+ ##### 1.2.2
68
+ * WooCommerce 2.1 fix for order custom fields
69
+
70
  ##### 1.2.1
71
  * WooCommerce 2.1 integration: Change to use wc_enqueue_js instead of add_inline_js
72
  * WooCommerce 2.1 integration: Change to support new default checkout field filter for default opt-in checkbox status
classes/class-ss-wc-integration-mailchimp.php CHANGED
@@ -101,10 +101,13 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
101
 
102
  if ( $this->is_valid() && $new_status == $this->occurs ) {
103
 
104
- $order = new WC_Order( $id );
 
 
105
 
106
  // If the 'ss_wc_mailchimp_opt_in' meta value isn't set (because 'display_opt_in' wasn't enabled at the time the order was placed) or the 'ss_wc_mailchimp_opt_in' is yes, subscriber the customer
107
- if ( ! isset( $order->order_custom_fields['ss_wc_mailchimp_opt_in'][0] ) || 'yes' == $order->order_custom_fields['ss_wc_mailchimp_opt_in'][0] ) {
 
108
  $this->subscribe( $order->billing_first_name, $order->billing_last_name, $order->billing_email, $this->list );
109
  }
110
 
@@ -458,4 +461,20 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
458
  update_post_meta( $order_id, 'ss_wc_mailchimp_opt_in', $opt_in );
459
  }
460
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
  }
101
 
102
  if ( $this->is_valid() && $new_status == $this->occurs ) {
103
 
104
+ // get the ss_wc_mailchimp_opt_in value from the post meta. "order_custom_fields" was removed with WooCommerce 2.1
105
+ $ss_wc_mailchimp_opt_in = get_post_meta( $id, 'ss_wc_mailchimp_opt_in', true );
106
+ self::log( '$ss_wc_mailchimp_opt_in: ' . $ss_wc_mailchimp_opt_in );
107
 
108
  // If the 'ss_wc_mailchimp_opt_in' meta value isn't set (because 'display_opt_in' wasn't enabled at the time the order was placed) or the 'ss_wc_mailchimp_opt_in' is yes, subscriber the customer
109
+ if ( ! isset( $ss_wc_mailchimp_opt_in ) || 'yes' == $ss_wc_mailchimp_opt_in ) {
110
+ self::log( 'Subscribing user (' . $order->billing_email . ') to list(' . $this->list . ') ' );
111
  $this->subscribe( $order->billing_first_name, $order->billing_last_name, $order->billing_email, $this->list );
112
  }
113
 
461
  update_post_meta( $order_id, 'ss_wc_mailchimp_opt_in', $opt_in );
462
  }
463
  }
464
+
465
+ /**
466
+ * Helper log function for debugging
467
+ *
468
+ * @since 1.2.2
469
+ */
470
+ static function log( $message ) {
471
+ if ( WP_DEBUG === true ) {
472
+ if ( is_array( $message ) || is_object( $message ) ) {
473
+ error_log( print_r( $message, true ) );
474
+ } else {
475
+ error_log( $message );
476
+ }
477
+ }
478
+ }
479
+
480
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: anderly, saintsystems
3
  Tags: woocommerce, mailchimp
4
  Requires at least: 3.6
5
  Tested up to: 3.8.1
6
- Stable tag: 1.2.1
7
  License: GPLv3
8
 
9
  Simple and flexible MailChimp integration for WooCommerce.
@@ -78,6 +78,9 @@ If you need help, have problems, want to leave feedback or want to provide const
78
 
79
  == Changelog ==
80
 
 
 
 
81
  = 1.2.1 =
82
  * WooCommerce 2.1 integration: Change to use wc_enqueue_js instead of add_inline_js
83
  * WooCommerce 2.1 integration: Change to support new default checkout field filter for default opt-in checkbox status
3
  Tags: woocommerce, mailchimp
4
  Requires at least: 3.6
5
  Tested up to: 3.8.1
6
+ Stable tag: 1.2.2
7
  License: GPLv3
8
 
9
  Simple and flexible MailChimp integration for WooCommerce.
78
 
79
  == Changelog ==
80
 
81
+ = 1.2.2 =
82
+ * WooCommerce 2.1 fix for order custom fields
83
+
84
  = 1.2.1 =
85
  * WooCommerce 2.1 integration: Change to use wc_enqueue_js instead of add_inline_js
86
  * WooCommerce 2.1 integration: Change to support new default checkout field filter for default opt-in checkbox status
woocommerce-mailchimp.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
6
  * Author: Adam Anderly
7
  * Author URI: http://anderly.com
8
- * Version: 1.2.1
9
  * Text Domain: ss_wc_mailchimp
10
  * Domain Path: languages
11
  *
5
  * Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
6
  * Author: Adam Anderly
7
  * Author URI: http://anderly.com
8
+ * Version: 1.2.2
9
  * Text Domain: ss_wc_mailchimp
10
  * Domain Path: languages
11
  *