KoolPal
KoolPal

Reputation: 365

Followup - Woocommerce different headers for each email types

Objective Replace default email-header.php for some specific emails with custom email headers. I wish to point to separate email header template files.

I have WordPress : 4.9.1 Woocommerce : 3.2.5

This is a question based on the solution provided here: Woocommerce different headers for each email types

I followed the code solution as provided by @helgatheviking here: https://stackoverflow.com/a/27406663/8044005

Perhaps the solution provided earlier is not working due to changes in WP & WC

In my functions.php I have

    function so_27400044_remove_email_header(){
    remove_action( 'woocommerce_email_header', 'email_header');
}
add_action( 'init', 'so_27400044_remove_email_header' );

I created a new header file for this Admin New Order email and added the reference in my admin-new-order.php I have

<?php do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<?php wc_get_template( 'emails/admin-new-order-header.php', array( 'email_heading' => $email_heading ) ) ; ?>

When I test this email, I get both the headers! existing as well the new header I created!

Please guide me.

Thanks a lot!

Upvotes: 2

Views: 661

Answers (1)

LoicTheAztec
LoicTheAztec

Reputation: 253886

As it's not possible to remove default email header for now in WooCommerce 3.2+, you should just remove from those specific email templates the following code line:

<?php do_action( 'woocommerce_email_header', $email_heading, $email ); ?>

Then just add instead (your custom template):

<?php wc_get_template( 'emails/admin-new-order-header.php', array( 'email_heading' => $email_heading ) ) ; ?>

I don't see for the moment another way.

Upvotes: 2

Related Questions