【问题标题】:Woocommerce emails: send text only to customerWoocommerce 电子邮件:仅向客户发送文本
【发布时间】:2015-10-29 13:40:49
【问题描述】:

我在 Woocommerce-order-processing-email 中添加了一些文本:

add_action(
    'woocommerce_email_before_order_table',    
    'add_order_email_instructions', 
    0
);

function add_order_email_instructions( $order ) {
    if ( 'paypal' == $order->payment_method ) {
        echo 'my text:';
    } 
}

这可行,但我希望文本仅出现在发送给客户的电子邮件中,而不是管理员。我需要添加什么?

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    传入两个参数。

    add_action(
        'woocommerce_email_before_order_table',    
        'add_order_email_instructions', 
        0,2
    );
    

    第二个参数是你想要的条件。

    function add_order_email_instructions( $order, $sent_to_admin ) {
        if ( 'paypal' == $order->payment_method && !$sent_to_admin) {
            echo 'my text:';
        } 
    }
    

    将操作限制在处理订单时:

      add_action('woocommerce_order_status_processing', 'scriptonomy_when_processing');
        function scriptonomy_when_processing(){  
    add_action('woocommerce_email_before_order_table', 'add_order_email_instructions', 0,2); 
    }
    

    【讨论】:

    • 太好了,我如何编辑它以使其仅显示在订单处理电子邮件中? (不是订单完成,发票等)
    • 挂钩到 woocommerce_order_status_processing 操作
    • 对不起,我是初学者,你介意告诉我怎么做吗?
    • 我已更新我的答案以包含代码示例。
    猜你喜欢
    • 2017-08-08
    • 2020-06-03
    • 2017-08-19
    • 2014-03-09
    • 1970-01-01
    • 2016-10-26
    • 1970-01-01
    • 2019-05-10
    • 1970-01-01
    相关资源
    最近更新 更多