【问题标题】:I simply want to send shopping cart to email in photocrati wp theme我只是想在 photocrati wp 主题中将购物车发送到电子邮件
【发布时间】:2012-11-13 07:27:47
【问题描述】:

我正在使用一个 Photocrati WordPress 主题,它只有一个重定向到 PayPal 的结帐过程。我创建了一个新按钮,但我需要它来调用不同的操作,将购物车的内容发送到特定的电子邮件,并将用户重定向到感谢页面,而无需支付网关,例如 PayPal。即使我成功创建了按钮,我也不知道如何完成这项工作,仅此而已。这似乎很简单,因为所有的价值都在那里,任何帮助或指导将不胜感激。 Photocrati Themes 将 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']);
?>

请帮忙!! 谢谢。

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 感谢您的评论,但不幸的是,这是目前的迫切需求,我迫不及待地等待未来的更新来完成这项工作。如果您对我有短期解决方案,我将非常乐意接受。
    • 我们从其他客户那里听说 FotoMoto 使用该主题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-12
    • 2012-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多