updated import

This commit is contained in:
minic studio
2013-04-09 17:00:45 +03:00
parent 25a560eea8
commit 8fc4be6ce6
2 changed files with 31 additions and 8 deletions

View File

@@ -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.'<br />'.$this->l('Milchimp message:').' '.$mailchimp->errorMessage, 'type' => 'error');
return;
} else {
P($import);
$this->message['text'] = $this->l('Successfull imported:').' <b>'.$import['add_count'].'</b><br />';
$this->message['text'] .= $this->l('Successfull updated:').' <b>'.$import['update_count'].'</b><br />';
if($import['error_count'] > 0){
$this->message['text'] .= $this->l('Error occured:').' <b>'.$import['error_count'].'</b><br />';
foreach ($import['errors'] as $error) {
$this->message['text'] .= '<p style="margin-left: 15px;">';
$this->message['text'] .= $error['email'].' - '.$error['code'].' - '.$error['message'];
$this->message['text'] .= '</p>';
}
$this->message['type'] = 'warn';
}
}
}

View File

@@ -39,6 +39,20 @@
{/if}
{/foreach}
</div>
<div class="switch-holder inline">
<label for="">{l s='Confirmation email'}:</label>
<div class="switch small inactive">
<input type="radio" class="" name="optin" value="0" checked="true" />
</div>
<p style="clear:both;">{l s='Turn on if you wish to send confirmation email for customers after import is done.' mod='minicmailchimp'}</p>
</div>
<div class="switch-holder inline">
<label for="">{l s='Update if exists'}:</label>
<div class="switch small inactive">
<input type="radio" class="" name="update_users" value="0" checked="true" />
</div>
<p style="clear:both;">{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'}</p>
</div>
<div class="switch-holder inline">
<label for="">{l s='Import all Customers'}:</label>
<div class="switch small inactive">