WooCommerce:如果使用特定付款方式,则在新订单电子邮件上显示通知 [英] WooCommerce: Show notice on new order email if specific payment method is used

查看:105
本文介绍了WooCommerce:如果使用特定付款方式,则在新订单电子邮件上显示通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在表格之前发送给管理员的新订单"电子邮件中添加一条通知,因此,如果客户使用购买订单"付款,则处理团队将知道付款正在处理中.

I want to add a notice to "new order" email sent to admins before the table so if customer paid with "Purchase Order", processing team will know the payment is pending.

研究与开发;完成的工作: 我花了一些时间研究各种Tut和文档,并提出了 Version 1 代码,但订单电子邮件中没有显示任何内容(我更改了 Version 2 代码,然后重试但无济于事).密码有误吗?我只想确认一下,然后再考虑其他选项.谢谢

Research & Work Done: I spent some time researching various tuts and docs and came up with the Version 1 code but it's not showing anything on the order email (I changed the code Version 2 and tried again but to no avail). Are the codes wrong? I just want to confirm before I look into other options. Thank you

版本1

/* Payment pending instruction if payment method is "Purchase Order" */
function add_order_instruction_email( $order, $sent_to_admin, $plain_text, $email ) {
    if ( $sent_to_admin ) {
        echo '<p><strong>Payment Method:</strong> '.$order->payment_method_title().'</p>';
        if ( 'Purchase Order' == $order->get_payment_method_title() ) {
            /* if purchase order method is used */
            echo '<p><strong>Note:</strong> Payment is pending, please contact customer for payment before processing order for shipping.</p>';
        }
    }
}
add_action( 'woocommerce_before_email_order_table', 'add_order_instruction_email', 20, 4 );

版本2

/* Payment pending instruction if payment method is "Purchase Order" */
function add_order_instruction_email( $order, $sent_to_admin, $plain_text, $email ) {
    if ( $email->id == 'new_order' ) {
        echo '<p><strong>Payment Method:</strong> '.$order->payment_method_title().'</p>';
        if ( 'Purchase Order' == $order->get_payment_method_title() ) {
            /* if purchase order method is used */
            echo '<p><strong>Note:</strong> Payment is pending, please contact customer for payment before processing order for shipping.</p>';
        }
    }
}
add_action( 'woocommerce_before_email_order_table', 'add_order_instruction_email', 10, 2 );

推荐答案

如果其他人对此感兴趣,这对我有用:

If someone else is interested in this, here's what worked for me:

/* Payment pending instruction if payment method is "Purchase Order" */
function add_order_instruction_email( $order, $sent_to_admin, $plain_text, $email ) {
    if ( $email->id == 'new_order' ) {
        if ( 'Purchase Order' == $order->get_payment_method_title() ) {
            echo '<p><strong>Note:</strong> Payment is pending, please contact customer for payment before processing order for shipping.</p>';
        }
    }
}
add_action( 'woocommerce_email_order_details', 'add_order_instruction_email', 10, 4 );

这篇关于WooCommerce:如果使用特定付款方式,则在新订单电子邮件上显示通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆