Fix language of WooCommerce ‘Thank You’ redirect URL for qTranslate

I struggled a bit with wrong translation of the thank you page. For translation I used qTranslate and IM8 qTranslate WooCommerce

Looking at the Network tab in Chrome I saw the 301 redirect, but it took a while to figure out that a missing slash (/) was doing that wrong redirect.

Screen Shot 2014-10-19 at 9.37.36 AM Screen Shot 2014-10-19 at 9.37.49 AM
I added the following to functions.php to fix the issue:

/**
 * Add slash before question mark due 301 redirect that prevents the lang query to pass
 *
 **/
function atc_payment_successful_result( $result ) {

 $result['redirect'] = str_replace( '?lang', '/?lang', $result['redirect'] );
 return $result;
}
add_filter( 'im8qtranslatewoocommerce_payment_redirect_filters', '__return_empty_array' ); // Prevent plugin filter
add_filter( 'woocommerce_payment_successful_result', 'atc_payment_successful_result' );

 

Advertisements

Author: Michal Zuber

Full stack developer, biker and rollerblader. Owner and developer at https://nevilleweb.sk/ Co-founded http://neville.sk/ Blog at https://michalzuber.wordpress.com/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s