.</strong> <a href="http://blog.mailchimp.com/opt-in-vs-confirmed-opt-in-vs-double-opt-in/" target="blank"><?php _e('Read more about Opt-Ins', 'cart66'); ?> </a></p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Show Lists', 'cart66'); ?> </th> <td> <?php $mcLists = false; if ($mailChimpKey = Cart66Setting::getValue('mailchimp_apikey')) { $mc = new Cart66MailChimp($mailChimpKey); $mcLists = $mc->getLists(); } if (is_array($mcLists)) { $mcSavedListIds = array(); if ($mcSavedLists = Cart66Setting::getValue('mailchimp_list_ids')) { $mcSavedListIds = explode('~', $mcSavedLists); } foreach ($mcLists as $list) { $checked = ''; $val = $list['id'] . '::' . $list['name']; Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] looking for: {$val} in " . print_r($mcSavedListIds, true)); if (in_array($val, $mcSavedListIds)) { $checked = 'checked="checked"'; } ?>
public function getLists() { $MailChimp = new Cart66MailChimp(); $api_key = Cart66Setting::getValue('mailchimp_apikey'); $api = $MailChimp->MCAPI($api_key); $retval = $MailChimp->lists(); $output = ""; if (empty($retval)) { $output = "Unable to load lists!"; $output .= "\n\tCode=" . $api->errorCode; $output .= "\n\tMsg=" . $api->errorMessage . "\n"; } else { $output = $retval['data']; } return $output; }
<?php // Look for constant contact opt-in $mcIds = Cart66Common::postVal('mailchimp_subscribe_ids'); if (isset($mcIds) && is_array($mcIds)) { Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Trying to register for Mail Chimp newsletter"); $mc = new Cart66MailChimp(); $api_key = Cart66Setting::getValue('mailchimp_apikey'); $mc->MCAPI($api_key); if (isset($_POST['payment']) && isset($_POST['billing'])) { // Process from on-site checkout forms $email = $_POST['payment']['email']; $extraFields = array('FirstName' => $_POST['billing']['firstName'], 'LastName' => $_POST['billing']['lastName']); } elseif (isset($_POST['mailchimp_email']) && isset($_POST['mailchimp_first_name']) && isset($_POST['mailchimp_last_name'])) { // Process from PayPal Express Checkout $email = Cart66Common::postVal('mailchimp_email'); $extraFields = array('FirstName' => $_POST['mailchimp_first_name'], 'LastName' => $_POST['mailchimp_last_name']); } $mcDoubleOptin = Cart66Setting::getValue('mailchimp_doubleoptin') == "no-optin" ? "false" : "true"; if (isset($email) && !empty($email)) { $merge_vars = array('FNAME' => $extraFields['FirstName'], 'LNAME' => $extraFields['LastName'], "double_optin" => $mcDoubleOptin); // By default this sends a confirmation email - you will not see new members // until the link contained in it is clicked! foreach ($mcIds as $list_id) { $retval = $mc->listSubscribe($list_id, $email, $merge_vars, "html", $mcDoubleOptin); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] listSubscribe():\n List ID: {$list_id}\n Email: {$email}\n Merge Vars: " . print_r($merge_vars, true)); } } if ($mc->errorCode) { $logmsg = "Unable to load listSubscribe()!\n"; $logmsg .= "\tCode=" . $mc->errorCode . "\n";