How to Display Product Images in WooCommerce Order Emails
In WooCommerce, order emails are a vital part of communicating with customers and providing them with essential information about their purchases. However, by default, WooCommerce order emails do not include product images in the order table. This omission can lead to a less visually appealing and informative email for customers.
Enabling Product Images in Order Emails
Fortunately, WooCommerce offers flexibility and customization options through filters, allowing you to include product images in order emails effortlessly. By using a simple code snippet, you can enable product images in the order table of WooCommerce order emails.
Solution: Enabling Product Images in Order Emails
To enable product images in order emails, you can use the following code snippet:
add_filter( 'woocommerce_email_order_items_args', 'wc_force_showing_items_images_in_email', 100, 1 );
/**
* Force Showing images in Order Email Table.
*
* @param array $items_arr
* @return array
*/
function wc_force_showing_items_images_in_email( $items_arr ) {
$items_arr['show_image'] = true;
return $items_arr;
}
How to Use the Snippet Code
You can implement this snippet by following on of these steps:
- Child Theme: If you’re using a custom child theme, you can add the snippet to the
functions.php
file of your child theme. This ensures that the functionality remains intact even when you update your theme. - Custom Plugin: A better way, you can create a custom plugin to add the snippet. Creating a custom plugin allows you to keep your code separate from the theme files, making it easier to manage and maintain. You can use our online tool WP Plugin Creator to generate a custom plugin with the snippet included. Simply paste the snippet into the plugin code editor, specify the plugin name, and download the generated plugin zip file.