我只想将购物车发送到photocrati wp主题的电子邮件

时间:2012-11-13 07:27:48

标签: jquery wordpress wordpress-theming shopping-cart email-integration

我正在使用Photocrati WordPress主题,该主题只有一个结帐流程,可重定向到PayPal。我创建了一个新按钮,但是我需要它来调用另一个动作,将购物车的内容发送到特定的电子邮件,并将用户重定向到感谢页面而没有支付网关,如PayPal。即使我成功创建了按钮,我仍然迷失了如何完成这项工作,但就是这样。这似乎非常简单,因为所有的价值观都存在,任何帮助或方向都将受到高度赞赏。 Photocrati主题使用jQuery和php的组合作为购物车。购物车页面是WordPress模板页面文件,但这里是sendcart.php(从模板页面文件调用的操作文件):     

define('ABSPATH', dirname(dirname(dirname(dirname(__FILE__)))).'/');
include_once(ABSPATH.'wp-config.php');
include_once(ABSPATH.'wp-load.php');
include_once(ABSPATH.'wp-includes/wp-db.php');
global $wpdb;

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

// assign posted variables to local variables
$firstName = $_POST['first_name'];
$lastName = $_POST['last_name'];
$email = $_POST['payer_email'];

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}

$admin_info = get_userdata(1);
$admineaddr = get_option('admin_email');

if (isset($admin_info->user_email) && $admin_info->user_email != null)
{
    $admineaddr = $admin_info->user_email;
}

// Send thank you email/receipt
$p_date = date("M d, Y");
$subject = "Thank you for your purchase!";
$message = "Thank you for your purchase! A notification will be sent to you by PayPal with the transaction details.";
$headers = "From: ".$admineaddr."\r\n";
$headers .= "Return-Path: ".$admineaddr."\r\n";

mail($email, $subject, $message, $headers);


$subject2 = "New Sale";
$message2 = "A new sale has been made:
Name: ".$firstName." ".$lastName."
Email: ".$email."";                         
$headers2 = "From: ".$admineaddr."\r\n";
$headers2 .= "Return-Path: ".$admineaddr."\r\n";

mail($admineaddr, $subject2, $message2, $headers2);

/* IMPORTANT! This code empties the entire cart! */
unset($_SESSION['cart']);
unset($_SESSION['cart_qty']);
?>

请帮忙!! 感谢。

1 个答案:

答案 0 :(得分:1)

我以为我会参加Photocrati工作 - 我们正在研究NextGEN Gallery Pro,它将无缝集成到Photocrati 5.未来的更新将包括一个具有更多功能的电子商务系统,包括多个支付选项。