Skip to content

Commit 60911cf

Browse files
committed
unhook all the transactional emails
1 parent 1a306d4 commit 60911cf

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

includes/CLI.php

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,34 @@ public static function customers( $args, $assoc_args ) {
135135
* Disable sending WooCommerce emails when generating objects.
136136
*/
137137
protected static function disable_emails() {
138-
$wc_emails = \WC_Emails::instance();
139-
remove_action( 'woocommerce_email_header', array( $wc_emails, 'email_header' ) );
140-
remove_action( 'woocommerce_email_footer', array( $wc_emails, 'email_footer' ) );
141-
remove_action( 'woocommerce_email_order_details', array( $wc_emails, 'order_downloads' ), 10, 4 );
142-
remove_action( 'woocommerce_email_order_details', array( $wc_emails, 'order_details' ), 10, 4 );
143-
remove_action( 'woocommerce_email_order_meta', array( $wc_emails, 'order_meta' ), 10, 3 );
144-
remove_action( 'woocommerce_email_customer_details', array( $wc_emails, 'customer_details' ), 10, 3 );
145-
remove_action( 'woocommerce_email_customer_details', array( $wc_emails, 'email_addresses' ), 20, 3 );
146-
remove_action( 'woocommerce_low_stock_notification', array( $wc_emails, 'low_stock' ) );
147-
remove_action( 'woocommerce_no_stock_notification', array( $wc_emails, 'no_stock' ) );
148-
remove_action( 'woocommerce_product_on_backorder_notification', array( $wc_emails, 'backorder' ) );
149-
remove_action( 'woocommerce_created_customer_notification', array( $wc_emails, 'customer_new_account' ), 10, 3 );
150-
remove_filter( 'woocommerce_email_footer_text', array( $wc_emails, 'replace_placeholders' ) );
151-
138+
$email_actions = array(
139+
'woocommerce_low_stock',
140+
'woocommerce_no_stock',
141+
'woocommerce_product_on_backorder',
142+
'woocommerce_order_status_pending_to_processing',
143+
'woocommerce_order_status_pending_to_completed',
144+
'woocommerce_order_status_processing_to_cancelled',
145+
'woocommerce_order_status_pending_to_failed',
146+
'woocommerce_order_status_pending_to_on-hold',
147+
'woocommerce_order_status_failed_to_processing',
148+
'woocommerce_order_status_failed_to_completed',
149+
'woocommerce_order_status_failed_to_on-hold',
150+
'woocommerce_order_status_cancelled_to_processing',
151+
'woocommerce_order_status_cancelled_to_completed',
152+
'woocommerce_order_status_cancelled_to_on-hold',
153+
'woocommerce_order_status_on-hold_to_processing',
154+
'woocommerce_order_status_on-hold_to_cancelled',
155+
'woocommerce_order_status_on-hold_to_failed',
156+
'woocommerce_order_status_completed',
157+
'woocommerce_order_fully_refunded',
158+
'woocommerce_order_partially_refunded',
159+
'woocommerce_new_customer_note',
160+
'woocommerce_created_customer',
161+
);
162+
163+
foreach ( $email_actions as $action ) {
164+
remove_action( $action, array( 'WC_Emails', 'send_transactional_email' ), 10, 10 );
165+
}
152166
}
153167
}
154168
WP_CLI::add_command( 'wc generate products', array( 'WC\SmoothGenerator\CLI', 'products' ) );

0 commit comments

Comments
 (0)