Skip to content
Advertisement

Adding an image near the footer on WooCommerce completed orders email notification

I’m trying this code to insert images just near the footer in WooCommerce completed orders email notification, but unfortunately it doesn’t work!

Here’s the code I’m trying:

    <?php
    echo ("Hello");
    ?>
    <div>
        <img src="myPic.jpg" alt="myPic" />
    </div>

Any Clue please?

Thanks

Advertisement

Answer

You should better use a custom hooked function in woocommerce_email_customer_details action hook for example, this way:

add_action( 'woocommerce_email_customer_details', 'custom_image_near_email_footer' , 50, 4);
function custom_image_near_email_footer( $order, $sent_to_admin, $plain_text, $email ) {    
    // For customer order notification with "completed" status
    if ( 'customer_completed_order' == $email->id ) 
        echo '<div style="text-align:center;">
            <img src="'.home_url( "wp-content/uploads/2017/05/myPic.jpg" ).'" alt="myPic"/>
        </div>';
}

You could also use woocommerce_email_footer action hook instead which have only one argument ($email argument).

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

This code is tested and works on WooCommerce version 2.6.x and 3.0+

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement