Skip to content

Commit 9b5946f

Browse files
authored
Unhook and Remove WooCommerce Default Emails Add
1 parent 91ab65f commit 9b5946f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/**
4+
* Unhook and Remove WooCommerce Default Emails
5+
*
6+
* https://gist.github.com/woogists/761755ba87c8c0ca0abcc3fc6a4c8628
7+
*/
8+
add_action( 'woocommerce_email', 'unhook_those_pesky_emails' );
9+
10+
function unhook_those_pesky_emails( $email_class ) {
11+
12+
/**
13+
* Hooks for sending emails during store events
14+
**/
15+
remove_action( 'woocommerce_low_stock_notification', array( $email_class, 'low_stock' ) );
16+
remove_action( 'woocommerce_no_stock_notification', array( $email_class, 'no_stock' ) );
17+
remove_action( 'woocommerce_product_on_backorder_notification', array( $email_class, 'backorder' ) );
18+
19+
// New order emails
20+
remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
21+
remove_action( 'woocommerce_order_status_pending_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
22+
remove_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
23+
remove_action( 'woocommerce_order_status_failed_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
24+
remove_action( 'woocommerce_order_status_failed_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
25+
remove_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
26+
27+
// Processing order emails
28+
remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) );
29+
remove_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) );
30+
31+
// Completed order emails
32+
remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) );
33+
34+
// Note emails
35+
remove_action( 'woocommerce_new_customer_note_notification', array( $email_class->emails['WC_Email_Customer_Note'], 'trigger' ) );
36+
}

0 commit comments

Comments
 (0)