diff --git a/minicmailchimp.php b/minicmailchimp.php
index c976c9d..670e429 100644
--- a/minicmailchimp.php
+++ b/minicmailchimp.php
@@ -147,7 +147,7 @@ class MinicMailchimp extends Module
$this->getMailchimpLists();
}
-
+
// Handling settings
if(Tools::isSubmit('submitSettings'))
$this->saveSettings();
@@ -205,19 +205,28 @@ class MinicMailchimp extends Module
}
}
- $optin = false; //yes, send optin emails
- $up_exist = true; // yes, update currently subscribed users
- $replace_int = false; // no, add interest, don't replace
+ $optin = (Tools::getValue('optin')) ? true : false; //yes, send optin emails
+ $up_exist = (Tools::getValue('update_users')) ? true : false; // yes, update currently subscribed users
+ $replace_int = true; // no, add interest, don't replace
$mailchimp = new MCAPI($this->api_key, $this->ssl);
$import = $mailchimp->listBatchSubscribe($list_id, $list, $optin, $up_exist, $replace_int);
if ($mailchimp->errorCode){
- echo "Batch Subscribe failed!\n";
- echo "code:".$mailchimp->errorCode."\n";
- echo "msg :".$mailchimp->errorMessage."\n";
+ $this->message = array('text' => $this->l('Mailchimp error code:').' '.$mailchimp->errorCode.'
'.$this->l('Milchimp message:').' '.$mailchimp->errorMessage, 'type' => 'error');
+ return;
} else {
- P($import);
+ $this->message['text'] = $this->l('Successfull imported:').' '.$import['add_count'].'
';
+ $this->message['text'] .= $this->l('Successfull updated:').' '.$import['update_count'].'
';
+ if($import['error_count'] > 0){
+ $this->message['text'] .= $this->l('Error occured:').' '.$import['error_count'].'
';
+ foreach ($import['errors'] as $error) {
+ $this->message['text'] .= '
'; + $this->message['text'] .= $error['email'].' - '.$error['code'].' - '.$error['message']; + $this->message['text'] .= '
'; + } + $this->message['type'] = 'warn'; + } } } diff --git a/views/templates/admin/import.tpl b/views/templates/admin/import.tpl index c423d55..f7e6509 100644 --- a/views/templates/admin/import.tpl +++ b/views/templates/admin/import.tpl @@ -39,6 +39,20 @@ {/if} {/foreach} +{l s='Turn on if you wish to send confirmation email for customers after import is done.' mod='minicmailchimp'}
+{l s='Turn on if you wish to update the record if alredy exists. If you dont you\'ll receive a warning for those customers.' mod='minicmailchimp'}
+