Forums / Addon Sideboxes / MailChimp Newsletter Sidebox

MailChimp Newsletter Sidebox

Views: 189,700

Results 381 to 400 of 403
14 Aug 2021, 8:35 PM
#381
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

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?

4 Oct 2021, 4:21 AM
#383
noppie avatar

noppie

Zen Follower

Join Date:
Mar 2004
Posts:
210
Plugin Contributions:
0

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.

My Multi_Site Zen Carts
http://herasonlinemarket.com

6 Jan 2022, 11:10 AM
#384
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

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.

Simon

6 Jan 2022, 1:11 PM
#385
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: MailChimp Newsletter Sidebox

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

<?php echo zen_draw_hidden_field('email_address_old', $account->fields['customers_email_address'], 'id="email-address-old"') ?>

pages/account_edit/header_php.php

mailchimp_update($email_address_old, $email_address);  

$zco_notifier->notify('NOTIFY_HEADER_ACCOUNT_EDIT_UPDATES_COMPLETE');

extra_functions/mailchimp_functions.php

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

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.

Simon

7 Jan 2022, 8:51 AM
#386
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

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.

Simon

9 Jan 2022, 3:42 PM
#387
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: MailChimp Newsletter Sidebox

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:

Attachment 19878

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

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

 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

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.

<?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>';
?>

Simon

9 Jan 2022, 5:35 PM
#388
IDEASLady avatar

IDEASLady

Totally Zenned

Join Date:
Aug 2005
Location:
Trujillo Alto, Puerto Rico
Posts:
1,447
Plugin Contributions:
3

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.

IDEASLady
IDEAS Creative Studio

Your image... our business!

9 Jan 2022, 6:11 PM
#389
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: MailChimp Newsletter Sidebox

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.

Simon

9 Jan 2022, 7:13 PM
#390
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,721
Plugin Contributions:
56

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.

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.

9 Jan 2022, 8:52 PM
#391
IDEASLady avatar

IDEASLady

Totally Zenned

Join Date:
Aug 2005
Location:
Trujillo Alto, Puerto Rico
Posts:
1,447
Plugin Contributions:
3

Re: MailChimp Newsletter Sidebox

In the specific case of MooSend though, please coordinate with them, since they did the integration for us.
Yes, I understand. The problem is that these "service suppliers" (not only MooSend) are not getting much interest from Zen Cart users (since the user-base has gone down). So they kinda abandoned these updates and development.

I installed that module a couple of months ago and I had to disable it because it was not compatible (it made my cart inoperable, it will not let you checkout). There was no error logs so I couldn't tell them what exactly was happening. Since there are not a lot of people asking and/or using it, they would not proceed to update the module.

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.
I know, and that's why I mentioned MooSend because there's also an integration for ZC but nobody talks about it.

IDEASLady
IDEAS Creative Studio

Your image... our business!

10 Jan 2022, 1:14 AM
#392
elemi avatar

elemi

Zen Follower

Join Date:
Mar 2006
Location:
Auckland, New Zealand
Posts:
242
Plugin Contributions:
0

Re: MailChimp Newsletter Sidebox

simon1066:

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.

Thanks for working this out Simon, I will integrate it this week :-)

Elemi

The Art of Bespoke Aromatherapy
https://www.AmorAromatherapy.co.nz

13 Jan 2022, 2:54 PM
#393
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: MailChimp Newsletter Sidebox

Passing Marketing Permissions (GDPR) from ZC customer account to Mailchimp

In Mailchimp there is an option to enable compulsory Marketing Permissions (GDPR) checkbox(es) on a sign-up form in order to capture explicit consent to receive emails - this basically 'time-stamps' the consent for later use if needed. It would be useful to pass this explicit consent from a ZC customer account (once they have accepted the relevant GDPR privacy notice) to Mailchimps member list, so see the code below.

It is common for the explicit consent to be captured by selecting from various marketing avenues such as:

Attachment 19882

at least one of these HAS to be selected. In my case I only have one avenue (email) so the following code reflects this:

The relevant marketing permission has a 'marketing_permission_id' field which is needed and can be obtained from the output of an API call. Paste this code (updating the xxxxx) into a new php file and visit it in a browser.

<?php
$api_key = 'xxxxxxxxxxxxxxxxxxxx'; // your api key
$server = 'xxxx.'; // your server - something like 'us20', usually found at the end of the API key

$list_id = 'xxxxxxxx'; // your list id
$email = 'xxxmy_email_addressxxxxx';
$auth = base64_encode( 'user:'.$api_key );
	
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://'.$server.'api.mailchimp.com/3.0/lists/'.$list_id.'/members');
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->member as $obj) {
	echo $obj->id . ' - ' . $obj->name;
	echo '<br />';
}

echo '<pre>'; print_r($result_obj); echo '</pre>';
?>

includes/functions/extra_functions/mailchimp.php

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', 
            'marketing_permissions' => array([
			'marketing_permission_id' => 'xxxxxxxxx',
			'enabled' => 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);
    }

There may be a tidier way to do it, that's all I could manage.

This now passes the marketing permission consent from a customers ZC account to Mailchimps members list.

Simon

14 Feb 2022, 11:09 PM
#394
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,721
Plugin Contributions:
56

Re: MailChimp Newsletter Sidebox

If your customers or products can be easily segmented, you might want to look at MailChimp's Groups feature. You can add Groups to your audience and allow people to self-segment. The signup form when groups are configured will include radio buttons/checkboxes so people can indicate the groups they want to join; then you can segment your audience by groups when creating and sending a newsletter.

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.

5 May 2022, 6:16 PM
#396
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,721
Plugin Contributions:
56

Re: MailChimp Newsletter Sidebox

Yes it does.

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.

20 Jul 2022, 4:37 PM
#398
cjsmiff avatar

cjsmiff

Zen Follower

Join Date:
Jul 2006
Location:
UK
Posts:
170
Plugin Contributions:
0

Re: MailChimp Newsletter Sidebox

Hi,

I am trying to configure this on Zen Cart v1.5.6c. I am stuck on the Mailchimp side of it as my Form does not have any bot prevention code at the bottom as per your instructions. Here is a link to my Form. What am I doing wrong please?

Kind regards :-)

20 Jul 2022, 4:46 PM
#399
cjsmiff avatar

cjsmiff

Zen Follower

Join Date:
Jul 2006
Location:
UK
Posts:
170
Plugin Contributions:
0

Re: MailChimp Newsletter Sidebox

cjsmiff:

Hi,

I am trying to configure this on Zen Cart v1.5.6c. I am stuck on the Mailchimp side of it as my Form does not have any bot prevention code at the bottom as per your instructions. Here is a link to my Form. What am I doing wrong please?

Kind regards :-)

UPDATE: well now, the Zen Cart Create Account page works fine without the bot prevention code and I don't need the sidebox so haven't tested it, but would imagine if one works then the other should too...