Support

Home Forums Event Espresso Premium Custom CSS on invoice/receipt

Custom CSS on invoice/receipt

Posted: March 17, 2017 at 4:46 am


Elnino

March 17, 2017 at 4:46 am

Hi,

I’d like to customize the CSS for the invoice/receipt but can’t figure out where to change that. I’ve copy the file ‘html_main_default.css’ in ‘mytheme/css/ee-messages’ folder so that I can override it. Now how to tell EE to use this?

I’ve added the following function:

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;
	}

	//for this example we'll just filter the wpeditor for this variation
	if ( $type != 'wpeditor' ) {
		return $variation_path;
	}

	$new_url = get_stylesheet_directory_uri() . '/ee-messages/html_main_default.css';
	return $new_url;
}
add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', 'ee_modify_html_variation', 10, 8 );

that I’ve found on your github but it’s probably not the right way to do it.

Could you please help? All the posts related to this topic are two years old and no longer apply to the current EE4 version.

Thanks.


Josh

  • Support Staff

March 17, 2017 at 3:49 pm

The code above works, but you’ll need to modify things a bit for your scenario.

The part that needs changing is this:

if ( $type != 'wpeditor' ) {
 return $variation_path;
}

That’s basically telling WordPress to not load your CSS unless you’re viewing a preview of the receipt in the receipt editor. Since you want to load your CSS when the actual receipt loads, so you can remove that entire conditional.


Elnino

March 19, 2017 at 3:34 pm

Hi Josh,

Thanks for your reply. Removal of this condition actually triggers the use of the CSS but only this one. Meaning on the Order confirmation page, I only have this stylesheet that loads on the page which results in a not-so-good-looking page!

How would you load the default ones as well like html_base_default.css or html_print_default.css within this function?

Thanks for your help.


Josh

  • Support Staff

March 20, 2017 at 10:26 am

I’d copy the original styles into a custom stylesheet. Then make the customizations to the custom stylesheet.


Elnino

March 22, 2017 at 2:58 am

All right, thanks, that’s what I’ve done then. I thought there was an easier way of customizing just the extra stylesheet.

The support post ‘Custom CSS on invoice/receipt’ 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