0

我正在为基于 WordPress 的网站上的客户集成 Shopp 和 Mailchimp。结帐页面有多个电子邮件地址的输入,所有这些都应通过 API 添加到 MailChimp。我使用 MCAPI.php 包装器成功完成了 listSubscribe() 以使第一封电子邮件正常工作。listSubscribe() 可以在处理结帐时运行的同一 PHP 函数中重复使用吗?

这是我目前拥有的代码:

/* include MailChimp API on checkout init */
add_action('shopp_order_success', 'opc_mc_checkout');
function opc_mc_checkout () {
// do stuff
require_once 'MCAPI.class.php';
$apikey='redacted'; // Enter your API key
$api = new MCAPI($apikey);
$retval = $api->lists();
$listid='redacted'; // Enter list Id here
$email=shopp('purchase.email', 'return=true'); // Enter subscriber email address
$name=shopp('purchase.firstname', 'return=true'); // Enter subscriber first name
$lname=shopp('purchase.lastname', 'return=true'); // Enter subscriber last name

// By default this sends a confirmation email - you will not see new members
// until the link contained in it is clicked!

$merge_vars = array('FNAME' => $name, 'LNAME' => $lname);
if($api->listSubscribe($listid, $email,$merge_vars) === true) {
}

/* teacher extra emails */
$apikey='redacted'; // Enter your API key
$api = new MCAPI($apikey);
$retval = $api->lists();
$listid='redacted';  // Enter list Id here
$teacher_1_email=shopp('purchase.data', 'name=Teacher 1 Email&return=true'); // Enter subscriber email //$teacher_1_email=$_POST['Teacher 1 Email']; // Enter subscriber email 
$teacher_1_name=shopp('purchase.firstname', 'return=true'); // Enter subscriber first name
$teacher_1_lname=shopp('purchase.lastname', 'return=true'); // Enter subscriber last name


$merge_vars = array('FNAME' => $teacher_1_name, 'LNAME' => $teacher_1_lname);
if($api->listSubscribe($listid, $teacher_1_email,$merge_vars) === true) {
}

我搜索了谷歌和 API 文档,但没有运气。非常感谢您的帮助!

谢谢!

4

0 回答 0