Support

Home Forums Event Espresso Premium Load dedicated JS file on Invoice and Receipt pages

Load dedicated JS file on Invoice and Receipt pages

Posted: April 9, 2017 at 4:06 am

Viewing 4 reply threads


Elnino

April 9, 2017 at 4:06 am

Hi Josh,

You closed this topic: https://eventespresso.com/topic/change-the-way-promotions-are-being-displayed-on-the-checkout-page/ before I had the chance to answer.

The option you gave me is all right for regular pages managed by WordPress core. What I want is how to load a JS script for the Receipt/Invoice page which is very specific to EE and not available in the WP admin. The URI of those pages are something like:

/?ee=msg_url_trigger&snd_msgr=html&gen_msgr=html&message_type=receipt&context=purchaser&token=1-80f3d7306685b6b9ddbf9e2f44980de9&GRP_ID=13&id=66

And the regular theme/js/scripts.js file is not loaded for those two particular EE pages. I remind you I used your solution here to load a specific CSS on those pages. Is there a way to do the same for JS file?


Josh

  • Support Staff

April 10, 2017 at 9:27 am

Hey El Nino the forum software actually automatically closes topics after 14 days. I did not close your topic.

You can use the
AHEE__EE_Html_Messenger_main_wrapper_template_head
action hook to load your custom JavaScript file to the <head> section of the Invoice and Receipts. Or you can use the
AHEE__EE_Html_Messenger_main_wrapper_template_footer
action hoot to load your custom JavaScript file just before the closing
</html> tag of the Invoice and Receipts.


Elnino

April 11, 2017 at 4:13 am

Hi Josh,

Sorry for thinking you closed the topic. Maybe you should give the system a bit more time (like 4 weeks or 2 months) before actually closing topics?

I’ve added this code in my theme function_ee.php:

add_action( 'AHEE__EE_Html_Messenger_main_wrapper_template_footer', function( $message_type, $subject, $from, $main_body ) {
	if ( ! $message_type instanceof EE_Receipt_message_type ) {
		return;
	} else {
		$new_url = get_stylesheet_directory_uri() . '/js/scripts.js';
		 wp_enqueue_script($new_url);

	}
}, 10, 4 );

However it doesn’t seem to work, the file is not loaded on the receipt page. Could you please tell me what I should add exactly in my function.php to make this hook work?

Thanks a lot.


Tony

  • Support Staff

April 11, 2017 at 4:27 am

Maybe you should give the system a bit more time (like 4 weeks or 2 months) before actually closing topics?

Just to clarify, its 14 days of inactivity, so if no reply is made within 14 days the topic automatically closes, each reply resets the clock.

For the majority of users 14 days is more than enough time to reply, we (support staff) usually reply within 48 hours (often much quicker) so the majority of inactivity is waiting for the users reply.

Anyway, back to your issue 🙂

Could you please tell me what I should add exactly in my function.php to make this hook work?

You need to echo your script not enqueue it:

echo '<script type="text/javascript" src="' . $new_file .'" ></script>;


Elnino

April 11, 2017 at 2:39 pm

Perfect, that works great! Thanks!

Viewing 4 reply threads

The support post ‘Load dedicated JS file on Invoice and Receipt pages’ 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