我在WordPress网站上有一个联系表单为7的表单。当您单击“提交”时,您将在Paypal上重定向并很高兴付款:)。一切正常,但是我想要更多。我只想在访客使用Paypal付款时才发送邮件。我已经在Google上进行搜索,但是还没有找到实现此目的的方法。
任何想法?
谢谢!
内森
您可以使用PayPal IPN完成此操作。 free plugin available to get PayPal IPN setup in WordPress非常容易,但是您需要从functions.php文件(或您自己的插件)中建立一个基本钩子,以根据您希望发送的时间来触发电子邮件。
您可以根据不同的PayPal交易类型或付款状态触发所需的任何操作。
这是从扩展程序向IPN插件发送电子邮件的非常基本的示例。这是一个完整的插件文件,仅包含插件的钩子。在这种情况下,我正在使用paypal_ipn_for_wordpress_txn_type_cart挂钩。
<?php
/**
* @package PayPal IPN for WordPress - Hook Template
* @version 1.0.0
*/
/*
Plugin Name: PayPal IPN for WordPress - Hook Template
Plugin URI: http://www.angelleye.com/
Description: Hook tester for PayPal IPN for WordPress plugin.
Author: angelleye
Version: 1.0.0
*/
add_action('paypal_ipn_for_wordpress_txn_type_cart', 'paypal_ipn_for_wordpress_txn_type_cart', 10, 1);
function paypal_ipn_for_wordpress_txn_type_cart($posted) {
// Parse data from IPN $posted array
$payment_status = isset($posted['payment_status']) ? $posted['payment_status'] : '';
$mc_gross = isset($posted['mc_gross']) ? $posted['mc_gross'] : '';
$first_name = isset($posted['first_name']) ? $posted['first_name'] : '';
$last_name = isset($posted['last_name']) ? $posted['last_name'] : '';
$cart_items = isset($posted['cart_items']) ? $posted['cart_items'] : '';
/**
* At this point you can use the data to generate email notifications,
* update your local database, hit 3rd party web services, or anything
* else you might want to automate based on this type of IPN.
*/
$to = '[email protected]';
$subject = 'Email from PayPal IPN';
$message = 'Order Total: ' . $mc_gross . "\n";
$message .= 'Payment Status: ' . $payment_status . "\n";
$message .= 'Name: ' . $first_name . ' ' . $last_name . "\n";
$message .= 'Cart Items: ' . print_r($cart_items, true);
wp_mail( $to, $subject, $message );
}
因此,在您的网站上同时安装了IPN插件和此插件的情况下,无论何时在您的PayPal帐户上进行购物车交易,都会相应地发送电子邮件。这是在网站上激活此插件并在PayPal上运行测试交易时收到的电子邮件示例。
Order Total: 90.27
Payment Status: Completed
Name: Tester Testerson
Cart Items: Array
(
[0] => Array
(
[item_number] =>
[item_name] => Woo Album #2
[quantity] => 1
[mc_gross] => 75.27
[mc_handling] => 0.00
[mc_shipping] => 0.00
[custom] =>
[option_name1] =>
[option_selection1] =>
[option_name2] =>
[option_selection2] =>
[btn_id] =>
[tax] => 0.00
)
)
当然,您可以花一些时间使电子邮件更漂亮,并将其发送到所需的任何电子邮件地址。
同样,您可以根据不同的IPN类型或付款状态,使用lots of different hooks触发自己的插件功能。
这里的示例仅包含IPN提供的一些数据参数,但是WordPress中的IPN记录将为您提供一个模板,您可以轻松地将其复制/粘贴到自己的插件文件中,该文件包含该IPN类型可用的每个IPN参数。 >
列出的PayPal IPN plugin目前不可用,是否还有其他活动的插件?