Version Description
Download this release
Release Info
Developer | anderly |
Plugin | WooCommerce MailChimp |
Version | 2.3.0 |
Comparing to | |
See all releases |
Code changes from version 2.2.0 to 2.3.0
- COPYRIGHT.txt +1 -1
- assets/js/woocommerce-mailchimp-admin.js +104 -6
- config/default-settings.php +2 -1
- includes/class-ss-wc-mailchimp-admin-notices.php +4 -4
- includes/class-ss-wc-mailchimp-handler.php +53 -6
- includes/class-ss-wc-mailchimp-plugin.php +21 -10
- includes/class-ss-wc-mailchimp.php +60 -7
- includes/class-ss-wc-settings-mailchimp.php +71 -6
- includes/migrations/class-ss-wc-migration.php +2 -1
- readme.txt +30 -21
- woocommerce-mailchimp.php +3 -3
COPYRIGHT.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
|
2 |
WooCommerce MailChimp
|
3 |
|
4 |
-
Copyright
|
5 |
|
6 |
The files COPYRIGHT.txt and LICENSE.txt as well as ALL NOTICES IN THE
|
7 |
HEADERS OF ALL FILES MUST BE KEPT INTACT.
|
1 |
|
2 |
WooCommerce MailChimp
|
3 |
|
4 |
+
Copyright 2019 "saintsystems" (Saint Systems) www.saintsystems.com
|
5 |
|
6 |
The files COPYRIGHT.txt and LICENSE.txt as well as ALL NOTICES IN THE
|
7 |
HEADERS OF ALL FILES MUST BE KEPT INTACT.
|
assets/js/woocommerce-mailchimp-admin.js
CHANGED
@@ -10,6 +10,8 @@ var SS_WC_MailChimp = function($) {
|
|
10 |
var $mainList;
|
11 |
var $interestGroupsLoadingIndicator;
|
12 |
var $interestGroups;
|
|
|
|
|
13 |
var $displayOptIn;
|
14 |
var $occurs;
|
15 |
var $optInLabel;
|
@@ -24,6 +26,7 @@ var SS_WC_MailChimp = function($) {
|
|
24 |
checkApiKey: checkApiKey,
|
25 |
loadLists: loadLists,
|
26 |
loadGroups: loadGroups,
|
|
|
27 |
};
|
28 |
|
29 |
function init() {
|
@@ -33,6 +36,7 @@ var SS_WC_MailChimp = function($) {
|
|
33 |
initHandlers();
|
34 |
initLists();
|
35 |
initGroups();
|
|
|
36 |
|
37 |
} //end function init
|
38 |
|
@@ -42,6 +46,7 @@ var SS_WC_MailChimp = function($) {
|
|
42 |
$apiKey = $('#' + namespace_prefixed('api_key'));
|
43 |
$mainList = $('#' + namespace_prefixed('list'));
|
44 |
$interestGroups = $('#' + namespace_prefixed('interest_groups'));
|
|
|
45 |
$displayOptIn = $('#' + namespace_prefixed('display_opt_in'));
|
46 |
$occurs = $('#' + namespace_prefixed('occurs'));
|
47 |
$optInLabel = $('#' + namespace_prefixed('opt_in_label'));
|
@@ -52,9 +57,10 @@ var SS_WC_MailChimp = function($) {
|
|
52 |
|
53 |
function initHandlers() {
|
54 |
$mainList.closest('tr').hide();
|
55 |
-
|
56 |
if ($mainList.val() === '') {
|
57 |
$interestGroups.attr('disabled','disabled');
|
|
|
58 |
}
|
59 |
|
60 |
$apiKey.change(function() {
|
@@ -65,9 +71,12 @@ var SS_WC_MailChimp = function($) {
|
|
65 |
$mainList.change(function() {
|
66 |
if ($mainList.val()) {
|
67 |
$interestGroups.removeAttr('disabled');
|
|
|
68 |
} else {
|
69 |
$interestGroups.children().remove();
|
70 |
$interestGroups.attr('disabled','disabled');
|
|
|
|
|
71 |
}
|
72 |
});
|
73 |
|
@@ -82,6 +91,7 @@ var SS_WC_MailChimp = function($) {
|
|
82 |
$mainList.on('change', function() {
|
83 |
if ($mainList.val() !== '') {
|
84 |
loadGroups($apiKey.val(), $mainList.val());
|
|
|
85 |
}
|
86 |
});
|
87 |
|
@@ -151,6 +161,31 @@ var SS_WC_MailChimp = function($) {
|
|
151 |
|
152 |
} //end function initGroups
|
153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
function checkApiKey(apiKey, shouldLoadLists = false) {
|
155 |
|
156 |
if ( $apiKey.val() === '' ) {
|
@@ -247,11 +282,11 @@ var SS_WC_MailChimp = function($) {
|
|
247 |
$mainList.select2('destroy');
|
248 |
$mainList.removeAttr('disabled');
|
249 |
$mainList.children().remove();
|
250 |
-
$.each(result, function(key, val) {
|
251 |
-
$mainList
|
252 |
.append($('<option></option>')
|
253 |
.attr('value',key)
|
254 |
-
.text(val));
|
255 |
});
|
256 |
$mainList.select2();
|
257 |
}
|
@@ -314,7 +349,7 @@ var SS_WC_MailChimp = function($) {
|
|
314 |
$interestGroups.append(
|
315 |
$('<option></option>')
|
316 |
.attr('value',id)
|
317 |
-
.text(grouping));
|
318 |
});
|
319 |
|
320 |
initGroups();
|
@@ -323,6 +358,69 @@ var SS_WC_MailChimp = function($) {
|
|
323 |
|
324 |
} //end function loadGroups
|
325 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
function toggleAllSettings( show_hide ) {
|
327 |
if (show_hide == 'show') {
|
328 |
$apiKey.closest('tr').nextAll('tr').fadeIn();
|
@@ -337,4 +435,4 @@ var SS_WC_MailChimp = function($) {
|
|
337 |
return namespace + '_' + suffix;
|
338 |
}
|
339 |
|
340 |
-
}(jQuery);
|
10 |
var $mainList;
|
11 |
var $interestGroupsLoadingIndicator;
|
12 |
var $interestGroups;
|
13 |
+
var $tagsLoadingIndicator;
|
14 |
+
var $tags;
|
15 |
var $displayOptIn;
|
16 |
var $occurs;
|
17 |
var $optInLabel;
|
26 |
checkApiKey: checkApiKey,
|
27 |
loadLists: loadLists,
|
28 |
loadGroups: loadGroups,
|
29 |
+
loadTags: loadTags,
|
30 |
};
|
31 |
|
32 |
function init() {
|
36 |
initHandlers();
|
37 |
initLists();
|
38 |
initGroups();
|
39 |
+
initTags();
|
40 |
|
41 |
} //end function init
|
42 |
|
46 |
$apiKey = $('#' + namespace_prefixed('api_key'));
|
47 |
$mainList = $('#' + namespace_prefixed('list'));
|
48 |
$interestGroups = $('#' + namespace_prefixed('interest_groups'));
|
49 |
+
$tags = $('#' + namespace_prefixed('tags'));
|
50 |
$displayOptIn = $('#' + namespace_prefixed('display_opt_in'));
|
51 |
$occurs = $('#' + namespace_prefixed('occurs'));
|
52 |
$optInLabel = $('#' + namespace_prefixed('opt_in_label'));
|
57 |
|
58 |
function initHandlers() {
|
59 |
$mainList.closest('tr').hide();
|
60 |
+
|
61 |
if ($mainList.val() === '') {
|
62 |
$interestGroups.attr('disabled','disabled');
|
63 |
+
$tags.attr('disabled','disabled');
|
64 |
}
|
65 |
|
66 |
$apiKey.change(function() {
|
71 |
$mainList.change(function() {
|
72 |
if ($mainList.val()) {
|
73 |
$interestGroups.removeAttr('disabled');
|
74 |
+
$tags.removeAttr('disabled');
|
75 |
} else {
|
76 |
$interestGroups.children().remove();
|
77 |
$interestGroups.attr('disabled','disabled');
|
78 |
+
$tags.children().remove();
|
79 |
+
$tags.attr('disabled','disabled');
|
80 |
}
|
81 |
});
|
82 |
|
91 |
$mainList.on('change', function() {
|
92 |
if ($mainList.val() !== '') {
|
93 |
loadGroups($apiKey.val(), $mainList.val());
|
94 |
+
loadTags($apiKey.val(), $mainList.val());
|
95 |
}
|
96 |
});
|
97 |
|
161 |
|
162 |
} //end function initGroups
|
163 |
|
164 |
+
function initTags() {
|
165 |
+
|
166 |
+
// Reinitialize the <optgroup> elements by splitting out the option names
|
167 |
+
var $options = $tags.children('option').clone();
|
168 |
+
|
169 |
+
$tags.attr('data-placeholder', SS_WC_MailChimp_Messages.select_tags_placeholder);
|
170 |
+
|
171 |
+
$tags.select2('destroy').select2();
|
172 |
+
var tagsMessage = $('#ss-wc-mailchimp-tags-msg').length > 0 ? $('#ss-wc-mailchimp-tags-msg') : $('<div id="ss-wc-mailchimp-tags-msg" style="display: inline-block"/>');
|
173 |
+
$tags.after(tagsMessage);
|
174 |
+
if ($options.length === 0) {
|
175 |
+
tagsMessage.text(SS_WC_MailChimp_Messages.tags_not_enabled);
|
176 |
+
$tags.siblings('.select2-container').remove();
|
177 |
+
tagsMessage.show();
|
178 |
+
} else {
|
179 |
+
$tags.siblings('.select2-container').show();
|
180 |
+
tagsMessage.hide();
|
181 |
+
}
|
182 |
+
|
183 |
+
// Add the loading indicator for tags (set to hidden by default)
|
184 |
+
$tagsLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_tags" class="woocommerce-mailchimp-loading"><span class="woocommerce-mailchimp-loading-indicator"> '+SS_WC_MailChimp_Messages.connecting_to_mailchimp+'</span></div>');
|
185 |
+
$tags.parent().append($tagsLoadingIndicator.hide());
|
186 |
+
|
187 |
+
} //end function initTags
|
188 |
+
|
189 |
function checkApiKey(apiKey, shouldLoadLists = false) {
|
190 |
|
191 |
if ( $apiKey.val() === '' ) {
|
282 |
$mainList.select2('destroy');
|
283 |
$mainList.removeAttr('disabled');
|
284 |
$mainList.children().remove();
|
285 |
+
$.each(result, function(key, val) {
|
286 |
+
$mainList
|
287 |
.append($('<option></option>')
|
288 |
.attr('value',key)
|
289 |
+
.text(val));
|
290 |
});
|
291 |
$mainList.select2();
|
292 |
}
|
349 |
$interestGroups.append(
|
350 |
$('<option></option>')
|
351 |
.attr('value',id)
|
352 |
+
.text(grouping));
|
353 |
});
|
354 |
|
355 |
initGroups();
|
358 |
|
359 |
} //end function loadGroups
|
360 |
|
361 |
+
function loadTags(apiKey, listId) {
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Load tags
|
365 |
+
*/
|
366 |
+
$tags.attr('disabled','disabled');
|
367 |
+
|
368 |
+
$tags.children().remove();
|
369 |
+
|
370 |
+
$tags.select2().hide();
|
371 |
+
$('#ss-wc-mailchimp-tags-msg').hide();
|
372 |
+
$tagsLoadingIndicator.show();
|
373 |
+
$tagsIndicator = $tagsLoadingIndicator.children().first();
|
374 |
+
$tagsIndicator.addClass('loading');
|
375 |
+
$.post(
|
376 |
+
ajaxurl,
|
377 |
+
{
|
378 |
+
'action': '' + namespace_prefixed('get_tags'),
|
379 |
+
'data': { 'api_key': apiKey, 'list_id': listId }
|
380 |
+
},
|
381 |
+
function(response) {
|
382 |
+
console.log(response);
|
383 |
+
$tagsLoadingIndicator.hide();
|
384 |
+
$tagsIndicator.removeClass('loading');
|
385 |
+
var result = [];
|
386 |
+
|
387 |
+
try {
|
388 |
+
result = $.parseJSON(response);
|
389 |
+
} catch (err) {
|
390 |
+
console.error(err);
|
391 |
+
alert(SS_WC_MailChimp_Messages.error_loading_tags);
|
392 |
+
}
|
393 |
+
|
394 |
+
if (result.error) {
|
395 |
+
$('#ss-wc-mailchimp-tags-msg').text(result.error).show();
|
396 |
+
$tags.children().remove();
|
397 |
+
$tags.select2('destroy');
|
398 |
+
$tags.hide();
|
399 |
+
return;
|
400 |
+
}
|
401 |
+
|
402 |
+
if (result.length === 0) {
|
403 |
+
$('#ss-wc-mailchimp-tags-msg').show();
|
404 |
+
initTags();
|
405 |
+
return;
|
406 |
+
}
|
407 |
+
|
408 |
+
$tags.show();
|
409 |
+
$tags.removeAttr('disabled');
|
410 |
+
$tags.children().remove();
|
411 |
+
$.each(result, function(id, grouping) {
|
412 |
+
$tags.append(
|
413 |
+
$('<option></option>')
|
414 |
+
.attr('value',id)
|
415 |
+
.text(grouping));
|
416 |
+
});
|
417 |
+
|
418 |
+
initTags();
|
419 |
+
}
|
420 |
+
);
|
421 |
+
|
422 |
+
} //end function loadTags
|
423 |
+
|
424 |
function toggleAllSettings( show_hide ) {
|
425 |
if (show_hide == 'show') {
|
426 |
$apiKey.closest('tr').nextAll('tr').fadeIn();
|
435 |
return namespace + '_' + suffix;
|
436 |
}
|
437 |
|
438 |
+
}(jQuery);
|
config/default-settings.php
CHANGED
@@ -4,6 +4,7 @@ return array(
|
|
4 |
'enabled' => 'yes',
|
5 |
'list' => '',
|
6 |
'interest_groups' => '',
|
|
|
7 |
'display_opt_in' => 'no',
|
8 |
'occurs' => 'pending',
|
9 |
'double_opt_in' => 'no',
|
@@ -11,4 +12,4 @@ return array(
|
|
11 |
'opt_in_checkbox_default_status' => 'checked',
|
12 |
'opt_in_checkbox_display_location' => 'woocommerce_review_order_before_submit',
|
13 |
'debug' => 'no',
|
14 |
-
);
|
4 |
'enabled' => 'yes',
|
5 |
'list' => '',
|
6 |
'interest_groups' => '',
|
7 |
+
'tags' => '',
|
8 |
'display_opt_in' => 'no',
|
9 |
'occurs' => 'pending',
|
10 |
'double_opt_in' => 'no',
|
12 |
'opt_in_checkbox_default_status' => 'checked',
|
13 |
'opt_in_checkbox_display_location' => 'woocommerce_review_order_before_submit',
|
14 |
'debug' => 'no',
|
15 |
+
);
|
includes/class-ss-wc-mailchimp-admin-notices.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @package WooCommerce MailChimp
|
6 |
* @author Saint Systems, LLC
|
7 |
* @link http://www.saintsystems.com
|
8 |
-
* @copyright Copyright
|
9 |
*
|
10 |
* @since 2.0.13
|
11 |
*/
|
@@ -33,7 +33,7 @@ class SS_WC_MailChimp_Admin_Notices {
|
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
-
* Dismiss a WooCommerce notice - stores the dismissed notices for
|
37 |
* @return void
|
38 |
*/
|
39 |
public function dismiss_notice() {
|
@@ -57,8 +57,8 @@ class SS_WC_MailChimp_Admin_Notices {
|
|
57 |
|
58 |
$dismissed_notices = array_unique( $dismissed_notices );
|
59 |
|
60 |
-
// Remind users every
|
61 |
-
set_transient( 'ss_wc_mailchimp_dismissed_notices', $dismissed_notices,
|
62 |
|
63 |
}
|
64 |
|
5 |
* @package WooCommerce MailChimp
|
6 |
* @author Saint Systems, LLC
|
7 |
* @link http://www.saintsystems.com
|
8 |
+
* @copyright Copyright 2019, Saint Systems, LLC
|
9 |
*
|
10 |
* @since 2.0.13
|
11 |
*/
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
+
* Dismiss a WooCommerce notice - stores the dismissed notices for 30 days
|
37 |
* @return void
|
38 |
*/
|
39 |
public function dismiss_notice() {
|
57 |
|
58 |
$dismissed_notices = array_unique( $dismissed_notices );
|
59 |
|
60 |
+
// Remind users every 30 days
|
61 |
+
set_transient( 'ss_wc_mailchimp_dismissed_notices', $dismissed_notices, DAY_IN_SECONDS * 30 );
|
62 |
|
63 |
}
|
64 |
|
includes/class-ss-wc-mailchimp-handler.php
CHANGED
@@ -93,6 +93,8 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
93 |
|
94 |
add_action( 'wp_ajax_ss_wc_mailchimp_get_interest_groups', array( $this, 'ajax_get_interest_groups' ) );
|
95 |
|
|
|
|
|
96 |
add_action( 'wp_ajax_ss_wc_mailchimp_get_merge_fields', array( $this, 'ajax_get_merge_fields' ) );
|
97 |
|
98 |
add_action( 'queue_ss_wc_mailchimp_maybe_subscribe', array( $this, 'maybe_subscribe' ), 10, 6 );
|
@@ -235,6 +237,45 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
235 |
|
236 |
} //end function ajax_get_interest_groups
|
237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
/**
|
239 |
* Return merge fields (a.k.a. merge tags) for the passed MailChimp List
|
240 |
*
|
@@ -348,12 +389,17 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
348 |
$interest_groups = $this->sswcmc->interest_groups();
|
349 |
|
350 |
if ( ! empty( $interest_groups ) ) {
|
351 |
-
$interest_groups = array_fill_keys( $
|
352 |
-
|
353 |
-
// Allow hooking into variables.
|
354 |
-
$interest_groups = apply_filters( 'ss_wc_mailchimp_subscribe_interest_groups', $interest_groups, $order_id, $email );
|
355 |
}
|
356 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
// Allow hooking into variables.
|
358 |
$merge_tags = apply_filters( 'ss_wc_mailchimp_subscribe_merge_tags', $merge_tags, $order_id, $email );
|
359 |
|
@@ -363,6 +409,7 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
363 |
'email' => $email,
|
364 |
'merge_tags' => $merge_tags,
|
365 |
'interest_groups' => $interest_groups,
|
|
|
366 |
'email_type' => 'html',
|
367 |
'double_opt_in' => $this->sswcmc->double_opt_in(),
|
368 |
);
|
@@ -384,7 +431,7 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
384 |
|
385 |
if ( ! empty( $list_id ) && ( ! $subscribe_customer || empty( $subscribe_customer ) || 'yes' === $subscribe_customer ) ) {
|
386 |
// Call API.
|
387 |
-
$api_response = $this->sswcmc->mailchimp()->subscribe( $list_id, $email, $email_type, $merge_tags, $interest_groups, $double_opt_in );
|
388 |
|
389 |
// Log api response.
|
390 |
$this->log( sprintf( __( __METHOD__ . '(): MailChimp API response: %s', 'woocommerce-mailchimp' ), print_r( $api_response, true ) ) );
|
@@ -402,7 +449,7 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
402 |
// Email admin.
|
403 |
$admin_email = get_option( 'admin_email' );
|
404 |
$admin_email = apply_filters( 'ss_wc_mailchimp_admin_email', $admin_email );
|
405 |
-
wp_mail( $admin_email, __( 'WooCommerce
|
406 |
} else {
|
407 |
// Hook on success.
|
408 |
do_action( 'ss_wc_mailchimp_subscription_success', $email, array( 'list_id' => $list_id, 'order_id' => $order_id ) );
|
93 |
|
94 |
add_action( 'wp_ajax_ss_wc_mailchimp_get_interest_groups', array( $this, 'ajax_get_interest_groups' ) );
|
95 |
|
96 |
+
add_action( 'wp_ajax_ss_wc_mailchimp_get_tags', array( $this, 'ajax_get_tags' ) );
|
97 |
+
|
98 |
add_action( 'wp_ajax_ss_wc_mailchimp_get_merge_fields', array( $this, 'ajax_get_merge_fields' ) );
|
99 |
|
100 |
add_action( 'queue_ss_wc_mailchimp_maybe_subscribe', array( $this, 'maybe_subscribe' ), 10, 6 );
|
237 |
|
238 |
} //end function ajax_get_interest_groups
|
239 |
|
240 |
+
/**
|
241 |
+
* Return tags for the passed MailChimp List to be used in select fields
|
242 |
+
*
|
243 |
+
* @access public
|
244 |
+
* @return array
|
245 |
+
*/
|
246 |
+
public function ajax_get_tags() {
|
247 |
+
|
248 |
+
try {
|
249 |
+
|
250 |
+
if ( ! $_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
251 |
+
|
252 |
+
return $this->toJSON( array( '' => __( 'Enter your api key above to see your lists', 'ss_wc_mailchimp' ) ) );
|
253 |
+
|
254 |
+
}
|
255 |
+
|
256 |
+
if ( ! $_POST['data']['list_id'] || empty( $_POST['data']['list_id'] ) ) {
|
257 |
+
|
258 |
+
return $this->toJSON( array( '' => __( 'Please select a list from above.', 'ss_wc_mailchimp' ) ) );
|
259 |
+
|
260 |
+
}
|
261 |
+
|
262 |
+
$api_key = $_POST['data']['api_key'];
|
263 |
+
$list_id = $_POST['data']['list_id'];
|
264 |
+
|
265 |
+
$tags = $this->sswcmc->mailchimp( $api_key )->get_tags( $list_id );
|
266 |
+
|
267 |
+
$results = $tags;
|
268 |
+
|
269 |
+
} catch ( Exception $e ) {
|
270 |
+
|
271 |
+
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
272 |
+
|
273 |
+
}
|
274 |
+
|
275 |
+
return $this->toJSON( $results );
|
276 |
+
|
277 |
+
} //end function ajax_get_tags
|
278 |
+
|
279 |
/**
|
280 |
* Return merge fields (a.k.a. merge tags) for the passed MailChimp List
|
281 |
*
|
389 |
$interest_groups = $this->sswcmc->interest_groups();
|
390 |
|
391 |
if ( ! empty( $interest_groups ) ) {
|
392 |
+
$interest_groups = array_fill_keys( $interest_groups, true );
|
|
|
|
|
|
|
393 |
}
|
394 |
|
395 |
+
// Allow hooking into interest groups.
|
396 |
+
$interest_groups = apply_filters( 'ss_wc_mailchimp_subscribe_interest_groups', $interest_groups, $order_id, $email );
|
397 |
+
|
398 |
+
$tags = $this->sswcmc->tags();
|
399 |
+
|
400 |
+
// Allow hooking into tags.
|
401 |
+
$tags = apply_filters( 'ss_wc_mailchimp_subscribe_tags', $tags, $order_id, $email );
|
402 |
+
|
403 |
// Allow hooking into variables.
|
404 |
$merge_tags = apply_filters( 'ss_wc_mailchimp_subscribe_merge_tags', $merge_tags, $order_id, $email );
|
405 |
|
409 |
'email' => $email,
|
410 |
'merge_tags' => $merge_tags,
|
411 |
'interest_groups' => $interest_groups,
|
412 |
+
'tags' => $tags,
|
413 |
'email_type' => 'html',
|
414 |
'double_opt_in' => $this->sswcmc->double_opt_in(),
|
415 |
);
|
431 |
|
432 |
if ( ! empty( $list_id ) && ( ! $subscribe_customer || empty( $subscribe_customer ) || 'yes' === $subscribe_customer ) ) {
|
433 |
// Call API.
|
434 |
+
$api_response = $this->sswcmc->mailchimp()->subscribe( $list_id, $email, $email_type, $merge_tags, $interest_groups, $double_opt_in, $tags );
|
435 |
|
436 |
// Log api response.
|
437 |
$this->log( sprintf( __( __METHOD__ . '(): MailChimp API response: %s', 'woocommerce-mailchimp' ), print_r( $api_response, true ) ) );
|
449 |
// Email admin.
|
450 |
$admin_email = get_option( 'admin_email' );
|
451 |
$admin_email = apply_filters( 'ss_wc_mailchimp_admin_email', $admin_email );
|
452 |
+
wp_mail( $admin_email, __( 'WooCommerce Mailchimp subscription failed', 'woocommerce-mailchimp' ), $error_response );
|
453 |
} else {
|
454 |
// Hook on success.
|
455 |
do_action( 'ss_wc_mailchimp_subscription_success', $email, array( 'list_id' => $list_id, 'order_id' => $order_id ) );
|
includes/class-ss-wc-mailchimp-plugin.php
CHANGED
@@ -15,7 +15,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
15 |
*
|
16 |
* @var string
|
17 |
*/
|
18 |
-
private static $version = '2.
|
19 |
|
20 |
/**
|
21 |
* Plugin singleton instance
|
@@ -229,7 +229,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
229 |
}
|
230 |
|
231 |
/**
|
232 |
-
* Returns selected
|
233 |
*
|
234 |
* @access public
|
235 |
* @return array
|
@@ -238,6 +238,16 @@ final class SS_WC_MailChimp_Plugin {
|
|
238 |
return $this->settings['interest_groups'];
|
239 |
}
|
240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
/**
|
242 |
* Whether or not an api key has been set.
|
243 |
*
|
@@ -393,7 +403,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
393 |
|
394 |
add_filter( 'plugin_action_links_' . plugin_basename( SS_WC_MAILCHIMP_FILE ), array( $this, 'action_links' ) );
|
395 |
|
396 |
-
|
397 |
|
398 |
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_mailchimp_settings' ) );
|
399 |
|
@@ -476,16 +486,14 @@ final class SS_WC_MailChimp_Plugin {
|
|
476 |
public static function plugin_row_meta( $links, $file ) {
|
477 |
if ( plugin_basename( SS_WC_MAILCHIMP_FILE ) === $file ) {
|
478 |
$row_meta = array(
|
479 |
-
'docs'
|
480 |
);
|
481 |
|
482 |
if ( ! function_exists( 'SSWCMCPRO' ) ) {
|
483 |
-
$row_meta[] =
|
484 |
-
'upgrade' => '<a href="' . esc_url( apply_filters( 'ss_wc_mailchimp_support_url', 'https://www.saintsystems.com/products/woocommerce-mailchimp-pro/#utm_source=wp-plugin&utm_medium=woocommerce-mailchimp&utm_campaign=plugins-upgrade-link' ) ) . '" aria-label="' . esc_attr__( 'Upgrade to WooCommerce MailChimp Pro', 'woocommerce-mailchimp' ) . '" target="_blank">' . esc_html__( 'Upgrade to Pro', 'woocommerce-mailchimp' ) . '</a>',
|
485 |
-
);
|
486 |
}
|
487 |
|
488 |
-
return array_merge( $
|
489 |
}
|
490 |
|
491 |
return (array) $links;
|
@@ -523,11 +531,14 @@ final class SS_WC_MailChimp_Plugin {
|
|
523 |
|
524 |
// Localize javascript messages.
|
525 |
$translation_array = array(
|
526 |
-
'connecting_to_mailchimp' => __( 'Connecting to
|
527 |
'error_loading_account' => __( 'Error. Please check your api key.', 'woocommerce-mailchimp' ),
|
528 |
-
'error_loading_groups' => __( 'Error loading groups. Please check your
|
529 |
'select_groups_placeholder' => __( 'Select one or more groups (optional)', 'woocommerce-mailchimp' ),
|
530 |
'interest_groups_not_enabled' => __( 'This list does not have interest groups enabled', 'woocommerce-mailchimp' ),
|
|
|
|
|
|
|
531 |
);
|
532 |
wp_localize_script( 'woocommerce-mailchimp-admin', 'SS_WC_MailChimp_Messages', $translation_array );
|
533 |
|
15 |
*
|
16 |
* @var string
|
17 |
*/
|
18 |
+
private static $version = '2.3.0';
|
19 |
|
20 |
/**
|
21 |
* Plugin singleton instance
|
229 |
}
|
230 |
|
231 |
/**
|
232 |
+
* Returns selected Mailchimp interest groups.
|
233 |
*
|
234 |
* @access public
|
235 |
* @return array
|
238 |
return $this->settings['interest_groups'];
|
239 |
}
|
240 |
|
241 |
+
/**
|
242 |
+
* Returns selected Mailchimp tags.
|
243 |
+
*
|
244 |
+
* @access public
|
245 |
+
* @return array
|
246 |
+
*/
|
247 |
+
public function tags() {
|
248 |
+
return $this->settings['tags'];
|
249 |
+
}
|
250 |
+
|
251 |
/**
|
252 |
* Whether or not an api key has been set.
|
253 |
*
|
403 |
|
404 |
add_filter( 'plugin_action_links_' . plugin_basename( SS_WC_MAILCHIMP_FILE ), array( $this, 'action_links' ) );
|
405 |
|
406 |
+
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
|
407 |
|
408 |
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_mailchimp_settings' ) );
|
409 |
|
486 |
public static function plugin_row_meta( $links, $file ) {
|
487 |
if ( plugin_basename( SS_WC_MAILCHIMP_FILE ) === $file ) {
|
488 |
$row_meta = array(
|
489 |
+
'docs' => '<a href="' . esc_url( apply_filters( 'ss_wc_mailchimp_docs_url', 'https://support.saintsystems.com/hc/en-us/sections/201959566' ) ) . '" aria-label="' . esc_attr__( 'View WooCommerce Mailchimp documentation', 'woocommerce-mailchimp' ) . '" target="_blank">' . esc_html__( 'Documentation', 'woocommerce-mailchimp' ) . '</a>',
|
490 |
);
|
491 |
|
492 |
if ( ! function_exists( 'SSWCMCPRO' ) ) {
|
493 |
+
$row_meta['upgrade'] = '<a href="' . esc_url( apply_filters( 'ss_wc_mailchimp_support_url', 'https://www.saintsystems.com/products/woocommerce-mailchimp-pro/#utm_source=wp-plugin&utm_medium=woocommerce-mailchimp&utm_campaign=plugins-upgrade-link' ) ) . '" aria-label="' . esc_attr__( 'Upgrade to WooCommerce Mailchimp Pro', 'woocommerce-mailchimp' ) . '" target="_blank">' . esc_html__( 'Upgrade to Pro', 'woocommerce-mailchimp' ) . '</a>';
|
|
|
|
|
494 |
}
|
495 |
|
496 |
+
return array_merge( $links, $row_meta );
|
497 |
}
|
498 |
|
499 |
return (array) $links;
|
531 |
|
532 |
// Localize javascript messages.
|
533 |
$translation_array = array(
|
534 |
+
'connecting_to_mailchimp' => __( 'Connecting to Mailchimp', 'woocommerce-mailchimp' ),
|
535 |
'error_loading_account' => __( 'Error. Please check your api key.', 'woocommerce-mailchimp' ),
|
536 |
+
'error_loading_groups' => __( 'Error loading groups. Please check your Mailchimp Interest Groups for the selected list.', 'woocommerce-mailchimp' ),
|
537 |
'select_groups_placeholder' => __( 'Select one or more groups (optional)', 'woocommerce-mailchimp' ),
|
538 |
'interest_groups_not_enabled' => __( 'This list does not have interest groups enabled', 'woocommerce-mailchimp' ),
|
539 |
+
'error_loading_tags' => __( 'Error loading tags. Please check your Mailchimp tags for the selected list.', 'woocommerce-mailchimp' ),
|
540 |
+
'select_tags_placeholder' => __( 'Select one or more tags (optional)', 'woocommerce-mailchimp' ),
|
541 |
+
'tags_not_enabled' => __( 'This list does not have tags enabled', 'woocommerce-mailchimp' ),
|
542 |
);
|
543 |
wp_localize_script( 'woocommerce-mailchimp-admin', 'SS_WC_MailChimp_Messages', $translation_array );
|
544 |
|
includes/class-ss-wc-mailchimp.php
CHANGED
@@ -110,7 +110,7 @@ class SS_WC_MailChimp {
|
|
110 |
|
111 |
}
|
112 |
|
113 |
-
set_transient( 'sswcmc_lists', $results,
|
114 |
|
115 |
}
|
116 |
|
@@ -118,6 +118,46 @@ class SS_WC_MailChimp {
|
|
118 |
|
119 |
} //end function get_lists
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
/**
|
122 |
* Get Subscriber
|
123 |
* @param string $list_id The MailChimp list ID
|
@@ -150,7 +190,7 @@ class SS_WC_MailChimp {
|
|
150 |
* @param boolean $double_opt_in Whether to send a double opt-in email to confirm subscription
|
151 |
* @return mixed $response The MailChimp API response
|
152 |
*/
|
153 |
-
public function subscribe( $list_id, $email_address, $email_type, $merge_fields, $interests, $double_opt_in ) {
|
154 |
|
155 |
$args = array(
|
156 |
'email_address' => $email_address,
|
@@ -180,6 +220,19 @@ class SS_WC_MailChimp {
|
|
180 |
return false;
|
181 |
}
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
return $response;
|
184 |
|
185 |
} //end function subscribe
|
@@ -258,7 +311,7 @@ class SS_WC_MailChimp {
|
|
258 |
}
|
259 |
|
260 |
// Cache list merge tags for 15 minutes
|
261 |
-
set_transient( "sswcmc_{$list_id}_merge_fields", $results,
|
262 |
|
263 |
}
|
264 |
|
@@ -295,7 +348,7 @@ class SS_WC_MailChimp {
|
|
295 |
|
296 |
}
|
297 |
|
298 |
-
set_transient( "sswcmc_{$list_id}_interest_categories", $results,
|
299 |
|
300 |
}
|
301 |
|
@@ -333,7 +386,7 @@ class SS_WC_MailChimp {
|
|
333 |
|
334 |
}
|
335 |
|
336 |
-
set_transient( "sswcmc_{$list_id}_{$interest_category_id }_interests", $results,
|
337 |
|
338 |
}
|
339 |
|
@@ -403,11 +456,11 @@ class SS_WC_MailChimp {
|
|
403 |
|
404 |
foreach ( $tags as $tag ) {
|
405 |
|
406 |
-
$results[ $tag['
|
407 |
|
408 |
}
|
409 |
|
410 |
-
set_transient( "sswcmc_{$list_id}_tags", $results,
|
411 |
|
412 |
}
|
413 |
|
110 |
|
111 |
}
|
112 |
|
113 |
+
set_transient( 'sswcmc_lists', $results, MINUTE_IN_SECONDS * 5 );
|
114 |
|
115 |
}
|
116 |
|
118 |
|
119 |
} //end function get_lists
|
120 |
|
121 |
+
/**
|
122 |
+
* Get list
|
123 |
+
*
|
124 |
+
* @access public
|
125 |
+
* @return mixed
|
126 |
+
*/
|
127 |
+
public function get_list_web_ids( $args = array() ) {
|
128 |
+
|
129 |
+
if ( ! $results = get_transient( 'sswcmc_list_web_ids' ) ) {
|
130 |
+
|
131 |
+
$resource = 'lists/';
|
132 |
+
|
133 |
+
if ( ! array_key_exists( 'count', $args ) ) {
|
134 |
+
$args['count'] = 100;
|
135 |
+
}
|
136 |
+
|
137 |
+
$response = $this->api->get( $resource, $args );
|
138 |
+
|
139 |
+
if ( ! $response ) {
|
140 |
+
return false;
|
141 |
+
}
|
142 |
+
|
143 |
+
$lists = $response['lists'];
|
144 |
+
|
145 |
+
$results = array();
|
146 |
+
|
147 |
+
foreach ( $lists as $list ) {
|
148 |
+
|
149 |
+
$results[ (string)$list['id'] ] = $list['web_id'];
|
150 |
+
|
151 |
+
}
|
152 |
+
|
153 |
+
set_transient( 'sswcmc_list_web_ids', $results, MINUTE_IN_SECONDS * 5 );
|
154 |
+
|
155 |
+
}
|
156 |
+
|
157 |
+
return $results;
|
158 |
+
|
159 |
+
} //end function get_list_web_ids
|
160 |
+
|
161 |
/**
|
162 |
* Get Subscriber
|
163 |
* @param string $list_id The MailChimp list ID
|
190 |
* @param boolean $double_opt_in Whether to send a double opt-in email to confirm subscription
|
191 |
* @return mixed $response The MailChimp API response
|
192 |
*/
|
193 |
+
public function subscribe( $list_id, $email_address, $email_type, $merge_fields, $interests, $double_opt_in, $tags = array() ) {
|
194 |
|
195 |
$args = array(
|
196 |
'email_address' => $email_address,
|
220 |
return false;
|
221 |
}
|
222 |
|
223 |
+
if ( is_array( $tags ) && !empty( $tags ) ) {
|
224 |
+
|
225 |
+
$args = array(
|
226 |
+
'tags' => $tags
|
227 |
+
);
|
228 |
+
|
229 |
+
do_action( 'sswcmc_log', __METHOD__ . ' Attempting to add tags to subscriber ('.$email_address.'): ' . print_r( $args, true ) );
|
230 |
+
|
231 |
+
$response_tags = $this->api->post( $resource . '/tags', $args );
|
232 |
+
|
233 |
+
do_action( 'sswcmc_log', __METHOD__ . ' Subscriber tags response: ' . print_r( $response_tags, true ) );
|
234 |
+
}
|
235 |
+
|
236 |
return $response;
|
237 |
|
238 |
} //end function subscribe
|
311 |
}
|
312 |
|
313 |
// Cache list merge tags for 15 minutes
|
314 |
+
set_transient( "sswcmc_{$list_id}_merge_fields", $results, MINUTE_IN_SECONDS * 5 );
|
315 |
|
316 |
}
|
317 |
|
348 |
|
349 |
}
|
350 |
|
351 |
+
set_transient( "sswcmc_{$list_id}_interest_categories", $results, MINUTE_IN_SECONDS * 5 );
|
352 |
|
353 |
}
|
354 |
|
386 |
|
387 |
}
|
388 |
|
389 |
+
set_transient( "sswcmc_{$list_id}_{$interest_category_id }_interests", $results, MINUTE_IN_SECONDS * 5 );
|
390 |
|
391 |
}
|
392 |
|
456 |
|
457 |
foreach ( $tags as $tag ) {
|
458 |
|
459 |
+
$results[ $tag['name'] ] = $tag['name'];
|
460 |
|
461 |
}
|
462 |
|
463 |
+
set_transient( "sswcmc_{$list_id}_tags", $results, MINUTE_IN_SECONDS * 5 );
|
464 |
|
465 |
}
|
466 |
|
includes/class-ss-wc-settings-mailchimp.php
CHANGED
@@ -146,6 +146,16 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
146 |
return $this->get_option( 'interest_groups' );
|
147 |
}
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
/**
|
150 |
* has_list function.
|
151 |
*
|
@@ -311,11 +321,17 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
311 |
|
312 |
if ( '' === $current_section ) {
|
313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
$settings = array(
|
315 |
array(
|
316 |
'title' => __( 'MailChimp', 'woocommerce-mailchimp' ),
|
317 |
'type' => 'title',
|
318 |
-
'desc' =>
|
319 |
'id' => 'general_options',
|
320 |
),
|
321 |
);
|
@@ -324,9 +340,9 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
324 |
'id' => $this->namespace_prefixed( 'api_key' ),
|
325 |
'title' => __( 'API Key', 'woocommerce-mailchimp' ),
|
326 |
'type' => 'text',
|
327 |
-
'desc' => sprintf( __( '%sLogin to
|
328 |
),
|
329 |
-
'placeholder' => __( 'Paste your
|
330 |
'default' => '',
|
331 |
'css' => 'min-width:350px;',
|
332 |
'desc_tip' => 'Your API Key is required for the plugin to communicate with your MailChimp account.',
|
@@ -341,12 +357,18 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
341 |
'default' => 'yes',
|
342 |
);
|
343 |
|
344 |
-
|
|
|
|
|
|
|
|
|
345 |
|
346 |
if ( $this->has_api_key() && $this->has_list() ) {
|
347 |
$interest_groups = $this->get_interest_groups();
|
|
|
348 |
} else {
|
349 |
$interest_groups = array();
|
|
|
350 |
}
|
351 |
|
352 |
$settings[] = array(
|
@@ -365,7 +387,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
365 |
'id' => $this->namespace_prefixed( 'interest_groups' ),
|
366 |
'title' => __( 'Interest Groups', 'woocommerce-mailchimp' ),
|
367 |
'type' => 'multiselect',
|
368 |
-
'desc'
|
369 |
'default' => '',
|
370 |
'options' => $interest_groups,
|
371 |
'class' => 'wc-enhanced-select',
|
@@ -376,7 +398,24 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
376 |
'desc_tip' => true,
|
377 |
);
|
378 |
|
379 |
-
$settings = apply_filters(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
|
381 |
$settings[] = array(
|
382 |
'id' => $this->namespace_prefixed( 'occurs' ),
|
@@ -418,6 +457,8 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
418 |
)
|
419 |
);
|
420 |
|
|
|
|
|
421 |
$settings[] = array(
|
422 |
'id' => $this->namespace_prefixed( 'opt_in_label' ),
|
423 |
'title' => __( 'Opt-In Field Label', 'woocommerce-mailchimp' ),
|
@@ -630,6 +671,30 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
630 |
|
631 |
}
|
632 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
633 |
/**
|
634 |
* Inform the user they don't have any MailChimp lists
|
635 |
*/
|
146 |
return $this->get_option( 'interest_groups' );
|
147 |
}
|
148 |
|
149 |
+
/**
|
150 |
+
* tags function.
|
151 |
+
*
|
152 |
+
* @access public
|
153 |
+
* @return array
|
154 |
+
*/
|
155 |
+
public function tags() {
|
156 |
+
return $this->get_option( 'tags' );
|
157 |
+
}
|
158 |
+
|
159 |
/**
|
160 |
* has_list function.
|
161 |
*
|
321 |
|
322 |
if ( '' === $current_section ) {
|
323 |
|
324 |
+
$desc = __( 'Enter your MailChimp settings below to control how WooCommerce integrates with your MailChimp account.', 'woocommerce-mailchimp' );
|
325 |
+
$desc_pro = '';
|
326 |
+
if ( ! function_exists( 'SSWCMCPRO' ) ) {
|
327 |
+
$desc_pro = sprintf( __( '%sUpgrade to Pro%s to unlock several powerful features including %sWooCommerce Subscriptions%s support and product-specific lists, groups and tags.', 'woocommerce-mailchimp' ), '<p/><a href="https://www.saintsystems.com/products/woocommerce-mailchimp-pro/#utm_source=wp-plugin&utm_medium=woocommerce-mailchimp&utm_campaign=plugin-settings-page" target="_blank">', '</a>', '<a href="https://woocommerce.com/products/woocommerce-subscriptions/" target="_blank">', '</a>' );
|
328 |
+
}
|
329 |
+
|
330 |
$settings = array(
|
331 |
array(
|
332 |
'title' => __( 'MailChimp', 'woocommerce-mailchimp' ),
|
333 |
'type' => 'title',
|
334 |
+
'desc' => $desc . $desc_pro,
|
335 |
'id' => 'general_options',
|
336 |
),
|
337 |
);
|
340 |
'id' => $this->namespace_prefixed( 'api_key' ),
|
341 |
'title' => __( 'API Key', 'woocommerce-mailchimp' ),
|
342 |
'type' => 'text',
|
343 |
+
'desc' => sprintf( __( '%sLogin to Mailchimp%s to look up your api key.', 'woocommerce-mailchimp' ), '<br/><a href="https://admin.mailchimp.com/account/api/" target="_blank">', '</a>'
|
344 |
),
|
345 |
+
'placeholder' => __( 'Paste your Mailchimp API key here', 'woocommerce-mailchimp' ),
|
346 |
'default' => '',
|
347 |
'css' => 'min-width:350px;',
|
348 |
'desc_tip' => 'Your API Key is required for the plugin to communicate with your MailChimp account.',
|
357 |
'default' => 'yes',
|
358 |
);
|
359 |
|
360 |
+
if ( $this->has_api_key() ) {
|
361 |
+
$mailchimp_lists = $this->get_lists();
|
362 |
+
} else {
|
363 |
+
$mailchimp_lists = array();
|
364 |
+
}
|
365 |
|
366 |
if ( $this->has_api_key() && $this->has_list() ) {
|
367 |
$interest_groups = $this->get_interest_groups();
|
368 |
+
$tags = $this->get_tags();
|
369 |
} else {
|
370 |
$interest_groups = array();
|
371 |
+
$tags = array();
|
372 |
}
|
373 |
|
374 |
$settings[] = array(
|
387 |
'id' => $this->namespace_prefixed( 'interest_groups' ),
|
388 |
'title' => __( 'Interest Groups', 'woocommerce-mailchimp' ),
|
389 |
'type' => 'multiselect',
|
390 |
+
'desc' => __( 'Optional: Interest groups to assign to subscribers.', 'woocommerce-mailchimp' ),
|
391 |
'default' => '',
|
392 |
'options' => $interest_groups,
|
393 |
'class' => 'wc-enhanced-select',
|
398 |
'desc_tip' => true,
|
399 |
);
|
400 |
|
401 |
+
$settings = apply_filters( 'ss_wc_mailchimp_settings_general_after_interest_groups' , $settings );
|
402 |
+
|
403 |
+
$settings[] = array(
|
404 |
+
'id' => $this->namespace_prefixed( 'tags' ),
|
405 |
+
'title' => __( 'Tags', 'woocommerce-mailchimp' ),
|
406 |
+
'type' => 'multiselect',
|
407 |
+
'desc' => __( 'Optional: Tags to assign to subscribers.', 'woocommerce-mailchimp' ),
|
408 |
+
'default' => '',
|
409 |
+
'options' => $tags,
|
410 |
+
'class' => 'wc-enhanced-select',
|
411 |
+
'custom_attributes' => array(
|
412 |
+
'placeholder' => __( 'Select tags...', 'woocommerce-mailchimp' ),
|
413 |
+
),
|
414 |
+
'css' => 'min-width: 350px;',
|
415 |
+
'desc_tip' => true,
|
416 |
+
);
|
417 |
+
|
418 |
+
$settings = apply_filters( 'ss_wc_mailchimp_settings_general_after_tags' , $settings );
|
419 |
|
420 |
$settings[] = array(
|
421 |
'id' => $this->namespace_prefixed( 'occurs' ),
|
457 |
)
|
458 |
);
|
459 |
|
460 |
+
$settings = apply_filters( 'ss_wc_mailchimp_settings_general_after_display_opt_in' , $settings );
|
461 |
+
|
462 |
$settings[] = array(
|
463 |
'id' => $this->namespace_prefixed( 'opt_in_label' ),
|
464 |
'title' => __( 'Opt-In Field Label', 'woocommerce-mailchimp' ),
|
671 |
|
672 |
}
|
673 |
|
674 |
+
/**
|
675 |
+
* get_tags function.
|
676 |
+
*
|
677 |
+
* @access public
|
678 |
+
* @return void
|
679 |
+
*/
|
680 |
+
public function get_tags() {
|
681 |
+
|
682 |
+
if ( $this->mailchimp() && $this->has_list() ) {
|
683 |
+
$tags = $this->mailchimp()->get_tags( $this->get_list() );
|
684 |
+
} else {
|
685 |
+
return array();
|
686 |
+
}
|
687 |
+
|
688 |
+
if ( $tags === false ) {
|
689 |
+
|
690 |
+
return array();
|
691 |
+
|
692 |
+
}
|
693 |
+
|
694 |
+
return $tags;
|
695 |
+
|
696 |
+
}
|
697 |
+
|
698 |
/**
|
699 |
* Inform the user they don't have any MailChimp lists
|
700 |
*/
|
includes/migrations/class-ss-wc-migration.php
CHANGED
@@ -22,6 +22,7 @@ abstract class SS_WC_MailChimp_Migration {
|
|
22 |
'enabled',
|
23 |
'list',
|
24 |
'interest_groups',
|
|
|
25 |
'display_opt_in',
|
26 |
'occurs',
|
27 |
'double_opt_in',
|
@@ -95,4 +96,4 @@ abstract class SS_WC_MailChimp_Migration {
|
|
95 |
return $this->namespace . '_' . $suffix;
|
96 |
}
|
97 |
|
98 |
-
}
|
22 |
'enabled',
|
23 |
'list',
|
24 |
'interest_groups',
|
25 |
+
'tags',
|
26 |
'display_opt_in',
|
27 |
'occurs',
|
28 |
'double_opt_in',
|
96 |
return $this->namespace . '_' . $suffix;
|
97 |
}
|
98 |
|
99 |
+
}
|
readme.txt
CHANGED
@@ -1,32 +1,37 @@
|
|
1 |
-
=== WooCommerce
|
2 |
Contributors: saintsystems, anderly
|
3 |
Donate link: http://ssms.us/hVdk
|
4 |
-
Tags: woocommerce, mailchimp
|
5 |
Requires at least: 4.7.0
|
6 |
Tested up to: 5.2.2
|
7 |
WC tested up to: 3.6.5
|
8 |
-
|
|
|
9 |
License: GPLv3
|
10 |
|
11 |
-
Simple and flexible
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
WooCommerce
|
16 |
|
17 |
-
Automatically subscribe customers to a designated
|
|
|
|
|
|
|
18 |
|
19 |
= Features =
|
20 |
|
21 |
**WooCommerce Event Selection**
|
22 |
|
23 |
-
- Subscribe customers to
|
24 |
-
- Subscribe customers to
|
25 |
-
- Subscribe customers to
|
26 |
|
27 |
-
**Works with
|
28 |
|
29 |
-
- Set one or more interest groups to add users to based on the selected
|
|
|
30 |
|
31 |
**Opt-In Settings**
|
32 |
|
@@ -40,7 +45,7 @@ Automatically subscribe customers to a designated MailChimp list and, optionally
|
|
40 |
|
41 |
Would you like to help translate the plugin into more languages? Join our Translations Community at https://translate.wordpress.org/projects/wp-plugins/woocommerce-mailchimp.
|
42 |
|
43 |
-
WooCommerce
|
44 |
|
45 |
Thanks in advance for your help on any translation efforts!
|
46 |
|
@@ -73,7 +78,7 @@ If no custom translations are present, languages will be loaded in the following
|
|
73 |
|
74 |
= Requirements =
|
75 |
|
76 |
-
WooCommerce
|
77 |
|
78 |
= Documentation & Support =
|
79 |
|
@@ -82,7 +87,7 @@ Online documentation and code samples are available via our [Help Center](https:
|
|
82 |
Please visit the
|
83 |
[WooCommerce MailChimp support forum on WordPress.org](https://wordpress.org/support/plugin/woocommerce-mailchimp) for basic support and help from other users. Since this is a free plugin, we respond to these as we have time.
|
84 |
|
85 |
-
Dedicated support will
|
86 |
|
87 |
= Contribute =
|
88 |
All development for WooCommerce MailChimp is [handled via GitHub](https://github.com/anderly/woocommerce-mailchimp). Opening new issues and submitting pull requests are welcome.
|
@@ -91,7 +96,7 @@ All development for WooCommerce MailChimp is [handled via GitHub](https://github
|
|
91 |
|
92 |
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).
|
93 |
|
94 |
-
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
|
95 |
|
96 |
== Installation ==
|
97 |
|
@@ -100,20 +105,24 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
|
|
100 |
|
101 |
= Usage =
|
102 |
|
103 |
-
1. Go to WooCommerce > Settings >
|
104 |
2. First, paste your MailChimp API Key to get started.
|
105 |
-
3. Select whether you want customers to be subscribed to your
|
106 |
-
4. Next, select your
|
107 |
5. Select your opt-in, double opt-in settings and hit `Save changes`.
|
108 |
-
6. That's it, your WooCommerce store is now integrated with
|
109 |
|
110 |
== Screenshots ==
|
111 |
|
112 |
-
1. WooCommerce
|
113 |
-
2. WooCommerce
|
114 |
|
115 |
== Changelog ==
|
116 |
|
|
|
|
|
|
|
|
|
117 |
#### 2.2.0 - July 23, 2019
|
118 |
- Bump min WC version to 3.5.0, and min WP version to 4.7.0.
|
119 |
- Bump min PHP version to 5.6 in prep for WooCoommerce 3.7 requirements.
|
1 |
+
=== WooCommerce Mailchimp ===
|
2 |
Contributors: saintsystems, anderly
|
3 |
Donate link: http://ssms.us/hVdk
|
4 |
+
Tags: woocommerce, mailchimp, ecommerce, email
|
5 |
Requires at least: 4.7.0
|
6 |
Tested up to: 5.2.2
|
7 |
WC tested up to: 3.6.5
|
8 |
+
Requires PHP: 5.6
|
9 |
+
Stable tag: 2.3.0
|
10 |
License: GPLv3
|
11 |
|
12 |
+
Simple and flexible Mailchimp integration for WooCommerce.
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
+
WooCommerce Mailchimp provides simple and flexible Mailchimp integration for WooCommerce.
|
17 |
|
18 |
+
Automatically subscribe customers to a designated Mailchimp list and, optionally, Mailchimp interest groups and tags upon order creation or order completion.
|
19 |
+
This can be done quietly or based on the user's consent with several opt-in settings that support international opt-in laws.
|
20 |
+
|
21 |
+
Upgrade to [WooCommerce Mailchimp Pro](https://www.saintsystems.com/products/woocommerce-mailchimp-pro/) for more advanced features including WooCommerce Subscriptions support and the ability to set product-specific lists, groups and tags.
|
22 |
|
23 |
= Features =
|
24 |
|
25 |
**WooCommerce Event Selection**
|
26 |
|
27 |
+
- Subscribe customers to Mailchimp after order creation
|
28 |
+
- Subscribe customers to Mailchimp after order processing
|
29 |
+
- Subscribe customers to Mailchimp after order completion
|
30 |
|
31 |
+
**Works with Mailchimp Interest Groups and Tags**
|
32 |
|
33 |
+
- Set one or more interest groups to add users to based on the selected Mailchimp list.
|
34 |
+
- Set one or more tags to add users to based on the selected Mailchimp list.
|
35 |
|
36 |
**Opt-In Settings**
|
37 |
|
45 |
|
46 |
Would you like to help translate the plugin into more languages? Join our Translations Community at https://translate.wordpress.org/projects/wp-plugins/woocommerce-mailchimp.
|
47 |
|
48 |
+
WooCommerce Mailchimp translation is managed through WordPress language packs here: https://translate.wordpress.org. This allows WooCommerce Mailchimp to be translated into other languages. The preferred tool for translating plugins is called [GlotPress](https://make.wordpress.org/polyglots/handbook/tools/glotpress-translate-wordpress-org/). You can [read about how GlotPress works in the WordPress Translator's Handbook](https://make.wordpress.org/polyglots/handbook/tools/glotpress-translate-wordpress-org/).
|
49 |
|
50 |
Thanks in advance for your help on any translation efforts!
|
51 |
|
78 |
|
79 |
= Requirements =
|
80 |
|
81 |
+
WooCommerce Mailchimp requires PHP 5.6+ (PHP 7.0+ recommended). You'll also need to be running WordPress 4.7.0+ and have WooCommerce 3.5.0+.
|
82 |
|
83 |
= Documentation & Support =
|
84 |
|
87 |
Please visit the
|
88 |
[WooCommerce MailChimp support forum on WordPress.org](https://wordpress.org/support/plugin/woocommerce-mailchimp) for basic support and help from other users. Since this is a free plugin, we respond to these as we have time.
|
89 |
|
90 |
+
Dedicated support will is available for [WooCommerce MailChimp Pro](https://www.saintsystems.com/products/woocommerce-mailchimp-pro/) customers.
|
91 |
|
92 |
= Contribute =
|
93 |
All development for WooCommerce MailChimp is [handled via GitHub](https://github.com/anderly/woocommerce-mailchimp). Opening new issues and submitting pull requests are welcome.
|
96 |
|
97 |
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).
|
98 |
|
99 |
+
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/?rate=5#new-post)!
|
100 |
|
101 |
== Installation ==
|
102 |
|
105 |
|
106 |
= Usage =
|
107 |
|
108 |
+
1. Go to WooCommerce > Settings > Mailchimp
|
109 |
2. First, paste your MailChimp API Key to get started.
|
110 |
+
3. Select whether you want customers to be subscribed to your Mailchimp list after order creation, order processing or order completion (there's a difference in WooCommerce).
|
111 |
+
4. Next, select your Mailchimp list and select any interest groups (optional).
|
112 |
5. Select your opt-in, double opt-in settings and hit `Save changes`.
|
113 |
+
6. That's it, your WooCommerce store is now integrated with Mailchimp!
|
114 |
|
115 |
== Screenshots ==
|
116 |
|
117 |
+
1. WooCommerce Mailchimp general settings screen.
|
118 |
+
2. WooCommerce Mailchimp troubleshooting screen.
|
119 |
|
120 |
== Changelog ==
|
121 |
|
122 |
+
#### 2.3.0 - July 25, 2019
|
123 |
+
- Added support for tags on main list.
|
124 |
+
- Improved integration with WooCommerce Mailchimp Pro.
|
125 |
+
|
126 |
#### 2.2.0 - July 23, 2019
|
127 |
- Bump min WC version to 3.5.0, and min WP version to 4.7.0.
|
128 |
- Bump min PHP version to 5.6 in prep for WooCoommerce 3.7 requirements.
|
woocommerce-mailchimp.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Plugin Name: WooCommerce
|
4 |
* Plugin URI: https://www.saintsystems.com/products/woocommerce-mailchimp/
|
5 |
-
* Description: WooCommerce
|
6 |
* Author: Saint Systems
|
7 |
* Author URI: https://www.saintsystems.com
|
8 |
-
* Version: 2.
|
9 |
* WC tested up to: 3.6.5
|
10 |
* Text Domain: woocommerce-mailchimp
|
11 |
* Domain Path: languages
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Plugin Name: WooCommerce Mailchimp
|
4 |
* Plugin URI: https://www.saintsystems.com/products/woocommerce-mailchimp/
|
5 |
+
* Description: WooCommerce Mailchimp provides simple and flexible Mailchimp integration for WooCommerce.
|
6 |
* Author: Saint Systems
|
7 |
* Author URI: https://www.saintsystems.com
|
8 |
+
* Version: 2.3.0
|
9 |
* WC tested up to: 3.6.5
|
10 |
* Text Domain: woocommerce-mailchimp
|
11 |
* Domain Path: languages
|