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.
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.
That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.
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
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.
That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.
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
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 theflag 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!PHP Code:
$double_optin = false
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:
BecomesPHP Code:
$retval = $api->listSubscribe($list_id, $email_address, $merge_vars, $format);
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:-)PHP Code:
$retval = $api->listSubscribe($list_id, $email_address, $merge_vars, $format, $double_optin = false);
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:
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:
//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);
}
}
}
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:PHP Code:
<?php echo zen_draw_hidden_field('email_address_old', $account->fields['customers_email_address'], 'id="email-address-old"') ?>
$zco_notifier->notify('NOTIFY_HEADER_ACCOUNT_EDIT_UPDATES_COMPLETE');
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.PHP Code:
mailchimp_update($email_address_old, $email_address, $firstname, $lastname, $email_format);
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 addso that the line becomes (in my case)PHP Code:
$update_existing = true
When a newsletter only person signs up for a new account, all the info will be automatically updated to mailchimp!PHP Code:
$retval = $api->listSubscribe($list_id, $email_address, $merge_vars, $format, $double_optin = false, $update_existing = true);
Bookmarks