Version Description
Download this release
Release Info
Developer | anderly |
Plugin | WooCommerce MailChimp |
Version | 2.1.0 |
Comparing to | |
See all releases |
Code changes from version 2.0.20 to 2.1.0
includes/class-ss-wc-mailchimp-api.php
CHANGED
@@ -13,33 +13,33 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
13 |
class SS_WC_MailChimp_API {
|
14 |
|
15 |
/**
|
16 |
-
|
17 |
-
|
18 |
public $api_key;
|
19 |
|
20 |
/**
|
21 |
-
|
22 |
-
|
23 |
public $datacenter = 'us1';
|
24 |
|
25 |
/**
|
26 |
-
|
27 |
-
|
28 |
private $api_root = 'https://<dc>.api.mailchimp.com/3.0/';
|
29 |
|
30 |
/**
|
31 |
-
|
32 |
-
|
33 |
private $debug = false;
|
34 |
|
35 |
/**
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
private $last_error;
|
44 |
|
45 |
/**
|
@@ -68,11 +68,11 @@ class SS_WC_MailChimp_API {
|
|
68 |
} //end function __construct
|
69 |
|
70 |
/**
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
public function get( $resource, $args = array() ) {
|
77 |
|
78 |
if ( is_array( $args) && ! array_key_exists( 'count', $args ) ) {
|
@@ -84,11 +84,11 @@ class SS_WC_MailChimp_API {
|
|
84 |
} //end function post
|
85 |
|
86 |
/**
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
public function post( $resource, $args = array() ) {
|
93 |
|
94 |
return $this->api_request( 'POST', $resource, $args );
|
@@ -96,11 +96,11 @@ class SS_WC_MailChimp_API {
|
|
96 |
} //end function post
|
97 |
|
98 |
/**
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
public function put( $resource, $args = array() ) {
|
105 |
|
106 |
return $this->api_request( 'PUT', $resource, $args );
|
@@ -108,11 +108,11 @@ class SS_WC_MailChimp_API {
|
|
108 |
} //end function put
|
109 |
|
110 |
/**
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
public function patch( $resource, $args = array() ) {
|
117 |
|
118 |
return $this->api_request( 'PATCH', $resource, $args );
|
@@ -120,11 +120,11 @@ class SS_WC_MailChimp_API {
|
|
120 |
} //end function patch
|
121 |
|
122 |
/**
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
public function delete( $resource, $args = array() ) {
|
129 |
|
130 |
return $this->api_request( 'DELETE', $resource, $args );
|
@@ -161,11 +161,14 @@ class SS_WC_MailChimp_API {
|
|
161 |
);
|
162 |
|
163 |
// attach arguments (in body or URL)
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
169 |
|
170 |
$raw_response = wp_remote_request( $url, $request_args );
|
171 |
|
@@ -204,12 +207,12 @@ class SS_WC_MailChimp_API {
|
|
204 |
} //end function api_request
|
205 |
|
206 |
/**
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
|
214 |
/**
|
215 |
* Conditionally log MailChimp API Call
|
@@ -255,11 +258,11 @@ class SS_WC_MailChimp_API {
|
|
255 |
} //end function has_api_key
|
256 |
|
257 |
/**
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
|
264 |
/**
|
265 |
* Returns error code from error property
|
@@ -267,7 +270,11 @@ class SS_WC_MailChimp_API {
|
|
267 |
*/
|
268 |
public function get_error_code() {
|
269 |
|
270 |
-
|
|
|
|
|
|
|
|
|
271 |
|
272 |
} //end get_error_code
|
273 |
|
@@ -277,7 +284,11 @@ class SS_WC_MailChimp_API {
|
|
277 |
*/
|
278 |
public function get_error_message() {
|
279 |
|
280 |
-
|
|
|
|
|
|
|
|
|
281 |
|
282 |
} //end get_error_message
|
283 |
|
13 |
class SS_WC_MailChimp_API {
|
14 |
|
15 |
/**
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
public $api_key;
|
19 |
|
20 |
/**
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
public $datacenter = 'us1';
|
24 |
|
25 |
/**
|
26 |
+
* @var string
|
27 |
+
*/
|
28 |
private $api_root = 'https://<dc>.api.mailchimp.com/3.0/';
|
29 |
|
30 |
/**
|
31 |
+
* @var boolean
|
32 |
+
*/
|
33 |
private $debug = false;
|
34 |
|
35 |
/**
|
36 |
+
* @var array
|
37 |
+
*/
|
38 |
+
private $last_response;
|
39 |
|
40 |
+
/**
|
41 |
+
* @var WP_Error
|
42 |
+
*/
|
43 |
private $last_error;
|
44 |
|
45 |
/**
|
68 |
} //end function __construct
|
69 |
|
70 |
/**
|
71 |
+
* @param string $resource
|
72 |
+
* @param array $args
|
73 |
+
*
|
74 |
+
* @return mixed
|
75 |
+
*/
|
76 |
public function get( $resource, $args = array() ) {
|
77 |
|
78 |
if ( is_array( $args) && ! array_key_exists( 'count', $args ) ) {
|
84 |
} //end function post
|
85 |
|
86 |
/**
|
87 |
+
* @param string $resource
|
88 |
+
* @param array $args
|
89 |
+
*
|
90 |
+
* @return mixed
|
91 |
+
*/
|
92 |
public function post( $resource, $args = array() ) {
|
93 |
|
94 |
return $this->api_request( 'POST', $resource, $args );
|
96 |
} //end function post
|
97 |
|
98 |
/**
|
99 |
+
* @param string $resource
|
100 |
+
* @param array $args
|
101 |
+
*
|
102 |
+
* @return mixed
|
103 |
+
*/
|
104 |
public function put( $resource, $args = array() ) {
|
105 |
|
106 |
return $this->api_request( 'PUT', $resource, $args );
|
108 |
} //end function put
|
109 |
|
110 |
/**
|
111 |
+
* @param string $resource
|
112 |
+
* @param array $args
|
113 |
+
*
|
114 |
+
* @return mixed
|
115 |
+
*/
|
116 |
public function patch( $resource, $args = array() ) {
|
117 |
|
118 |
return $this->api_request( 'PATCH', $resource, $args );
|
120 |
} //end function patch
|
121 |
|
122 |
/**
|
123 |
+
* @param string $resource
|
124 |
+
* @param array $args
|
125 |
+
*
|
126 |
+
* @return mixed
|
127 |
+
*/
|
128 |
public function delete( $resource, $args = array() ) {
|
129 |
|
130 |
return $this->api_request( 'DELETE', $resource, $args );
|
161 |
);
|
162 |
|
163 |
// attach arguments (in body or URL)
|
164 |
+
if ( $method === 'GET' ) {
|
165 |
+
$url = add_query_arg( $args, $url );
|
166 |
+
} else {
|
167 |
+
$request_args['body'] = json_encode( $args );
|
168 |
+
}
|
169 |
+
|
170 |
+
// print_r($url);
|
171 |
+
// die();
|
172 |
|
173 |
$raw_response = wp_remote_request( $url, $request_args );
|
174 |
|
207 |
} //end function api_request
|
208 |
|
209 |
/**
|
210 |
+
* Empties all data from previous response
|
211 |
+
*/
|
212 |
+
private function reset() {
|
213 |
+
$this->last_response = null;
|
214 |
+
$this->last_error = null;
|
215 |
+
}
|
216 |
|
217 |
/**
|
218 |
* Conditionally log MailChimp API Call
|
258 |
} //end function has_api_key
|
259 |
|
260 |
/**
|
261 |
+
* @return array|WP_Error
|
262 |
+
*/
|
263 |
+
public function get_last_response() {
|
264 |
+
return $this->last_response;
|
265 |
+
}
|
266 |
|
267 |
/**
|
268 |
* Returns error code from error property
|
270 |
*/
|
271 |
public function get_error_code() {
|
272 |
|
273 |
+
$last_error = $this->last_error;
|
274 |
+
if ( is_wp_error( $last_error ) ) {
|
275 |
+
return $last_error->get_error_code();
|
276 |
+
}
|
277 |
+
return null;
|
278 |
|
279 |
} //end get_error_code
|
280 |
|
284 |
*/
|
285 |
public function get_error_message() {
|
286 |
|
287 |
+
$last_error = $this->last_error;
|
288 |
+
if ( is_wp_error( $last_error ) ) {
|
289 |
+
return $last_error->get_error_message();
|
290 |
+
}
|
291 |
+
return null;
|
292 |
|
293 |
} //end get_error_message
|
294 |
|
includes/class-ss-wc-mailchimp-handler.php
CHANGED
@@ -65,15 +65,20 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
65 |
// get the ss_wc_mailchimp_opt_in value from the post meta. "order_custom_fields" was removed with WooCommerce 2.1
|
66 |
$subscribe_customer = get_post_meta( $id, $this->namespace_prefixed( 'opt_in' ), true );
|
67 |
|
|
|
|
|
|
|
|
|
|
|
68 |
// If the 'ss_wc_mailchimp_opt_in' meta value isn't set
|
69 |
// (because 'display_opt_in' wasn't enabled at the time the order was placed)
|
70 |
// or the 'ss_wc_mailchimp_opt_in' is yes, subscriber the customer
|
71 |
if ( ! $subscribe_customer || empty( $subscribe_customer ) || 'yes' === $subscribe_customer ) {
|
72 |
// log
|
73 |
-
$this->log( sprintf( __( __METHOD__ . '(): Subscribing customer (%s) to list %s', 'woocommerce-mailchimp' ), $
|
74 |
|
75 |
// subscribe
|
76 |
-
$this->subscribe( $
|
77 |
}
|
78 |
}
|
79 |
}
|
65 |
// get the ss_wc_mailchimp_opt_in value from the post meta. "order_custom_fields" was removed with WooCommerce 2.1
|
66 |
$subscribe_customer = get_post_meta( $id, $this->namespace_prefixed( 'opt_in' ), true );
|
67 |
|
68 |
+
$order_id = method_exists($order, 'get_id') ? $order->get_id(): $order->id;
|
69 |
+
$order_billing_email = method_exists($order, 'get_billing_email') ? $order->get_billing_email(): $order->billing_email;
|
70 |
+
$order_billing_first_name = method_exists($order, 'get_billing_first_name') ? $order->get_billing_first_name(): $order->billing_first_name;
|
71 |
+
$order_billing_last_name = method_exists($order, 'get_billing_last_name') ? $order->get_billing_last_name(): $order->billing_last_name;
|
72 |
+
|
73 |
// If the 'ss_wc_mailchimp_opt_in' meta value isn't set
|
74 |
// (because 'display_opt_in' wasn't enabled at the time the order was placed)
|
75 |
// or the 'ss_wc_mailchimp_opt_in' is yes, subscriber the customer
|
76 |
if ( ! $subscribe_customer || empty( $subscribe_customer ) || 'yes' === $subscribe_customer ) {
|
77 |
// log
|
78 |
+
$this->log( sprintf( __( __METHOD__ . '(): Subscribing customer (%s) to list %s', 'woocommerce-mailchimp' ), $order_billing_email , $this->sswcmc->get_list() ) );
|
79 |
|
80 |
// subscribe
|
81 |
+
$this->subscribe( $order_id, $order_billing_first_name, $order_billing_last_name, $order_billing_email , $this->sswcmc->get_list() );
|
82 |
}
|
83 |
}
|
84 |
}
|
includes/class-ss-wc-mailchimp-plugin.php
CHANGED
@@ -9,7 +9,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
9 |
* Plugin version
|
10 |
* @var string
|
11 |
*/
|
12 |
-
private static $version = '2.0
|
13 |
|
14 |
/**
|
15 |
* Plugin singleton instance
|
@@ -441,6 +441,10 @@ final class SS_WC_MailChimp_Plugin {
|
|
441 |
*/
|
442 |
function add_mailchimp_settings( $settings ) {
|
443 |
|
|
|
|
|
|
|
|
|
444 |
$settings[] = require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-settings-mailchimp.php' );
|
445 |
|
446 |
return $settings;
|
9 |
* Plugin version
|
10 |
* @var string
|
11 |
*/
|
12 |
+
private static $version = '2.1.0';
|
13 |
|
14 |
/**
|
15 |
* Plugin singleton instance
|
441 |
*/
|
442 |
function add_mailchimp_settings( $settings ) {
|
443 |
|
444 |
+
if ( ! is_array( $settings ) ) {
|
445 |
+
$settings = [];
|
446 |
+
}
|
447 |
+
|
448 |
$settings[] = require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-settings-mailchimp.php' );
|
449 |
|
450 |
return $settings;
|
includes/class-ss-wc-settings-mailchimp.php
CHANGED
@@ -458,6 +458,8 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
458 |
'woocommerce_checkout_billing' => __( 'Above billing details', 'woocommerce-mailchimp' ),
|
459 |
'woocommerce_checkout_shipping' => __( 'Above shipping details', 'woocommerce-mailchimp' ),
|
460 |
'woocommerce_after_checkout_billing_form' => __( 'Below Checkout billing form', 'woocommerce-mailchimp' ),
|
|
|
|
|
461 |
),
|
462 |
'desc_tip' => true,
|
463 |
);
|
458 |
'woocommerce_checkout_billing' => __( 'Above billing details', 'woocommerce-mailchimp' ),
|
459 |
'woocommerce_checkout_shipping' => __( 'Above shipping details', 'woocommerce-mailchimp' ),
|
460 |
'woocommerce_after_checkout_billing_form' => __( 'Below Checkout billing form', 'woocommerce-mailchimp' ),
|
461 |
+
'woocommerce_checkout_before_terms_and_conditions' => __( 'Above Checkout Terms and Conditions', 'woocommerce-mailchimp' ),
|
462 |
+
'woocommerce_checkout_after_terms_and_conditions' => __( 'Below Checkout Terms and Conditions', 'woocommerce-mailchimp' ),
|
463 |
),
|
464 |
'desc_tip' => true,
|
465 |
);
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: saintsystems, anderly
|
|
3 |
Donate link: http://ssms.us/hVdk
|
4 |
Tags: woocommerce, mailchimp
|
5 |
Requires at least: 3.5.1
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 2.0
|
8 |
License: GPLv3
|
9 |
|
10 |
Simple and flexible MailChimp integration for WooCommerce.
|
@@ -113,6 +113,10 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
|
|
113 |
|
114 |
== Changelog ==
|
115 |
|
|
|
|
|
|
|
|
|
116 |
#### 2.0.20 - February 1, 2017
|
117 |
|
118 |
- Added `woocommerce_mailchimp_admin_email` filter to allow hooking into and overriding email where error messages are sent (defaults to `get_option( 'admin_email' )` ).
|
3 |
Donate link: http://ssms.us/hVdk
|
4 |
Tags: woocommerce, mailchimp
|
5 |
Requires at least: 3.5.1
|
6 |
+
Tested up to: 4.7.2
|
7 |
+
Stable tag: 2.1.0
|
8 |
License: GPLv3
|
9 |
|
10 |
Simple and flexible MailChimp integration for WooCommerce.
|
113 |
|
114 |
== Changelog ==
|
115 |
|
116 |
+
#### 2.1.0 - April 26, 2017
|
117 |
+
- Added support for WooCommerce 3.0 changes.
|
118 |
+
- Added additional options for opt-in checkbox placement.
|
119 |
+
|
120 |
#### 2.0.20 - February 1, 2017
|
121 |
|
122 |
- Added `woocommerce_mailchimp_admin_email` filter to allow hooking into and overriding email where error messages are sent (defaults to `get_option( 'admin_email' )` ).
|
woocommerce-mailchimp.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
|
6 |
* Author: Saint Systems
|
7 |
* Author URI: https://www.saintsystems.com
|
8 |
-
* Version: 2.0
|
9 |
* Text Domain: woocommerce-mailchimp
|
10 |
* Domain Path: languages
|
11 |
*
|
5 |
* Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
|
6 |
* Author: Saint Systems
|
7 |
* Author URI: https://www.saintsystems.com
|
8 |
+
* Version: 2.1.0
|
9 |
* Text Domain: woocommerce-mailchimp
|
10 |
* Domain Path: languages
|
11 |
*
|