title: Language redirection on custom thankyou page using Polylang in Woocommerce
body: <p>In Woocommerce, I am working on my custom thank you page when you finish your order. Everything is done but what I need is to redirect english orders to english language Thank you page and major language to the major Thank you page.</p>
  
  <p>I ve added this code to <code>functions.php</code> but its only redirecting to the url which is set. How could I set 2 differend urls for 2 different languages?</p>
  
  <p>Main language: Slovak <br>
  2nd language: English <br>
  Plugin used for translations: Polylang</p>
  
  <p>My code:</p>
  
  <pre><code>add_action( 'template_redirect', 'woo_custom_redirect_after_purchase' );
  function woo_custom_redirect_after_purchase() {
      global $wp;
  
      if ( is_checkout() &amp;&amp; !empty( $wp-&gt;query_vars['order-received'] ) )
      {
          wp_redirect( '/dakujeme-za-objednavku/' );
          exit;
      }
  }
  </code></pre>
  
  <p>And when I use this code it redirects only to url which is not set to en_US (to /vi/cam-on not to thank you when the language is english</p>
  
  <pre><code>add_action( 'woocommerce_thankyou', 'bbloomer_redirectcustom');
  function bbloomer_redirectcustom( $order_id ){
  
      $order = new WC_Order( $order_id );
  
      if( get_locale() == 'en_US'){
          $url = get_site_url().'/thank-you';        
      }else{
          $url = get_site_url().'/vi/cam-on';
      }
      if ( $order-&gt;status != 'failed' ) {
          wp_redirect($url);
          exit;
      }
  }
  </code></pre>