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 .= '

Replace it with this

$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.