Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're experiencing an issue where the Thankyou page after making an order is not translated into the selected language,
Solution:
First, ensure that your custom code is multilingual-ready. You need to wrap your strings with

gettext()

calls. You can find guidance on how to do this in the WordPress Codex on I18n for WordPress Developers.
After adjusting your code, you can translate the strings using WPML's String Translation by navigating to WPML -> String Translation. For more detailed instructions on translating your theme, visit Translating the Theme You Created.
If you require assistance with making your custom code multilingual-ready, we suggest hiring a certified contractor from WPML Contractors.
As an example, here's how you might adjust a string in your code:

$title = sprintf( __("Merci %s pour votre commande! :)", 'your-text-domain'), esc_html( $order->get_billing_first_name() ) );

Please be aware that our support does not extend to custom coding. If you need specialized help, consider reaching out to our certified contractors.

It's important to note that the solution provided might not apply to your situation if it's outdated or not relevant to your case. If the issue persists, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Should you need further assistance, please do not hesitate to open a new support ticket. For support in English, you can reach us at WPML Support Forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 5 replies, has 2 voices.

Last updated by Marcel 1 year, 1 month ago.

Assisted by: Marcel.

Author Posts
March 7, 2024 at 2:00 pm #15384725

elmehdiZ

When a user make an order with the second language, the Thankyou page showing is not translated, how do I translate it?

hidden link

You can try ordering this product and the Thankyou page will still be showing in French instead of Arabic which is the language I Translated to

March 7, 2024 at 2:12 pm #15384753

Marcel
WPML Supporter since 02/2019

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Hi,

how did you create the "Thank You" Page? Did you use custom code or functionality from your theme, or did you use Elementor for it?

Please let me know.

Best Regards
Marcel

March 8, 2024 at 12:24 pm #15389058

elmehdiZ

Défautlt woocomerce page but I edited it using snippets plugin, see screenshot below

Screenshot_2024-03-08-13-22-52-123_com.opera.browser.png
March 8, 2024 at 4:13 pm #15390180

Marcel
WPML Supporter since 02/2019

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Thanks for the info. Your code is not multilingual-ready. First, you need to adjust your code by wrapping your strings into getText() calls, as described here: https://codex.wordpress.org/I18n_for_WordPress_Developers. Then, you can translate them as regular strings on WPML -> String Translation.

Additional info you can find here: https://wpml.org/documentation/support/translating-the-theme-you-created/.

If you need further help making your custom code multilingual-ready, I recommend contacting a certified contractor. You can find them here: https://wpml.org/contractors/.

Best Regards
Marcel

March 9, 2024 at 2:40 pm #15391548

elmehdiZ

I've sent you the whole snippet of the Thankyou page.
can you please adjust my code by wrapping the strings into getText() calls for me please?

I would be very very appreciated🙏❤️

add_filter('woocommerce_thankyou_order_received_text', 'woo_change_order_received_text', 10, 2 );

function woo_change_order_received_text( $str, $order ) {

$new_str = 'Nous vous appellerons Bientôt pour la confirmation Finale de Votre Commande.';

return $new_str;

}

add_filter( 'the_title', 'woo_personalize_order_received_title', 10, 2 );

function woo_personalize_order_received_title( $title, $id ) {

if ( is_order_received_page() && get_the_ID() === $id ) {

global $wp;

// Get the order. Line 9 to 17 are present in order_received() in includes/shortcodes/class-wc-shortcode-checkout.php file

$order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $wp->query_vars['order-received'] ) );

$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) );

if ( $order_id > 0 ) {

$order = wc_get_order( $order_id );

if ( $order->get_order_key() != $order_key ) {

$order = false;

}

}

if ( isset ( $order ) ) {

//$title = sprintf( "You are awesome, %s!", esc_html( $order->billing_first_name ) ); // use this for WooCommerce versions older then v2.7

$title = sprintf( "Merci %s pour votre commande! :)", esc_html( $order->get_billing_first_name() ) );

}

}

return $title;}

March 11, 2024 at 9:32 am #15393893

Marcel
WPML Supporter since 02/2019

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Hi there!

Please note that our support doesn't include custom coding. For specialized assistance, consider reaching out to our certified contractors.

As a tip, here's a code snippet you might find useful:

$title = sprintf( __("Merci %s pour votre commande! :)", 'your-text-domain'), esc_html( $order->get_billing_first_name() ) );

Cheers,
Marcel