将可点击的动态支付请求 uri 添加到 WooCommerce 中的暂停电子邮件通知
Add a clikable dynamic payment request uri to on-hold email notification in WooCommerce
我有一个付款请求 uri,如下所示:
https://www.mypaymentsite.com/cgi-bin/webscr?&cmd=_xclick&business=89000¤cy_code=USD&amount=9&item_name=ebook
我正在尝试创建一个动态的可点击支付 link,它将捕获 WooCommerce 订单总额作为金额。
url
的起始部分
https://www.mypaymentsite.com/cgi-bin/webscr?&cmd=_xclick&business=89000¤cy_code=USD&amount=
应该保持不变。然后附加订单总数,最后是最后的 url 部分 &item_name=ebook
付款 link 可以添加到客户的 order_on_hold woocommerce_email_before_order_table 或添加到付款说明中。
到目前为止,这是我的代码
add_action( 'woocommerce_email_before_order_table', 'customer_note_email_before_order_table', 10, 4 );
function customer_note_email_before_order_table( $order, $sent_to_admin, $plain_text, $email ){
// Only on onhold email notifications
if ( in_array( $email->id, array('customer_on_hold_order') ) ) :
//first part of the url
$first_url_part = "https://www.mypaymentsite.com/cgi-bin/webscr?&cmd=_xclick&business=89000¤cy_code=USD&amount=";
// Get customer Order total as the 2nd part
$order_total = $order->get_order_total();
//last part of the url
$last_url_part = "&item_name=ebook";
//Full url now. How do i combine those to make a url?
$payment_link = $first_url_part$order_total$last_url_part;
// lastly Display payment note "click here to send order payment directly" with "click here" as link text
echo '<h2>' . __("Direct Payment Link", "woocommerce") . '</h2> //HOW DO I ECHO THAT?
<div style="margin-bottom: 40px;">
<table cellspacing="0" cellpadding="0" style="width: 100%; color: #636363; border: 2px solid #e5e5e5;" border="0">
<tr><td><p>' . $payment_link . '</p></td></tr>
</table></div>';
endif;
}
我已经能够将 link 添加到付款说明中,但我无法附加订单金额。当我尝试 {order_total} 时它不起作用。我需要帮助。
您的代码有一些错误
- 将
$order->get_order_total()
替换为$order->get_total()
- 在变量之间放置点以连接它们
- 缺少使 link 有效工作的代码
所以你得到:
function action_woocommerce_email_before_order_table( $order, $sent_to_admin, $plain_text, $email ) {
// Only on onhold email notifications
if ( in_array( $email->id, array( 'customer_on_hold_order' ) ) ) {
// First part of the url
$first_url_part = 'https://www.mypaymentsite.com/cgi-bin/webscr?&cmd=_xclick&business=89000¤cy_code=USD&amount=';
// Get customer Order total as the 2nd part
$order_total = $order->get_total();
// Last part of the url
$last_url_part = '&item_name=ebook';
// Full url
$payment_link = $first_url_part . $order_total . $last_url_part;
// Lastly display payment note "click here to send order payment directly" with "click here" as link text
echo '<h2>' . __( 'Direct Payment Link', 'woocommerce') . '</h2>
<div style="margin-bottom: 40px;">
<table cellspacing="0" cellpadding="0" style="width: 100%; color: #636363; border: 2px solid #e5e5e5;" border="0">
<tr><td><span><a href="' . $payment_link . '">click here</a> to send order payment directly</span></td></tr>
</table></div>';
}
}
add_action( 'woocommerce_email_before_order_table', 'action_woocommerce_email_before_order_table', 10, 4 );
我有一个付款请求 uri,如下所示:
https://www.mypaymentsite.com/cgi-bin/webscr?&cmd=_xclick&business=89000¤cy_code=USD&amount=9&item_name=ebook
我正在尝试创建一个动态的可点击支付 link,它将捕获 WooCommerce 订单总额作为金额。
url
的起始部分https://www.mypaymentsite.com/cgi-bin/webscr?&cmd=_xclick&business=89000¤cy_code=USD&amount=
应该保持不变。然后附加订单总数,最后是最后的 url 部分 &item_name=ebook
付款 link 可以添加到客户的 order_on_hold woocommerce_email_before_order_table 或添加到付款说明中。
到目前为止,这是我的代码
add_action( 'woocommerce_email_before_order_table', 'customer_note_email_before_order_table', 10, 4 );
function customer_note_email_before_order_table( $order, $sent_to_admin, $plain_text, $email ){
// Only on onhold email notifications
if ( in_array( $email->id, array('customer_on_hold_order') ) ) :
//first part of the url
$first_url_part = "https://www.mypaymentsite.com/cgi-bin/webscr?&cmd=_xclick&business=89000¤cy_code=USD&amount=";
// Get customer Order total as the 2nd part
$order_total = $order->get_order_total();
//last part of the url
$last_url_part = "&item_name=ebook";
//Full url now. How do i combine those to make a url?
$payment_link = $first_url_part$order_total$last_url_part;
// lastly Display payment note "click here to send order payment directly" with "click here" as link text
echo '<h2>' . __("Direct Payment Link", "woocommerce") . '</h2> //HOW DO I ECHO THAT?
<div style="margin-bottom: 40px;">
<table cellspacing="0" cellpadding="0" style="width: 100%; color: #636363; border: 2px solid #e5e5e5;" border="0">
<tr><td><p>' . $payment_link . '</p></td></tr>
</table></div>';
endif;
}
我已经能够将 link 添加到付款说明中,但我无法附加订单金额。当我尝试 {order_total} 时它不起作用。我需要帮助。
您的代码有一些错误
- 将
$order->get_order_total()
替换为$order->get_total()
- 在变量之间放置点以连接它们
- 缺少使 link 有效工作的代码
所以你得到:
function action_woocommerce_email_before_order_table( $order, $sent_to_admin, $plain_text, $email ) {
// Only on onhold email notifications
if ( in_array( $email->id, array( 'customer_on_hold_order' ) ) ) {
// First part of the url
$first_url_part = 'https://www.mypaymentsite.com/cgi-bin/webscr?&cmd=_xclick&business=89000¤cy_code=USD&amount=';
// Get customer Order total as the 2nd part
$order_total = $order->get_total();
// Last part of the url
$last_url_part = '&item_name=ebook';
// Full url
$payment_link = $first_url_part . $order_total . $last_url_part;
// Lastly display payment note "click here to send order payment directly" with "click here" as link text
echo '<h2>' . __( 'Direct Payment Link', 'woocommerce') . '</h2>
<div style="margin-bottom: 40px;">
<table cellspacing="0" cellpadding="0" style="width: 100%; color: #636363; border: 2px solid #e5e5e5;" border="0">
<tr><td><span><a href="' . $payment_link . '">click here</a> to send order payment directly</span></td></tr>
</table></div>';
}
}
add_action( 'woocommerce_email_before_order_table', 'action_woocommerce_email_before_order_table', 10, 4 );