Re: MailChimp Newsletter Sidebox
Quote:
Originally Posted by
robraymond
I figured it out.
/includes/modules/your-template/create_account
Code:
mailchimp_add($email_address, $email_format);
becomes
Code:
mailchimp_add($email_address, $firstname, $lastname, $company, $email_format);
includes/functions/extra_functions/mailchimp_functions.php
Code:
function mailchimp_add($email_address, $email_format) {
include_once(DIR_WS_CLASSES . "MCAPI.class.php");
$api = new MCAPI(BOX_MAILCHIMP_NEWSLETTER_API_KEY);
$merge_vars = array('');
becomes
Code:
function mailchimp_add($email_address, $firstname, $lastname, $company, $email_format) {
include_once(DIR_WS_CLASSES . "MCAPI.class.php");
$api = new MCAPI(BOX_MAILCHIMP_NEWSLETTER_API_KEY);
$merge_vars = array('FNAME'=>$firstname, 'LNAME'=>$lastname, 'COMPANY'=>$company);
Hopefully this is the right way to do this.
Hi,
Thanks for that - I am trying to get this work for fast and easy check out.
I've done everything else as you've stated except I changed the code in /includes/modules/fec_create_account
But for whatever reason it doesn't want to work - any ideas?
Re: MailChimp Newsletter Sidebox
Hi,
I got this to work with FEC,
simply add the code
if ((int)$newsletter == 1) {
mailchimp_add($email_address, $firstname, $lastname, $email_format);
}
to /includes/modules/fec_create_account instead of /includes/modules/your-template/create_account and follow the instructions above for includes/functions/extra_functions/mailchimp_functions.php. I made a typo in mailchimp_functions.php hence the reason for my e-mail above - but once I fixed it, everything worked as it should.
Re: MailChimp Newsletter Sidebox
The MailChimp guys fiddle constantly with the anchor tags and layout of their website, but I do my best to keep the instructions on my home page current. I just did a new install and noticed that the current README descriptions don't correlate precisely to the links and positions on the MailChimp page, but the instructions on the help page on my site have been updated. Go there if you're having trouble figuring out what to do.
Re: MailChimp Newsletter Sidebox
Hi SWguy,
The sidebox function works great. I kept only the email address in the form, and then when the user clicks submit they are directed to the full sign up page to add additional information. I am having no issues with side box email list adds. My website is www.SETboutique.com.
My issues are with create account functions:
I followed step 5 in the installation instructions, but when I created a test account I didn't receive any emails from mailchimp.
I then followed the advice from a previous post and edited /includes/modules/custom_template/create_account.php to the following:
//--- added mailchimp
if ((int)$newsletter == 1) {
mailchimp_add($email_address, $firstname, $lastname, $email_format);
}
//--- End mailchimp
I created a new test account but I still didn't receive any emails from mailchimp.
I then took additional advice from a previous post and edited /includes/functions/extra_functions/mailchimp_functions.php to the following:
function mailchimp_add($email_address, $fname, $lname,$email_format) {
I created a new test account but I still didn't receive any emails from mailchimp.
Could you offer any additional advice? I am using ZC1.5.1, and mailchimp3.0. I added a new API for the use of this mod. I already had an API in mailchimp but I added a new one for this coding (just a FYI in case it helps).
Thank you,
Lindsay
Re: MailChimp Newsletter Sidebox
I'd suggest you install the software I wrote and get that working prior to making any changes. This includes the API version I packaged up.
Re: MailChimp Newsletter Sidebox
Hi,
I made the changes only because I couldn't get the original to work as stated before. I can remove the changes if you don't agree with them. But can you offer any advice for the create account functioning?
Thank you,
Lindsay
Re: MailChimp Newsletter Sidebox
Very nice module! Works great on ZC 1.5.1. I've made some slight changes to the coding. If your country doesn't obligate you to use a double opt-in procedure you can use the
PHP Code:
$double_optin = false
flag as described in the API documentation http://apidocs.mailchimp.com/api/1.3...cribe.func.php . Only make this change if your country allow you to and if your customers opt-in on your create account page!
I've found it very annoying for the customers to get two e-mails when they sign up at your store and place a checkmark that they want to receive a e-mail newsletter already.
For those that aren't that skilled in programming:
This line of code:
PHP Code:
$retval = $api->listSubscribe($list_id, $email_address, $merge_vars, $format);
Becomes
PHP Code:
$retval = $api->listSubscribe($list_id, $email_address, $merge_vars, $format, $double_optin = false);
Some minor improvement would be to make mailchimp update your list when someone changes their info on their 'My Account' page, I will code something for that tonight:-)
Re: MailChimp Newsletter Sidebox
Allright, coded the update function after my diner. When a customer updates his or her information on the "my account" page, this change will be synced with your Mail Chimp list. Here's how I dit it:
In mailchimp_functions.php from this great module I added my own function at the end of the file. Note that I added a field for Firstname and Lastname. You can do that, but if you don't want to just delete everything with firstname and lastname in it:
PHP Code:
//Mailchimp update function: update customers data to the mailchimp list.
function mailchimp_update($email_address_old, $email_address, $firstname, $lastname, $email_format) {
include_once(DIR_WS_CLASSES . "MCAPI.class.php");
$api = new MCAPI(BOX_MAILCHIMP_NEWSLETTER_API_KEY);
$merge_vars = array('FNAME'=>$firstname, 'LNAME'=>$lastname, 'EMAIL'=>$email_address);
if ($email_format == 'TEXT') {
$format = 'text';
} else {
$format = 'html';
}
$list_id = BOX_MAILCHIMP_NEWSLETTER_ID;
$retval = $api->listUpdateMember($list_id, $email_address_old, $merge_vars, $format);
if ($api->errorCode){
$errorMessage = "Unable to update member info with listUpdateMember()!\n" .
"\tCode=".$api->errorCode."\n" .
"\tMsg=".$api->errorMessage."\n";
$file = DIR_FS_SQL_CACHE . '/' . 'MailChimp.log';
if ($fp = @fopen($file, 'a')) {
fwrite($fp, $errorMessage);
fclose($fp);
}
}
}
In htdocs/includes/templates/YOURTEMPLATE/templates/tpl_account_edit_default.php you must make an invisible field to be able to pass the old email address (email_address_old) to the mailchimp_update() function. I've placed this line below the entry for the e-mail address, but you can paste in anywhere as long as it is within the form:
PHP Code:
<?php echo zen_draw_hidden_field('email_address_old', $account->fields['customers_email_address'], 'id="email-address-old"') ?>
At last you must make a call to the function. When the form is submitted it will use /includes/modules/pages/account_edit/header_php.php to make all the magic happen. Paste the following around line 154 above the line:
$zco_notifier->notify('NOTIFY_HEADER_ACCOUNT_EDIT_UPDATES_COMPLETE');
PHP Code:
mailchimp_update($email_address_old, $email_address, $firstname, $lastname, $email_format);
That's all! Now your mailchimp list will be updated as soon as your customer edits his or her information! Next thing to do is to make a sync for the "Subscribe or unsubscribe from newsletters." page.
Re: MailChimp Newsletter Sidebox
Note: Only usefull if you've included additional info in your mailchimp list such as first name, last name, country etc.
I've made a really small improvement.
I noticed that when a non-customer signs up for the maillinglist with the sidebox module the customer is added to the mailchimp list as supposed to. But when that non-costumer is going to be your customer, the API doesn't update the name field and lastname field (this is only if you've made some changes yourself to the original code to include additional customer information). With a really small change you can let the mailchimp API update the information as soon as the non-costumer becomes a customer.
In mailchimp_functions.php add
PHP Code:
$update_existing = true
so that the line becomes (in my case)
PHP Code:
$retval = $api->listSubscribe($list_id, $email_address, $merge_vars, $format, $double_optin = false, $update_existing = true);
When a newsletter only person signs up for a new account, all the info will be automatically updated to mailchimp!
Re: MailChimp Newsletter Sidebox
Quote:
Originally Posted by
swguy
I'd suggest you install the software I wrote and get that working prior to making any changes. This includes the API version I packaged up.
Hi, thanks for the great mod. I'm having the same trouble in the create account process. The account is created there is no confirmation email from mailchimp as expected. I would appreciate any advice. Thank you!