Support

Home Forums Event Espresso Premium Custom CSS for Email templates

Custom CSS for Email templates

Posted: October 18, 2018 at 12:21 am

Viewing 3 reply threads


yogakeys

October 18, 2018 at 12:21 am

Hi, I have seen many posts on this. I am struggling to get my style sheet to recognize in my emails.

Here is my code:

add_filter( 'gettext', 'mycustom_filter_gettext', 10, 3 );

function ee_modify_html_variation( $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack ) {
	if ( $messenger != 'html' ) {
		return $variation_path;
	}

	$new_url = get_stylesheet_directory_uri() . '/ee4-email-style.css';
	return $new_url;
}
add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', 'ee_modify_html_variation', 10, 8 );

I have placed the ee4-email-style.css file into my theme’s child folder.

Is there something I am missing? When I send an Order Complete email to myself, none of my styles are being recognized. Is there a way to check?

Thank you.


yogakeys

October 18, 2018 at 12:23 am

add_filter( 'gettext', 'mycustom_filter_gettext', 10, 3 ); is part of something else in my functions.php please ignore.


Josh

  • Support Staff

October 18, 2018 at 6:53 am

Hi,

Your code is actually passing the custom CSS to the Receipts and Invoices only. This block:

if ( $messenger != 'html' ) {
 return $variation_path;
}

is basically saying: “If this isn’t an invoice or receipt, move on and just send the regular CSS.”

So in order to send the custom CSS with an email, you’d change that line of code to be:

if ( $messenger != 'email' ) {
 return $variation_path;
}


yogakeys

October 18, 2018 at 3:55 pm

This works, thanks Josh!

Viewing 3 reply threads

The support post ‘Custom CSS for Email templates’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso