Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author sparkweb

    (@sparkweb)

    If you’d like to use this with FoxyCart 2.0’s new “Newsletter Subscribe” feature you’ll want to tweak the code in your datafeed template a little bit. (Don’t put any code in your checkout template.)

    Line 4 would say:

    if ((string)$custom_field->custom_field_name == "newsletter_subscribe" && (string)$custom_field->custom_field_value == "1") {

    Once you’ve updated this, try refeeding the test order from the transaction page at FoxyCart.

    Edit: I’ve updated the docs and code samples to make this more clear.

    Thread Starter andysuarez

    (@andysuarez)

    Hello..Thank you for the reply. I did not add any code in the checkout template. I folow steps 1-3. What will I do next?How can I tweak code in datafeed template?I used the datafeed url that is inside foxyshop settings.

    Thread Starter andysuarez

    (@andysuarez)

    Another question bothering me is that, can I automatically checked the box for newsletter subscribe and hide it..so user will not turn it off. I do want to add automatically user in my list after they purchase.

    Plugin Author sparkweb

    (@sparkweb)

    Ok, the code I sent earlier is for step 2. But if you want to add everyone automatically, just don’t add the checkbox in step 4 and take out the if statement in your datafeed template (step 2). So the code should start with line 9 and end with line 18.

    You asked how to adjust the datafeed template – go through step 2 again being careful to follow the instructions. That explains what you need to do.

    Thread Starter andysuarez

    (@andysuarez)

    Subscribers is still not added in my list after I follow your instructions.
    Here is my code.

    //If you have custom code to run for each order, put it here:

    //Add Customer To Mailchimp
    $add_to_mailchimp = 0;
    foreach($transaction->custom_fields->custom_field as $custom_field) {
    if ((string)$custom_field->custom_field_name == “newsletter_subscribe” && (string)$custom_field->custom_field_value == “1”) {
    $add_to_mailchimp = 1;
    }
    }

    require_once ‘MCAPI.class.php’;
    $mailchimp_api_key = ‘a746a82db34be0382639259b66ddd465-us9’;
    $mailchimp_list_id = “135a7d3da3”;
    $api = new MCAPI($mailchimp_api_key);
    $merge_vars = array(
    ‘FNAME’ => $customer_first_name,
    ‘LNAME’ => $customer_last_name,
    ‘OPTINIP’ => (string)$transaction->customer_ip
    );
    $retval = $api->listSubscribe($mailchimp_list_id, $customer_email, $merge_vars, “html”, false);

    //Runs a WordPress action at the end if you prefer to customize that way
    do_action(‘foxyshop_datafeed_order’, $transaction);
    }

    //All Done!
    die(“foxy”);

    Plugin Author sparkweb

    (@sparkweb)

    Please don’t post your API key in a public forum. You need to immediately go deactivate it and create a new one so your account doesn’t get compromised!

    Also, in my last message I said you only want to do some of that code:

    require_once 'MCAPI.class.php';
    $mailchimp_api_key = 'YOURKEY';
    $mailchimp_list_id = "135a7d3da3";
    $api = new MCAPI($mailchimp_api_key);
    $merge_vars = array(
    	'FNAME' => $customer_first_name,
    	'LNAME' => $customer_last_name,
    	'OPTINIP' => (string)$transaction->customer_ip
    );
    $retval = $api->listSubscribe($mailchimp_list_id, $customer_email, $merge_vars, "html", false)
    Thread Starter andysuarez

    (@andysuarez)

    OK, sorry about that. I have deactivate my account now..
    Here is what you said “But if you want to add everyone automatically, just don’t add the checkbox( I removed it now ) in step 4 and take out the if statement in your datafeed template (I did take out the if statement and give you what my code looks like). But still no subscribers being added. Am I missing something else? I think the code you shown to me is similar on what I also show to you.

    My MCAPI.class.php is under wp-content/themes/child_theme

    Plugin Author sparkweb

    (@sparkweb)

    You don’t have to deactivate your account, just deactivate the API key and make a new one.

    I said “So the code should start with line 9 and end with line 18.” You don’t want to have the stuff around the outside – that’s the part that says “if the checkbox is checked, add to MailChimp”.

    Thread Starter andysuarez

    (@andysuarez)

    ow..I see..OK I will try now..sorry for not understanding well.

    Thread Starter andysuarez

    (@andysuarez)

    I have tried it just now but still was not able to add subscriber to the list

    Plugin Author sparkweb

    (@sparkweb)

    ok now comes the troubleshooting. Right after the code put print_r($retval);

    Then refeed the transaction. It should generate an error. Put the error details here.

    Thread Starter andysuarez

    (@andysuarez)

    DataFeed Failed: (460864635) 2014-11-13 10:33:36 Datafeed Returned: <head/>
    <b>Warning</b>: require_once(MCAPI.class.php): failed to open stream: No such file or directory in <b>/home/drrjp/public_html/wp-content/plugins/foxyshop/themefiles/foxyshop-datafeed-endpoint.php</b> on line <b>217</b>

    <b>Fatal error</b>: require_once(): Failed opening required ‘MCAPI.class.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php:/home/drrjp/public_html/wp-content/plugins/background-manager/vendor/OAuth/lib’) in <b>/home/drrjp/public_html/wp-content/plugin

    Plugin Author sparkweb

    (@sparkweb)

    It looks like you are editing the foxyshop-datafeed-endpoint.php in the plugin instead of making a copy and putting it in your theme folder. Please follow the instructions in step 2. And make sure that the MCAPI.class.php file is in your theme folder as well.

    Thread Starter andysuarez

    (@andysuarez)

    I see..so I will just copy the foxyshop-datafeed-endpoint.php in the plugin and upload the file under my theme’s file? I am using a child theme so I will add both MCAPI.class.php file and the foxyshop-datafeed-endpoint.php under my child theme?

    Plugin Author sparkweb

    (@sparkweb)

    Yes, that is correct. Then refeed again and see if there are any errors. You want to look at what $retval returns. If it returns an error that is helpful information. If it returns a success it means you are all set and then can just comment out the print_r line or remove it.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘MailChimp Email Integration Not Adding New Subscriber’ is closed to new replies.