【问题标题】:Customizing Woocommerce email notification when order is pending payment订单待付款时自定义 Woocommerce 电子邮件通知
【发布时间】:2018-04-23 04:34:07
【问题描述】:

我在这个相关答案中找到了我的问题的部分可行答案:
send-an-email-notification-when-order-status-changhe-fron-pendig-to-cancelled

我正在考虑使用提供的解决方案,但想看看我是否可以将电子邮件通知更改为清楚地说“待付款订单现已取消”,因此它与常规取消的订单不同。

我该怎么做?

【问题讨论】:

    标签: php wordpress woocommerce orders email-notifications


    【解决方案1】:

    您可以尝试自定义此电子邮件的标题和主题:

    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 文件或任何插件文件中。

    经过测试并且可以工作

    【讨论】:

    • 太棒了!效果很好。非常感谢 Loic 的所有帮助。
    猜你喜欢
    • 2016-03-03
    • 2018-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-12
    • 2019-05-21
    • 1970-01-01
    • 2019-07-18
    相关资源
    最近更新 更多