Wednesday, January 16, 2013

Mail Chimp plugin for Zencart - adding extra fields

This is a little more tricky that you think, although once you have had a long read of mailchimps docs it is dead simple.

First of grab the Mail Chimp plugin  by SwGuy from the zencart plugins repository.

By default this only takes your email address, do for our example we will make it take first name and last name of your subscriber.

First step

Install the MailChimp Plugin as per the instructions given.

Second Step

Make sure your MailChimp Account is able to receive the extra fields

Third Step

Open includes/templates/template_default/sideboxes/tpl_mailchimp_sidebox.php

find this piece of code

$content .= ENTRY_EMAIL_ADDRESS;
$content .= '
';


Replace it with this

$content .= ENTRY_EMAIL_ADDRESS;
$content .= '
';
$content .= ENTRY_FIRST_NAME;
$content .= '
';
$content .= ENTRY_LAST_NAME;
$content .= '
';


Save the file

Fourth Step

In /includes/modules/your-template/create_account.php
 find this

mailchimp_add($email_address, $email_format);

and replace with

mailchimp_add($email_address, $firstname, $lastname, $email_format);


Fifth Step

In includes/functions/extra_functions/mailchimp_functions.php
Find this code (line 6-ish)

$merge_vars = array('');

Replace it with this

$merge_vars = Array(
'EMAIL' => $email_address,
'FNAME' => $firstname,
'LNAME' => $lastname
);



And thats all there is to it.

2 comments:

Anonymous said...

Any ideas on how to do this with Fast and Easy Checkout installed?

I've made the changes as suggested, with the exception that I altered fec_create_account - everything runs smoothly and the account is created but nothing is sent to mailchimp and no error is logged.

Nigel T said...

I have never used the FEC module, If there is no error being placed in either the logs or cache folder, I couldn't guess what would cause it, best bet would be to ask on the zencart forum. As surely someone else must have used both modules together.