Support

Home Forums Event Espresso Premium Change locale in AHEE_ thank_you_page transaction_details_template_ after_headin

Change locale in AHEE_ thank_you_page transaction_details_template_ after_headin

Posted: September 25, 2018 at 12:01 pm

Viewing 3 reply threads


Christophe Legrand

September 25, 2018 at 12:01 pm

Hi, I’m trying set the locale on checkout and thank-you page. I managed to get everything working properly, except the transaction details and payment details on the thank you page are not translated correctly. Probably because this content is loaded over AJAX. I’m trying the code below, but the content is still loaded in the main site language, which is nl_NL. It’s very strange cause when I var_dump( get_locale() ), I do get en_US as return.

add_action( 'AHEE__thank_you_page_transaction_details_template__after_heading', function() {

	add_filter( 'locale', function() {
		return 'en_US';
	}, 999 );

} );

Also when trying the following code on a different (static) page, the content is displayed in the correct language (en_US). This shows the problem lies within the AJAX request.

_filter( 'locale', function() {
	return 'nl_NL';
}, 90 );

echo EEH_Template::locate_template( THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', array(), true, true );

Any ideas?

Kind regards

  • This topic was modified 6 years ago by Seth Shoultes. Reason: Shortening title


Tony

  • Support Staff

September 26, 2018 at 4:56 am

Hi there,

Ajax requests are considered to be admin requests so using var_dump( get_locale() ) on the front end, is not and admin request and may return something different to doing the same on an ajax request.

What are you using to set up multiple languages on the site?


Christophe Legrand

September 26, 2018 at 8:45 am

Hi Tony,

I’m using WPML 🙂


Tony

  • Support Staff

September 26, 2018 at 11:53 am

Then you can try the snippet posted here:

https://wpml.org/forums/topic/ajax-call-locale-bug-fix/

Ultimately this is an issue with how translations are handled by WP and WPML on Ajax requests so the above may not actually fix the problem.

Viewing 3 reply threads

The support post ‘Change locale in AHEE_ thank_you_page transaction_details_template_ after_headin’ 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