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 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数