![](/img/trans.png)
[英]Send New Order email to an additional email based on payment type in Woocommerce
[英]WooCommerce: Show notice on new order email if specific payment method is used
我想在表格前發送給管理員的“新訂單”電子郵件中添加一條通知,這樣如果客戶使用“采購訂單”付款,處理團隊就會知道付款正在等待中。
研究和工作完成:我花了一些時間研究各種 tuts 和 docs 並想出了版本 1代碼,但它在訂單電子郵件中沒有顯示任何內容(我更改了代碼版本 2並再次嘗試但無濟於事)。 代碼有錯嗎? 在考慮其他選項之前,我只想確認一下。 謝謝
版本 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 );
如果其他人對此感興趣,這對我有用:
/* 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 );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.