Suppressing Emails When Admin or Store Manager Creates Order
-
Hello,
We are currently using a snippets plugin that was suppressing emails when Admin or Store Manager creates an order. This is because we are duplicating orders from an older system that we were using with a different host, so we don’t want those Customers to receive emails for these older orders.
I say “was”, because it seems that after installing Kadence, the email messages are no longer suppressed.
Do we need to create a snippet for a new user role (Kadence) ?
Thanks
Peter
Here’s an example of the snippet we use to inhibit the emails:
//** Inhibit WooCommerce Emails to Customer when user is Shop Manager **// add_action( 'woocommerce_email', 'unhook_emails_for_shop_manager' ); function unhook_emails_for_shop_manager( $email_class ) { $user = wp_get_current_user(); if ( in_array( 'shop_manager', (array) $user->roles ) ) { // New order emails remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) ); remove_action( 'woocommerce_order_status_pending_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) ); remove_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) ); remove_action( 'woocommerce_order_status_failed_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) ); remove_action( 'woocommerce_order_status_failed_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) ); remove_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) ); // Processing order emails remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) ); remove_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) ); // Completed order emails remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) ); // Note emails remove_action( 'woocommerce_new_customer_note_notification', array( $email_class->emails['WC_Email_Customer_Note'], 'trigger' ) ); } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Suppressing Emails When Admin or Store Manager Creates Order’ is closed to new replies.