Advertisement
sparkweb

Add Customer to Mailchimp

Aug 31st, 2011
263
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         //Add Customer To Mailchimp
  2.         $add_to_mailchimp = 0;
  3.         foreach($transaction->custom_fields->custom_field as $custom_field) {
  4.             if ((string)$custom_field->custom_field_name == "newsletter_subscribe" && (string)$custom_field->custom_field_value == "1") {
  5.                 $add_to_mailchimp = 1;
  6.             }
  7.         }
  8.         if ($add_to_mailchimp) {
  9.             require_once 'MCAPI.class.php';
  10.             $mailchimp_api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
  11.             $mailchimp_list_id = "xxxxxxxxxx";
  12.             $api = new MCAPI($mailchimp_api_key);
  13.             $merge_vars = array(
  14.                 'FNAME' => $customer_first_name,
  15.                 'LNAME' => $customer_last_name,
  16.                 'OPTINIP' => (string)$transaction->customer_ip
  17.             );
  18.             $retval = $api->listSubscribe($mailchimp_list_id, $customer_email, $merge_vars, "html", false);
  19.         }
Advertisement
RAW Paste Data Copied
Advertisement