Version Description
- Tested up to WordPress 4.6.1
- Tested up to WooCommerce 2.6.4
- More flexible opt_in checkbox placement
- Pass $order_id to
ss_wc_mailchimp_subscribe_options
hook - Use only one instance of MCAPI
- Fixed Issue #14 MCAPI constructor style
- Fixed Issue #15
mailchimp_api_error_msg
- Fixed Issue #16 where lists wouldn't show up until you saved the settings twice
Download this release
Release Info
Developer | anderly |
Plugin | WooCommerce MailChimp |
Version | 1.3.8 |
Comparing to | |
See all releases |
Code changes from version 1.3.7 to 1.3.8
- README.md +11 -1
- classes/api/class-MCAPI.php +1 -1
- classes/class-ss-wc-integration-mailchimp.php +116 -60
- readme.txt +31 -14
- woocommerce-mailchimp.php +4 -4
README.md
CHANGED
@@ -26,7 +26,7 @@ Automatically subscribe customers to a designated MailChimp list and, optionally
|
|
26 |
- Optionally, display an opt-in checkbox on the checkout page (this is required in some countries)
|
27 |
- Control the label displayed next to the opt-in checkbox
|
28 |
- Control whether or not the opt-in checkbox is checked or unchecked by default
|
29 |
-
- Control the placement of the opt-in checkbox on the checkout page
|
30 |
|
31 |
#### Translation Support
|
32 |
|
@@ -69,6 +69,16 @@ If you need help, have problems, want to leave feedback or want to provide const
|
|
69 |
|
70 |
### Changelog
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
#### 1.3.7
|
73 |
* WordPress 4.4 Compatible
|
74 |
* WooCommerce 2.4.12 Compatible
|
26 |
- Optionally, display an opt-in checkbox on the checkout page (this is required in some countries)
|
27 |
- Control the label displayed next to the opt-in checkbox
|
28 |
- Control whether or not the opt-in checkbox is checked or unchecked by default
|
29 |
+
- Control the placement of the opt-in checkbox on the checkout page
|
30 |
|
31 |
#### Translation Support
|
32 |
|
69 |
|
70 |
### Changelog
|
71 |
|
72 |
+
#### 1.3.8
|
73 |
+
* WordPress 4.6.x Compatible
|
74 |
+
* WooCommerce 2.6.x Compatible
|
75 |
+
* More flexible opt_in checkbox placement
|
76 |
+
* Pass $order_id to `ss_wc_mailchimp_subscribe_options` hook
|
77 |
+
* Use only one instance of MCAPI
|
78 |
+
* Fixed Issue #14 MCAPI constructor style
|
79 |
+
* Fixed Issue #15 `mailchimp_api_error_msg`
|
80 |
+
* Fixed Issue #16 where lists wouldn't show up until you saved the settings twice
|
81 |
+
|
82 |
#### 1.3.7
|
83 |
* WordPress 4.4 Compatible
|
84 |
* WooCommerce 2.4.12 Compatible
|
classes/api/class-MCAPI.php
CHANGED
@@ -36,7 +36,7 @@ class MCAPI {
|
|
36 |
* @param string $apikey Your MailChimp apikey
|
37 |
* @param string $secure Whether or not this should use a secure connection
|
38 |
*/
|
39 |
-
function
|
40 |
$this->secure = $secure;
|
41 |
$this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
|
42 |
$this->api_key = $apikey;
|
36 |
* @param string $apikey Your MailChimp apikey
|
37 |
* @param string $secure Whether or not this should use a secure connection
|
38 |
*/
|
39 |
+
function __construct($apikey, $secure=false) {
|
40 |
$this->secure = $secure;
|
41 |
$this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
|
42 |
$this->api_key = $apikey;
|
classes/class-ss-wc-integration-mailchimp.php
CHANGED
@@ -15,6 +15,12 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
15 |
*/
|
16 |
class SS_WC_Integration_MailChimp extends WC_Integration {
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
/**
|
19 |
* Init and hook in the integration.
|
20 |
*
|
@@ -23,10 +29,6 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
23 |
*/
|
24 |
public function __construct() {
|
25 |
|
26 |
-
if ( ! class_exists( 'MCAPI' ) ) {
|
27 |
-
include_once( 'api/class-MCAPI.php' );
|
28 |
-
}
|
29 |
-
|
30 |
$this->id = 'mailchimp';
|
31 |
$this->method_title = __( 'MailChimp', 'ss_wc_mailchimp' );
|
32 |
$this->method_description = __( 'MailChimp is a popular email marketing service.', 'ss_wc_mailchimp' );
|
@@ -34,28 +36,24 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
34 |
// Load the settings.
|
35 |
$this->init_settings();
|
36 |
|
37 |
-
|
38 |
-
$this->api_key = $this->get_option( 'api_key' );
|
39 |
-
$this->mailchimp = new MCAPI( $this->api_key );
|
40 |
-
$this->enabled = $this->get_option( 'enabled' );
|
41 |
-
|
42 |
-
$this->init_form_fields();
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
$this->groups = $this->get_option( 'groups' );
|
49 |
-
$this->display_opt_in = $this->get_option( 'display_opt_in' );
|
50 |
-
$this->opt_in_label = $this->get_option( 'opt_in_label' );
|
51 |
-
$this->opt_in_checkbox_default_status = $this->get_option( 'opt_in_checkbox_default_status' );
|
52 |
-
$this->opt_in_checkbox_display_location = $this->get_option( 'opt_in_checkbox_display_location' );
|
53 |
-
$this->interest_groupings = $this->get_option( 'interest_groupings' );
|
54 |
|
55 |
// Hooks
|
56 |
-
add_action( 'admin_notices',
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
// We would use the 'woocommerce_new_order' action but first name, last name and email address (order meta) is not yet available,
|
61 |
// so instead we use the 'woocommerce_checkout_update_order_meta' action hook which fires after the checkout process on the "thank you" page
|
@@ -65,13 +63,48 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
65 |
add_action( 'woocommerce_order_status_changed', array( $this, 'order_status_changed' ), 10, 3 );
|
66 |
|
67 |
// Maybe add an "opt-in" field to the checkout
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
add_filter( 'default_checkout_ss_wc_mailchimp_opt_in', array( $this, 'checkbox_default_status' ) );
|
70 |
|
71 |
// Maybe save the "opt-in" field on the checkout
|
72 |
add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'maybe_save_checkout_fields' ) );
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
/**
|
76 |
* Check if the user has enabled the plugin functionality, but hasn't provided an api key
|
77 |
**/
|
@@ -130,8 +163,7 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
130 |
* @return void
|
131 |
*/
|
132 |
public function has_api_key() {
|
133 |
-
|
134 |
-
return true;
|
135 |
}
|
136 |
|
137 |
/**
|
@@ -161,6 +193,8 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
161 |
* @return void
|
162 |
*/
|
163 |
function init_form_fields() {
|
|
|
|
|
164 |
$lists = array();
|
165 |
|
166 |
if ( is_admin() && ! is_ajax() ) {
|
@@ -257,11 +291,17 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
257 |
'opt_in_checkbox_display_location' => array(
|
258 |
'title' => __( 'Opt-In Checkbox Display Location', 'ss_wc_mailchimp' ),
|
259 |
'type' => 'select',
|
260 |
-
'description' => __( 'Where to display the opt-in checkbox on the checkout page
|
261 |
-
'default' => '
|
262 |
'options' => array(
|
263 |
-
'
|
264 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
)
|
266 |
)
|
267 |
);
|
@@ -333,6 +373,22 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
333 |
return ob_get_clean();
|
334 |
}
|
335 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
/**
|
337 |
* get_lists function.
|
338 |
*
|
@@ -340,14 +396,22 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
340 |
* @return void
|
341 |
*/
|
342 |
public function get_lists() {
|
343 |
-
|
344 |
|
345 |
-
if ( ! $mailchimp_lists ) {
|
346 |
|
347 |
$mailchimp_lists = array();
|
348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
|
350 |
-
if ( $this->
|
351 |
|
352 |
add_action( 'admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
353 |
add_action( 'network_admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
@@ -361,7 +425,7 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
361 |
if ( sizeof( $mailchimp_lists ) > 0 )
|
362 |
set_transient( 'sswcmclist_' . md5( $this->api_key ), $mailchimp_lists, 60 * 60 * 1 );
|
363 |
}
|
364 |
-
}
|
365 |
|
366 |
return $mailchimp_lists;
|
367 |
}
|
@@ -375,8 +439,8 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
375 |
*/
|
376 |
public function mailchimp_api_error_msg() {
|
377 |
echo $this->get_message(
|
378 |
-
sprintf( __( 'Unable to load lists from MailChimp: (%s) %s. ', 'ss_wc_mailchimp' ), $this->
|
379 |
-
sprintf( __( 'Please check your %s <a href="%s">settings</a>.', 'ss_wc_mailchimp' ), WOOCOMMERCE_MAILCHIMP_SETTINGS_URL )
|
380 |
);
|
381 |
}
|
382 |
|
@@ -392,10 +456,10 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
392 |
|
393 |
$interest_groupings = array();
|
394 |
$interest_groups = array();
|
395 |
-
$retval = $this->
|
396 |
|
397 |
-
if ( $this->
|
398 |
-
echo $this->get_message( sprintf( __( 'Unable to load listInterestGroupings() from MailChimp: (%s) %s', 'ss_wc_mailchimp' ), $this->
|
399 |
|
400 |
return false;
|
401 |
|
@@ -472,7 +536,7 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
472 |
);
|
473 |
|
474 |
// Allow hooking into subscription options
|
475 |
-
$options
|
476 |
|
477 |
// Extract options into variables
|
478 |
extract( $options );
|
@@ -481,14 +545,14 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
481 |
self::log( sprintf( __( 'Calling MailChimp API listSubscribe method with the following: %s', 'ss_wc_mailchimp' ), print_r( $options, true ) ) );
|
482 |
|
483 |
// Call API
|
484 |
-
$api_response = $this->
|
485 |
|
486 |
// Log api response
|
487 |
self::log( sprintf( __( 'MailChimp API response: %s', 'ss_wc_mailchimp' ), $api_response ) );
|
488 |
|
489 |
-
if ( $this->
|
490 |
// Format error message
|
491 |
-
$error_response = sprintf( __( 'WooCommerce MailChimp subscription failed: %s (%s)', 'ss_wc_mailchimp' ), $this->
|
492 |
|
493 |
// Log
|
494 |
self::log( $error_response );
|
@@ -526,22 +590,14 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
526 |
*
|
527 |
* @since 1.1
|
528 |
*/
|
529 |
-
function maybe_add_checkout_fields(
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
if ( 'yes' == $this->display_opt_in ) {
|
537 |
-
$checkout_fields[$display_location]['ss_wc_mailchimp_opt_in'] = array(
|
538 |
-
'type' => 'checkbox',
|
539 |
-
'label' => esc_attr( $this->opt_in_label ),
|
540 |
-
'default' => $this->opt_in_checkbox_default_status == 'checked' ? 1 : 0,
|
541 |
-
);
|
542 |
}
|
543 |
-
|
544 |
-
return $checkout_fields;
|
545 |
}
|
546 |
|
547 |
/**
|
@@ -584,4 +640,4 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
|
|
584 |
}
|
585 |
}
|
586 |
|
587 |
-
}
|
15 |
*/
|
16 |
class SS_WC_Integration_MailChimp extends WC_Integration {
|
17 |
|
18 |
+
/**
|
19 |
+
* Instance of the API class.
|
20 |
+
* @var Object
|
21 |
+
*/
|
22 |
+
private static $api = null;
|
23 |
+
|
24 |
/**
|
25 |
* Init and hook in the integration.
|
26 |
*
|
29 |
*/
|
30 |
public function __construct() {
|
31 |
|
|
|
|
|
|
|
|
|
32 |
$this->id = 'mailchimp';
|
33 |
$this->method_title = __( 'MailChimp', 'ss_wc_mailchimp' );
|
34 |
$this->method_description = __( 'MailChimp is a popular email marketing service.', 'ss_wc_mailchimp' );
|
36 |
// Load the settings.
|
37 |
$this->init_settings();
|
38 |
|
39 |
+
$this->load_settings();
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
if ( is_admin() ) {
|
42 |
+
// Load the settings
|
43 |
+
$this->init_form_fields();
|
44 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
// Hooks
|
47 |
+
add_action( 'admin_notices', array( $this, 'checks' ) );
|
48 |
+
|
49 |
+
// Update the settings fields
|
50 |
+
add_action( 'woocommerce_update_options_integration', array( $this, 'process_admin_options') );
|
51 |
+
|
52 |
+
// Update the settings fields
|
53 |
+
add_action( 'woocommerce_update_options_integration', array( $this, 'refresh_settings'), 10 );
|
54 |
+
|
55 |
+
// Refresh the settings
|
56 |
+
add_action( 'woocommerce_update_options_integration_' . $this->id, array( $this, 'refresh_settings'), 10 );
|
57 |
|
58 |
// We would use the 'woocommerce_new_order' action but first name, last name and email address (order meta) is not yet available,
|
59 |
// so instead we use the 'woocommerce_checkout_update_order_meta' action hook which fires after the checkout process on the "thank you" page
|
63 |
add_action( 'woocommerce_order_status_changed', array( $this, 'order_status_changed' ), 10, 3 );
|
64 |
|
65 |
// Maybe add an "opt-in" field to the checkout
|
66 |
+
$opt_in_checkbox_display_location = ( isset( $this->opt_in_checkbox_display_location ) && !empty( $this->opt_in_checkbox_display_location ) ) ? $this->opt_in_checkbox_display_location : 'woocommerce_review_order_before_submit';
|
67 |
+
|
68 |
+
// Old opt-in checkbox display locations
|
69 |
+
$old_opt_in_checkbox_display_locations = array(
|
70 |
+
'billing' => 'woocommerce_after_checkout_billing_form',
|
71 |
+
'order' => 'woocommerce_review_order_before_submit',
|
72 |
+
);
|
73 |
+
|
74 |
+
// Map old billing/order checkbox display locations to new format
|
75 |
+
if ( array_key_exists( $opt_in_checkbox_display_location, $old_opt_in_checkbox_display_locations ) ) {
|
76 |
+
$opt_in_checkbox_display_location = $old_opt_in_checkbox_display_locations[ $opt_in_checkbox_display_location ];
|
77 |
+
}
|
78 |
+
|
79 |
+
add_action( $opt_in_checkbox_display_location, array( $this, 'maybe_add_checkout_fields' ) );
|
80 |
add_filter( 'default_checkout_ss_wc_mailchimp_opt_in', array( $this, 'checkbox_default_status' ) );
|
81 |
|
82 |
// Maybe save the "opt-in" field on the checkout
|
83 |
add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'maybe_save_checkout_fields' ) );
|
84 |
}
|
85 |
|
86 |
+
public function load_settings() {
|
87 |
+
// We need the API key to set up for the lists in the form fields
|
88 |
+
$this->api_key = $this->get_option( 'api_key' );
|
89 |
+
// $this->get_api() = new MCAPI( $this->api_key );
|
90 |
+
$this->enabled = $this->get_option( 'enabled' );
|
91 |
+
|
92 |
+
// Get setting values
|
93 |
+
$this->occurs = $this->get_option( 'occurs' );
|
94 |
+
$this->list = $this->get_option( 'list' );
|
95 |
+
$this->double_optin = $this->get_option( 'double_optin' );
|
96 |
+
$this->groups = $this->get_option( 'groups' );
|
97 |
+
$this->display_opt_in = $this->get_option( 'display_opt_in' );
|
98 |
+
$this->opt_in_label = $this->get_option( 'opt_in_label' );
|
99 |
+
$this->opt_in_checkbox_default_status = $this->get_option( 'opt_in_checkbox_default_status' );
|
100 |
+
$this->opt_in_checkbox_display_location = $this->get_option( 'opt_in_checkbox_display_location' );
|
101 |
+
$this->interest_groupings = $this->get_option( 'interest_groupings' );
|
102 |
+
}
|
103 |
+
|
104 |
+
public function refresh_settings() {
|
105 |
+
$this->init_form_fields();
|
106 |
+
}
|
107 |
+
|
108 |
/**
|
109 |
* Check if the user has enabled the plugin functionality, but hasn't provided an api key
|
110 |
**/
|
163 |
* @return void
|
164 |
*/
|
165 |
public function has_api_key() {
|
166 |
+
return isset( $this->api_key ) && !empty( $this->api_key );
|
|
|
167 |
}
|
168 |
|
169 |
/**
|
193 |
* @return void
|
194 |
*/
|
195 |
function init_form_fields() {
|
196 |
+
$this->load_settings();
|
197 |
+
|
198 |
$lists = array();
|
199 |
|
200 |
if ( is_admin() && ! is_ajax() ) {
|
291 |
'opt_in_checkbox_display_location' => array(
|
292 |
'title' => __( 'Opt-In Checkbox Display Location', 'ss_wc_mailchimp' ),
|
293 |
'type' => 'select',
|
294 |
+
'description' => __( 'Where to display the opt-in checkbox on the checkout page.', 'ss_wc_mailchimp' ),
|
295 |
+
'default' => 'woocommerce_review_order_before_submit',
|
296 |
'options' => array(
|
297 |
+
'woocommerce_checkout_before_customer_details' => __( 'Above customer details', 'ss_wc_mailchimp' ),
|
298 |
+
'woocommerce_checkout_after_customer_details' => __( 'Below customer details', 'ss_wc_mailchimp' ),
|
299 |
+
'woocommerce_review_order_before_submit' => __( 'Order review above submit', 'ss_wc_mailchimp' ),
|
300 |
+
'woocommerce_review_order_after_submit' => __( 'Order review below submit', 'ss_wc_mailchimp' ),
|
301 |
+
'woocommerce_review_order_before_order_total' => __( 'Order review above total', 'ss_wc_mailchimp' ),
|
302 |
+
'woocommerce_checkout_billing' => __( 'Above billing details', 'ss_wc_mailchimp' ),
|
303 |
+
'woocommerce_checkout_shipping' => __( 'Above shipping details', 'ss_wc_mailchimp' ),
|
304 |
+
'woocommerce_after_checkout_billing_form' => __( 'Below Checkout billing form', 'ss_wc_mailchimp' ),
|
305 |
)
|
306 |
)
|
307 |
);
|
373 |
return ob_get_clean();
|
374 |
}
|
375 |
|
376 |
+
/**
|
377 |
+
* Main API Instance, ensure only 1 API instance is loaded.
|
378 |
+
* @return Object
|
379 |
+
*/
|
380 |
+
public function get_api() {
|
381 |
+
if ( is_null( self::$api ) ) {
|
382 |
+
$this->api_key = $this->get_option( 'api_key' );
|
383 |
+
if ( $this->api_key == '' ) {
|
384 |
+
return false;
|
385 |
+
}
|
386 |
+
require_once( 'api/class-MCAPI.php' );
|
387 |
+
self::$api = new MCAPI( $this->api_key );
|
388 |
+
}
|
389 |
+
return self::$api;
|
390 |
+
}
|
391 |
+
|
392 |
/**
|
393 |
* get_lists function.
|
394 |
*
|
396 |
* @return void
|
397 |
*/
|
398 |
public function get_lists() {
|
399 |
+
//$mailchimp_lists = get_transient( 'sswcmclist_' . md5( $this->api_key ) );
|
400 |
|
401 |
+
//if ( ! $mailchimp_lists ) {
|
402 |
|
403 |
$mailchimp_lists = array();
|
404 |
+
if ( $this->get_api() ) {
|
405 |
+
$retval = $this->get_api()->lists();
|
406 |
+
}
|
407 |
+
else {
|
408 |
+
return false;
|
409 |
+
}
|
410 |
+
|
411 |
+
// if ( $lists !== false ) {
|
412 |
+
// $retval = $this->get_api()->lists();
|
413 |
|
414 |
+
if ( $this->get_api()->errorCode ) {
|
415 |
|
416 |
add_action( 'admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
417 |
add_action( 'network_admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
425 |
if ( sizeof( $mailchimp_lists ) > 0 )
|
426 |
set_transient( 'sswcmclist_' . md5( $this->api_key ), $mailchimp_lists, 60 * 60 * 1 );
|
427 |
}
|
428 |
+
//}
|
429 |
|
430 |
return $mailchimp_lists;
|
431 |
}
|
439 |
*/
|
440 |
public function mailchimp_api_error_msg() {
|
441 |
echo $this->get_message(
|
442 |
+
sprintf( __( 'Unable to load lists from MailChimp: (%s) %s. ', 'ss_wc_mailchimp' ), $this->get_api()->errorCode, $this->get_api()->errorMessage ) .
|
443 |
+
sprintf( __( 'Please check your %s <a href="%s">settings</a>.', 'ss_wc_mailchimp' ), __( 'Settings', 'ss_wc_mailchimp' ), WOOCOMMERCE_MAILCHIMP_SETTINGS_URL )
|
444 |
);
|
445 |
}
|
446 |
|
456 |
|
457 |
$interest_groupings = array();
|
458 |
$interest_groups = array();
|
459 |
+
$retval = $this->get_api()->listInterestGroupings( $listid );
|
460 |
|
461 |
+
if ( $this->get_api()->errorCode ) {
|
462 |
+
echo $this->get_message( sprintf( __( 'Unable to load listInterestGroupings() from MailChimp: (%s) %s', 'ss_wc_mailchimp' ), $this->get_api()->errorCode, $this->get_api()->errorMessage ) );
|
463 |
|
464 |
return false;
|
465 |
|
536 |
);
|
537 |
|
538 |
// Allow hooking into subscription options
|
539 |
+
$options = apply_filters( 'ss_wc_mailchimp_subscribe_options', $subscribe_options, $order_id );
|
540 |
|
541 |
// Extract options into variables
|
542 |
extract( $options );
|
545 |
self::log( sprintf( __( 'Calling MailChimp API listSubscribe method with the following: %s', 'ss_wc_mailchimp' ), print_r( $options, true ) ) );
|
546 |
|
547 |
// Call API
|
548 |
+
$api_response = $this->get_api()->listSubscribe( $listid, $email, $vars, $email_type, $double_optin, $update_existing, $replace_interests, $send_welcome );
|
549 |
|
550 |
// Log api response
|
551 |
self::log( sprintf( __( 'MailChimp API response: %s', 'ss_wc_mailchimp' ), $api_response ) );
|
552 |
|
553 |
+
if ( $this->get_api()->errorCode && $this->get_api()->errorCode != 214 ) {
|
554 |
// Format error message
|
555 |
+
$error_response = sprintf( __( 'WooCommerce MailChimp subscription failed: %s (%s)', 'ss_wc_mailchimp' ), $this->get_api()->errorMessage, $this->get_api()->errorCode );
|
556 |
|
557 |
// Log
|
558 |
self::log( $error_response );
|
590 |
*
|
591 |
* @since 1.1
|
592 |
*/
|
593 |
+
function maybe_add_checkout_fields() {
|
594 |
+
if ( $this->is_valid() ) {
|
595 |
+
if ( 'yes' == $this->display_opt_in ) {
|
596 |
+
do_action( 'ss_wc_mailchimp_before_opt_in_checkbox' );
|
597 |
+
echo apply_filters('ss_wc_mailchimp_opt_in_checkbox', '<p class="form-row woocommerce-mailchimp-opt-in"><label for="ss_wc_mailchimp_opt_in"><input type="checkbox" name="ss_wc_mailchimp_opt_in" id="ss_wc_mailchimp_opt_in" value="yes"' . ($this->opt_in_checkbox_default_status == 'checked' ? ' checked="checked"' : '') . '/> ' . esc_html( $this->opt_in_label ) . '</label></p>' . "\n", $this->opt_in_checkbox_default_status, $this->opt_in_label);
|
598 |
+
do_action( 'ss_wc_mailchimp_after_opt_in_checkbox' );
|
599 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
600 |
}
|
|
|
|
|
601 |
}
|
602 |
|
603 |
/**
|
640 |
}
|
641 |
}
|
642 |
|
643 |
+
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: anderly, saintsystems
|
3 |
Tags: woocommerce, mailchimp
|
4 |
Requires at least: 3.5.1
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 1.3.
|
7 |
License: GPLv3
|
8 |
|
9 |
Simple and flexible MailChimp integration for WooCommerce.
|
@@ -14,26 +14,26 @@ WooCommerce MailChimp provides simple and flexible MailChimp integration for Woo
|
|
14 |
|
15 |
Automatically subscribe customers to a designated MailChimp list and, optionally, MailChimp interest groups upon order creation or order completion. This can be done quietly or based on the user's consent with several opt-in settings that support international opt-in laws.
|
16 |
|
17 |
-
|
18 |
|
19 |
-
|
20 |
|
21 |
- Subscribe customers to MailChimp after order creation
|
22 |
- Subscribe customers to MailChimp after order completion
|
23 |
|
24 |
-
|
25 |
|
26 |
- Set one or more interest groups to add users to based on the selected MailChimp list.
|
27 |
|
28 |
-
|
29 |
|
30 |
- MailChimp double opt-in support (control whether a double opt-in email is sent to the customer)
|
31 |
- Optionally, display an opt-in checkbox on the checkout page (this is required in some countries)
|
32 |
- Control the label displayed next to the opt-in checkbox
|
33 |
- Control whether or not the opt-in checkbox is checked or unchecked by default
|
34 |
-
- Control the placement of the opt-in checkbox on the checkout page
|
35 |
|
36 |
-
|
37 |
|
38 |
- i18n ready with included woocommerce-mailchimp.pot file
|
39 |
- WPML support via wpml-config.xml
|
@@ -45,19 +45,26 @@ Automatically subscribe customers to a designated MailChimp list and, optionally
|
|
45 |
|
46 |
Thanks in advance for your help on any translation efforts!
|
47 |
|
48 |
-
|
49 |
|
50 |
- All features should work for each blog in multisite installations.
|
51 |
|
52 |
-
|
53 |
|
54 |
-
|
55 |
|
56 |
-
|
57 |
|
58 |
-
|
59 |
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
== Installation ==
|
63 |
|
@@ -78,6 +85,16 @@ If you need help, have problems, want to leave feedback or want to provide const
|
|
78 |
|
79 |
== Changelog ==
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
= 1.3.7 =
|
82 |
* WordPress 4.4 Compatible
|
83 |
* WooCommerce 2.4.12 Compatible
|
2 |
Contributors: anderly, saintsystems
|
3 |
Tags: woocommerce, mailchimp
|
4 |
Requires at least: 3.5.1
|
5 |
+
Tested up to: 4.6.1
|
6 |
+
Stable tag: 1.3.8
|
7 |
License: GPLv3
|
8 |
|
9 |
Simple and flexible MailChimp integration for WooCommerce.
|
14 |
|
15 |
Automatically subscribe customers to a designated MailChimp list and, optionally, MailChimp interest groups upon order creation or order completion. This can be done quietly or based on the user's consent with several opt-in settings that support international opt-in laws.
|
16 |
|
17 |
+
= Features =
|
18 |
|
19 |
+
**WooCommerce Event Selection**
|
20 |
|
21 |
- Subscribe customers to MailChimp after order creation
|
22 |
- Subscribe customers to MailChimp after order completion
|
23 |
|
24 |
+
**Works with MailChimp Interest Groups**
|
25 |
|
26 |
- Set one or more interest groups to add users to based on the selected MailChimp list.
|
27 |
|
28 |
+
**Opt-In Settings**
|
29 |
|
30 |
- MailChimp double opt-in support (control whether a double opt-in email is sent to the customer)
|
31 |
- Optionally, display an opt-in checkbox on the checkout page (this is required in some countries)
|
32 |
- Control the label displayed next to the opt-in checkbox
|
33 |
- Control whether or not the opt-in checkbox is checked or unchecked by default
|
34 |
+
- Control the placement of the opt-in checkbox on the checkout page
|
35 |
|
36 |
+
= Translation Support =
|
37 |
|
38 |
- i18n ready with included woocommerce-mailchimp.pot file
|
39 |
- WPML support via wpml-config.xml
|
45 |
|
46 |
Thanks in advance for your help on any translation efforts!
|
47 |
|
48 |
+
= Multisite =
|
49 |
|
50 |
- All features should work for each blog in multisite installations.
|
51 |
|
52 |
+
= Requirements =
|
53 |
|
54 |
+
WooCommerce MailChimp requires PHP 5.4+ (PHP 7.0+ recommended). You'll also need to be running WordPress 3.5.1+ and have WooCommerce 2.2+.
|
55 |
|
56 |
+
= Documentation & Support =
|
57 |
|
58 |
+
Online documentation and code samples are available via our [Help Center](https://support.saintsystems.com/hc/en-us/sections/201959566). Given the free nature of this plugin, we cannot offer dedicated support via the WordPress.org forums (although we do check them). If you are interested in purchasing dedicated please contact us via our help center to get quote.
|
59 |
|
60 |
+
= Contribute =
|
61 |
+
All development for WooCommerce MailChimp is [handled via GitHub](https://github.com/anderly/woocommerce-mailchimp). Opening new issues and submitting pull requests are welcome.
|
62 |
+
|
63 |
+
[Our public roadmap is available on Trello](https://trello.com/b/VWBdLVuI/woocommerce-mailchimp-development). We'd love it if you vote and comment on your favorite ideas.
|
64 |
+
|
65 |
+
You can also keep up to date with [WooCommerce MailChimp Pro](https://www.saintsystems.com/products/woocommerce-mailchimp-pro/) development by [subscribing to our newsletter](http://eepurl.com/bxcewL).
|
66 |
+
|
67 |
+
Also, if you enjoy using the software [we'd love it if you could give us a review](https://wordpress.org/support/plugin/woocommerce-mailchimp/reviews/)!
|
68 |
|
69 |
== Installation ==
|
70 |
|
85 |
|
86 |
== Changelog ==
|
87 |
|
88 |
+
= 1.3.8 =
|
89 |
+
* Tested up to WordPress 4.6.1
|
90 |
+
* Tested up to WooCommerce 2.6.4
|
91 |
+
* More flexible opt_in checkbox placement
|
92 |
+
* Pass $order_id to `ss_wc_mailchimp_subscribe_options` hook
|
93 |
+
* Use only one instance of MCAPI
|
94 |
+
* Fixed Issue #14 MCAPI constructor style
|
95 |
+
* Fixed Issue #15 `mailchimp_api_error_msg`
|
96 |
+
* Fixed Issue #16 where lists wouldn't show up until you saved the settings twice
|
97 |
+
|
98 |
= 1.3.7 =
|
99 |
* WordPress 4.4 Compatible
|
100 |
* WooCommerce 2.4.12 Compatible
|
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.3.
|
9 |
* Text Domain: ss_wc_mailchimp
|
10 |
* Domain Path: languages
|
11 |
*
|
@@ -41,10 +41,10 @@ function woocommerce_mailchimp_init() {
|
|
41 |
/**
|
42 |
* Add the Integration to WooCommerce
|
43 |
*/
|
44 |
-
function add_mailchimp_integration($
|
45 |
-
$
|
46 |
|
47 |
-
return $
|
48 |
}
|
49 |
|
50 |
add_filter( 'woocommerce_integrations', 'add_mailchimp_integration' );
|
5 |
* Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
|
6 |
* Author: Adam Anderly
|
7 |
* Author URI: http://anderly.com
|
8 |
+
* Version: 1.3.8
|
9 |
* Text Domain: ss_wc_mailchimp
|
10 |
* Domain Path: languages
|
11 |
*
|
41 |
/**
|
42 |
* Add the Integration to WooCommerce
|
43 |
*/
|
44 |
+
function add_mailchimp_integration( $integrations ) {
|
45 |
+
$integrations[] = 'SS_WC_Integration_MailChimp';
|
46 |
|
47 |
+
return $integrations;
|
48 |
}
|
49 |
|
50 |
add_filter( 'woocommerce_integrations', 'add_mailchimp_integration' );
|