Foxy Forum Status

We're no longer responding to questions via our forum, but we will keep it up for historical reasons. If you can't find the answer you're looking for, please visit our knowledge base or contact us. If there's enough interest in the future, we may bring the forum back.

FoxyShop/MailChimp Integration for FoxyCart 2.0

ethanmillerethanmiller Member
in Help edited October 2014
I need a bit of help debugging my attempt to setup an integration between FoxyCart and MailChimp via FoxyShop. I followed these instructions

http://www.foxy-shop.com/2011/08/easy-mailchimp-integration/

They seem a bit dated, and perhaps not intended to work for v2.0 of FoxyCart. That said, it doesn't seem, at least at first glance, that it does not totally apply. Since 2.0 provides an option on the checkout page for the newsletter opt-in, it seemed to me that it is mainly #3 that is no longer applicable.

Instead of adding the code specified there, I simply added the name 'newsletter_subscribe' (i.e. the name given to the newsletter subscribe input in the 2.0 default checkout) to the code (specified in #2) placed in the foxyshop-datafeed-endpoint.php.

That said, after having run a few tests, the integration does not seem to be working correctly.
Comments
  • fc_adamfc_adam FoxyCart Team
    @ethanmiller,

    There hasn't been any major changes to the 2.0 datafeed - so any existing set ups for that should still work fine in 2.0. As you mentioned though, there is the option to include the newsletter signup field from the template configuration - so step 4 isn't needed to add in the custom fields.

    You'll still need to complete the rest of the steps though - if you've skipped step 3, you'll still need to do that one.
  • @sparkweb, this convo may also interest you.
    @fc_adam: sorry I meant to say that it was #4 that i skipped...

    when i tested a submit, however, no email was added on mail chimp. there were also no errors in my error_log. i tried to load the datafeed directly but it was empty.

    i'm currently debugging, and what i've noticed is that in the MCAPI.php callServer function (the function used to actually subscribe the user to the list), the response object sent back by the server is saying:
    a:2:{s:5:"error";s:43:"Invalid MailChimp List ID: OK Go Newsletter";s:4:"code";i:200;}
    

    I've tried two different ways of specifying the list, once with the ID that appears in the mailchimp dashboard for the list, and once as shown here, by typing the string name of the list.

    I'm now searching the MC docs to see where I may be going wrong in specifying the list, but I've also noticed that the MCAPI you are using here is really old. 1.2. It is in fact deprecated. So seems this needs to b e updated to 2.0, the current version. I'm wondering if this really could be the cause of the problem.
  • Right, okay, this still works with v.2 (but should probably be updated soon, no?). The problem here is that the id listed on the webpage is the
    web_id
    
    and not the
    id
    
    of the list. Here's what the json output looks like from MC for a list with some sample content:
    {
        "id": "a954c925f3",
        "web_id": 256249,
        "name": "Sample",
        "date_created": "2014-10-05 11:43:51",
        "member_count": 1,
        "unsubscribe_count": 0,
        "cleaned_count": 0,
        "email_type_option": false,
        "default_from_name": "OK Go",
        "default_from_email": "",
        "default_subject": "",
        "default_language": "en",
        "list_rating": 3,
        "member_count_since_send": 1,
        "unsubscribe_count_since_send": 0,
        "cleaned_count_since_send": 0
      },
    

    I had to switch the list id to the id above, and not the web_id, which was readable form the MC dashboard.
  • The correct list id, I just discovered, is provided on the settings page for the list.
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    edited October 2014
    Right, the V2 version is all REST-based and JSON where v1 relied on XML. Here's the code I use on Order Desk to submit to the list:
    $post_values = array(
    	"apikey" => "XXXXX",
    	"id" => $list_id,
    	"email" => array(
    		"email" => $email,
    	),
    	"merge_vars" => $merge_vars,
    	"email_type" => "html",
    	"double_optin" => 0,
    	"update_existing" => 1,
    );
    $url = "https://XXXX.api.mailchimp.com/2.0/lists/subscribe";
    

    EDIT: right on the settings page. I'm not sure what the web_id is. Never heard of that before.
  • @sparkweb: web_id is the id visible, for example, in the url when you are browsing a list on MC.

    thanks for the code, but i'm not sure where that code fits in. we're not using order desk currently. rather we are using the integration described here: http://www.foxy-shop.com/2011/08/easy-mailchimp-integration/ . i think the MCAPI.php file would have to be updated. that seems to rely on v1.2...
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    Right, I'm saying that if you were to rebuild the piece that connects to MC to work with 2.0, then the code above would give you a head-start. I think you could probably just upgrade to the latest MCAPI version. But I'll bet it would work as long as you were using the correct id (not the web id).
  • The other modification that was necessary here was to modify the line that looks like this:
    if ((string)$custom_field->custom_field_name == "newsletter_subscribe" && (string)$custom_field->custom_field_value == "yes") {
    

    to this:
    if ((string)$custom_field->custom_field_name == "newsletter_subscribe" && (string)$custom_field->custom_field_value == "1") {
    
  • @sparkweb: thanks. yeah i looked a bit at the v2.0 of the api. on a quick glance it seemed to be structured quite differently. i stopped at that point in the interest of time, hoping that i might be able to get the v1.2 version to work for the short term.
  • Hi, there,

    I'm new to the forum and FoxyCart - trying to get this integration to work.

    It doesn't seem to be passing anything to the MailChimp side of things on the test script. I changed and created a new API key and also a new list which is clear and empty (and without spaces in the name just to make it not be a space issue) and I'm not sure where to go here.

    I'm really needing to have a working Foxy to Mailchimp integration to move forward, but I'm sure it's something silly I'm doing wrong.

    Could anyone report if there is any changes to the infomation on the integration instructions or simply if it doesn't work anymore?

    It's just not passing anything to Mailchimp.

    Thanks a lot,

    - Paul
Sign In or Register to comment.