Search code examples
woocommercepluginsheaderhook

Is there a way to remove woocommerce_email_header action hook from emails without changing the plugin file?


contents of file class-wc-emails.php

Does anyone know how to remove this action email_header without editing this plugin file which the action is called in (plugins->woocommerce->includes->class-wc-emails.php).

I can remove the class with:

remove_action( 'woocommerce_email_header', array( $this, 'email_header' ) );

But only in the plugin file. Also I've tried:

remove_action( 'woocommerce_email_header', array( 'WC_Emails', 'email_header' ) );


Solution

  • add_action('woocommerce_email', 'remove_wc_header');
    
    function remove_wc_header($email_class) {
        
        remove_action( 'woocommerce_email_header', array( $email_class, 'email_header' ), 10, 4 );
    }
    

    Here is the code to remove the header. I'll leave it here if anyone needs it