我在这个相关的答案中找到了我的问题的部分和可行的答案:
send-an-email-notification-when-order-status-changhe-fron-pendig-to-cancelled
我正在考虑使用所提供的解决方案,但希望看看我是否可以更改电子邮件通知以明确说明“现在已取消的待处理订单”,因此它与常规取消的订单不同。
我该怎么做?
答案 0 :(得分:0)
您可以尝试这样做,以自定义此电子邮件的标题和主题:
add_action('woocommerce_order_status_pending_to_cancelled', 'cancelled_send_an_email_notification', 10, 2 );
function cancelled_send_an_email_notification( $order_id, $order ){
// Getting all WC_emails objects
$email_notifications = WC()->mailer()->get_emails();
// Cancelled Order email notification
$email_obj = $email_notifications['WC_Email_Cancelled_Order'];
// Customizing heading and subject
$email_obj->settings['heading'] = __( "Pending payment order now Cancelled", "woocommerce" );
$email_obj->settings['subject'] = __( "[{site_title}] Pending payment order ({order_number}), now Cancelled", "woocommerce" );
// Sending the email
$email_obj->trigger( $order_id );
}
代码放在活动子主题(或主题)的function.php文件中,或者放在任何插件文件中。
经过测试和工作