skip to Main Content

I would like to change the background color of the product thumbnails that the customer receives via WooCommerce email.
Is it possible to add a css to do this without modifying the original PNGs of the product photos? as a matter of design I would like to maintain the transparencies.

This is what I applied to my PHP to show the thumbnail:

add_filter( 'woocommerce_email_order_items_args', 'custom_email_order_items_args', 10, 1 );
function custom_email_order_items_args( $args ) {
    $args['show_image'] = true;
}

2

Answers


  1. Chosen as BEST ANSWER

    I tried to insert the code inside my "function.PHP" file but unfortunately it still doesn't work. A doubt arises in my mind: the problem occurs on a Gmail test mailbox "I attach image", however when sending the email on WebMail (siteground) the background color of the images is white. Is there a way to resolve this conflict? This is a real inconvenience for me because some products in my shop have a completely black image.enter image description here


  2. You can use the following hooked function, to set thumbnail product backgound color to white:

    add_filter( 'woocommerce_email_styles', 'custom_wc_email_styles', 20 );
    function custom_wc_email_styles( $css ) {
        $css .= '.order_item > td > img { background-color: #ffffff; }';
        return $css;
    }
    

    Code goes in functions.php file of your child theme (or in a plugin). Tested and works.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search