Re: MailChimp Newsletter Sidebox
I've been using Mailchimp for years, but need to add it now to our new website that uses the Fluorspar template. So far I have not been successful. When I enable it in the Layout Boxes Controller, it wipes out the center box in the Fluorspar display. Has anyone else been able to install this in a Fluorspar template?
Re: MailChimp Newsletter Sidebox
Re: MailChimp Newsletter Sidebox
ok is this suppose to have a box to put an email in, it goes to another page to add info...
did i do something wrong...
i followed software guys instructions on his web site.
in the attachments shows the subscribe box
and when clicking the subscribe it goes to a second page
now when creating forms on mailchimp,, i did the condensed verson so only the email was suppose to show up.
ok.. any more info you need please ask..
thank you so much.
Re: MailChimp Newsletter Sidebox
This is a bit of an ask but would anyone be able to share how, using v3 of the API, to update a members email address in the MailChimp list when it is edited in ZC's account_edit page. I believe this can be achieved by using the API's 'PATCH' command. This post has a solution for an earlier API version - which I've attempted to adapt, without success.
Re: MailChimp Newsletter Sidebox
Quote:
Originally Posted by
simon1066
This is a bit of an ask but would anyone be able to share how, using v3 of the API, to update a members email address in the MailChimp list when it is edited in ZC's account_edit page. I believe this can be achieved by using the API's 'PATCH' command. This
post has a solution for an earlier API version - which I've attempted to adapt, without success.
Here's what I have so far:
templates/tpl_account_edit_default.php
Code:
<?php echo zen_draw_hidden_field('email_address_old', $account->fields['customers_email_address'], 'id="email-address-old"') ?>
pages/account_edit/header_php.php
Code:
mailchimp_update($email_address_old, $email_address);
$zco_notifier->notify('NOTIFY_HEADER_ACCOUNT_EDIT_UPDATES_COMPLETE');
extra_functions/mailchimp_functions.php
Code:
function mailchimp_update($email_address_old, $email) {
$mailchimp = new MailChimp(BOX_MAILCHIMP_NEWSLETTER_API_KEY);
$reply = $mailchimp->list_update_subscriber([
'id_list' => BOX_MAILCHIMP_NEWSLETTER_ID,
'email' => $email,
'status' => 'subscribed'
]);
if (isset($reply->type)) {
$errorMessage = "Unable to run update_subscriber command()!\n" .
"\tMsg=" . print_r($reply, true) . "\n";
$file = DIR_FS_LOGS . '/' . 'MailChimp.log';
if ($fp = @fopen($file, 'a')) {
fwrite($fp, $errorMessage);
fclose($fp);
}
}
}
extra_functions/mailchimp.php
Code:
public function list_update_subscriber(Array $options)
{
// Check required params
if ( ! isset($options['id_list']) OR ! isset($options['email']))
{
throw new MailChimpException('Parameters not set on '.__METHOD__);
}
$subscriber_hash = md5(strtolower($options['email']));
$endpoint = '/lists/' . $options['id_list'] . '/members/' . $subscriber_hash;
$payload = [
'email_address' => $options['email'],
'status' => 'subscribed'
];
return $this->_execute_request('PATCH', $endpoint, $payload);
}
If I use 'PUT' instead of 'PATCH' it adds the new address to the Mailchimp members list - so I guess something is working.
Re: MailChimp Newsletter Sidebox
ZC v1.5.7c
PHP v7.3
I've updated my mailchimp.php with the patch for PATCH from @swguy's github contribution. I'm guessing that the issue lies somewhere in the other three edited files.
2 Attachment(s)
Re: MailChimp Newsletter Sidebox
Quote:
Originally Posted by
simon1066
ZC v1.5.7c
PHP v7.3
I've updated my mailchimp.php with the patch for PATCH from @swguy's
github contribution. I'm guessing that the issue lies somewhere in the other three edited files.
I've had to give up on being able to have changes of email address in ZC updated on Mailchimp's member's list (although I've confirmed that PATCH is functioning I'm unable to get the change of email to work). I thought I would post my documentation on this tweak to @swguy's mod.
Mailchimp allows for a list of subscribers to be segregated (into Groups) based on the selection made when completing the sign-up form, such as:
This is useful for sending different newsletters to different subscribers. However, if a subscriber signs up for newsletters on a ZC website, no groups are transferred to Mailchimp - meaning those subscribers will be missed if solely relying on groups to send newsletters.
Until I manage (not guaranteed) to add the relevant checkboxes to the account_newsletters page I have assumed that a subscriber on my website will automatically be signed up for both groups (wording the descriptive text on the signup page accordingly). To achieve this here are the relevant code additions (in red):
includes/languages/english/extra_definitions/mailchimp_sidebox_defines.php
Code:
define('BOX_MAILCHIMP_NEWSLETTER_ID','xxxxxxxxxx');
define('BOX_MAILCHIMP_NEWSLETTER_U','yyyyyyyyyy');
define('BOX_MAILCHIMP_NEWSLETTER_URL','http://YourSite.us1.list-manage.com/subscribe/post');
define('BOX_MAILCHIMP_NEWSLETTER_API_KEY','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
define('MAILCHIMP_INTEREST_ID_A','aaaaaaaaaaa');
define('MAILCHIMP_INTEREST_ID_B','bbbbbbbbbbb');
// Language defines for newsletter sidebox
define('BOX_HEADING_MAILCHIMP_SIDEBOX', 'Newsletter');
define('BOX_MAILCHIMP_PITCH', 'Subscribe to our newsletter for periodic updates and valuable coupons.');
define('BOX_MAILCHIMP_SUBSCRIBE', 'Subscribe');
includes/functions/extra_functions/mailchimp_functions.php
Code:
function mailchimp_add($email) {
$mailchimp = new MailChimp(BOX_MAILCHIMP_NEWSLETTER_API_KEY);
$reply = $mailchimp->list_add_subscriber([
'id_list' => BOX_MAILCHIMP_NEWSLETTER_ID,
'interest_id_A' => MAILCHIMP_INTEREST_ID_A,
'interest_id_B' => MAILCHIMP_INTEREST_ID_B,
'email' => $email,
'status' => 'pending'
]);
includes/functions/extra_functions/mailchimp.php
Code:
public function list_add_subscriber(Array $options)
{
// Check required params
if ( ! isset($options['id_list']) OR ! isset($options['email']))
{
throw new MailChimpException('Parameters not set on '.__METHOD__);
}
$endpoint = '/lists/' . $options['id_list'] . '/members/';
$payload = [
'email_address' => $options['email'],
'status' => 'subscribed',
'interests' => array(
$options['interest_id_A'] => true,
$options['interest_id_B'] => true
)
// 'status' => isset($options['status']) ? $options['status'] : 'pending',
];
if (isset($options['merge_fields']) AND $options['merge_fields'])
{
$payload['merge_fields'] = $options['merge_fields'];
}
return $this->_execute_request('POST', $endpoint, $payload);
}
Notes: Groups in Mailchimp dev talk are 'interests'. Finding the appropriate id of an interest (to add to the language file) is not straightforward. These days the only way to find these out is via an API call. Add the following code to a new php file in the root directory of your website and run it in a browser e.g. mywebsite[dot]com/mynewfile.php. The code is on this page, but I'll include it here in case it disappears.
Code:
<?php
$api_key = 'xxxxxxxxxxxxxxxxxxx-us13'; // your api key
$server = 'us13.'; // your server
$list_id = 'xxxxxxxxxxxxx'; // your list id
$group_id = 'xxxxxxxxxxxx'; // your group id
$auth = base64_encode( 'user:'.$api_key );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://'.$server.'api.mailchimp.com/3.0/lists/'.$list_id.'/interest-categories/'.$group_id.'/interests');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Authorization: Basic '.$auth));
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
$result_obj = json_decode($result);
foreach ($result_obj->interests as $obj) {
echo $obj->id . ' - ' . $obj->name;
echo '<br />';
}
echo '<pre>'; print_r($result_obj); echo '</pre>';
?>
Re: MailChimp Newsletter Sidebox
I believe <<<This is of course MY opinion>>> that updating and developing the MooSend module is the way to go. They already have a module to sync with ZC and do some automations (like abandoned cart or getting into a list). Their service is cheaper and you can create different lists (groups like you call them) for your newsletters, without paying extra. Much more of a selection of templates and some free features that Mailchimp doesn't offer on their free tier.
The only feature that Mailchip offers for free that MooSend doesn't is the "post on social media" after a newsletter is sent.
Re: MailChimp Newsletter Sidebox
Quote:
Originally Posted by
ideasgirl
I believe <<<This is of course MY opinion>>> that updating and developing the MooSend module is the way to go. They already have a module to sync with ZC and do some automations (like abandoned cart or getting into a list). Their service is cheaper and you can create different lists (groups like you call them) for your newsletters, without paying extra. Much more of a selection of templates and some free features that Mailchimp doesn't offer on their free tier.
The only feature that Mailchip offers for free that MooSend doesn't is the "post on social media" after a newsletter is sent.
Thanks for this, that's interesting. I'll take a look.
Re: MailChimp Newsletter Sidebox
@ideasgirl The more the merrier. When I did this work, MailChimp was the only game in town for SMBs; now there are lots of options.
I'd love to see more integration work. In the specific case of MooSend though, please coordinate with them, since they did the integration for us.