duanlan8763 2017-01-04 22:25
浏览 64
已采纳

在WooCommerce中自定义客户处理电子邮件通知

I am very new to WordPress, and have created an e-commerce store with WooCommerce.

After the customer places an order, I get an email and the customer get an email- one for me to say what they have ordered, and one to them as a thank you email.

Within this thank you email, in my functions.php file, I have learned to change the subject of the header to include their name such as this:

//add the first name of the person to the person getting the reciept in the subject of the email. 
add_filter('woocommerce_email_subject_customer_processing_order','UEBC_change_processing_email_subject', 10, 2);

function UEBC_change_processing_email_subject( $subject, $order ) {
global $woocommerce;
$subject = 'Thanks for your ' . get_bloginfo( 'name', 'display' ) . ' Order, '.$order->billing_first_name .'!';
return $subject;
}

The code snippet above works correctly, and is only displayed to the customer, not to me. e.g. "thanks for your order ABCD Clothes order John!". Within the body of the email, I am trying to make this personal as a small thank you message, however, when I make the message, I am using the hook:

add_action( 'woocommerce_email_before_order_table', 'custom_add_content', 20,1 );

I know that since im using the woocommerce_email_before_order_table hook, the custom function will be send in the body of the email to both the customer and myself.

I was wondering, is there a hook that Woocommerce provides so that the custom function will only be sent to the customer within the body of the email?

For example: woocommerce_email_header_customer_processing_order or words to that effect?

Thanks

  • 写回答

1条回答 默认 最新

  • dounuo9921 2017-01-05 02:58
    关注

    To add some custom content using woocommerce_email_before_order_table hook and targeting just the customer "processing order" email notification, you should try this:

    add_action( 'woocommerce_email_before_order_table', 'custom_content_to_processing_customer_email', 10, 4 );
    function custom_content_to_processing_customer_email( $order, $sent_to_admin, $plain_text, $email ) {
    
        if( 'customer_processing_order' == $email->id ){
    
            // Set here as you want your custom content (for customers and email notification related to processing orders only)
            echo '<p class="some-class">Here goes your custom content… </p>';
    
        }
    
    }
    

    Code goes in function.php file of your active child theme (or theme). Or also in any plugin php files.

    This code is tested and works

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀