add_action( 'woocommerce_email', 'disable_duplicate_woocommerce_emails' );
function disable_duplicate_woocommerce_emails( $email_class ) {
// เลือกปิดตัวใดตัวหนึ่ง เพื่อให้เหลืออีเมลส่งหาลูกค้าฉบับเดียว
// ตัวเลือก A: ปิดอีเมล Processing (คำสั่งซื้อที่กำลังประมวลผล)
remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) );
// ตัวเลือก B: ปิดอีเมล Completed (คำสั่งซื้อที่เสร็จสมบูรณ์แล้ว)
// remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) );
}ใช้โค้ดอย่างระมัดระวังadd_filter( 'woocommerce_email_customer_details_fields', 'custom_remove_addresses_from_completed_email', 10, 3 );
function custom_remove_addresses_from_completed_email( $fields, $sent_to_admin, $email ) {
// ตรวจสอบว่าเป็นอีเมลคำสั่งซื้อเสร็จสมบูรณ์ (customer_completed_order) ใช่หรือไม่
if ( 'customer_completed_order' === $email->id ) {
// ลบข้อมูลที่อยู่ใบเสร็จและที่อยู่จัดส่งออก
unset( $fields['billing_address'] );
unset( $fields['shipping_address'] );
}
return $fields;
}ใช้โค้ดอย่างระมัดระวัง/* ลบหรือคอมเมนต์บรรทัดนี้ออก */
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );ใช้โค้ดอย่างระมัดระวัง