• Peter

    (@oncoursegoggles)


    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' ) );
    }
    }
    • This topic was modified 5 years, 2 months ago by Peter.
Viewing 1 replies (of 1 total)
  • Hey,
    I can’t really think of what in this plugin would be effecting that. I suppose the filter to set the templates language for the purchaser could be. This is for multilingual support.

    Try adding this in your snippets:

    add_action( 'init', 'custom_unfilter_woo_email_designer', 20 );
    function custom_unfilter_woo_email_designer() {
    if ( class_exists( 'Kadence_Woomail_Designer' ) ) {
    $kadence_mail_instance = Kadence_Woomail_Designer::get_instance();
    remove_filter( 'woocommerce_email_setup_locale', array( $kadence_mail_instance, 'switch_to_site_locale' ) );
    remove_filter( 'woocommerce_email_restore_locale', array( $kadence_mail_instance, 'restore_to_user_locale' ) );
    }
    }

    That is a guess? I find it hard to see how that would be but I can’t think of anthing else.

    Ben

Viewing 1 replies (of 1 total)
  • The topic ‘Suppressing Emails When Admin or Store Manager Creates Order’ is closed to new replies.