Skip Navigation

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

Problem:
You need to translate email strings into Estonian using the Kadence Email Customizer plugin while keeping placeholders like {invoice_pay_link} functional.
Solution:
We recommend adding specific code to the functions.php file of your child theme to handle the translation and functionality of placeholders. Here are the steps:

  1. Add the following code to handle the translation and dynamic replacement of the {invoice_pay_link} placeholder:
    add_filter('kadence_woomail_order_body_text', function($body_text, $order, $sent_to_admin, $plain_text, $email){<br />    if (class_exists('WCML_Orders')) {<br />        $key = $email->id;<br />        $btn_switch = Kadence_Woomail_Customizer::opt($key . '_btn_switch');<br />        $pay_link = "";<br />        if ($order->get_checkout_payment_url()) {<br />            if (true == $btn_switch) {<br />                $pay_link = '<p class="btn-container"><a class="btn" href="' . esc_url($order->get_checkout_payment_url()) . '">' . esc_html__('Pay for this order', 'kadence-woocommerce-email-designer') . '</a></p>';<br />            } else {<br />                $pay_link = '<a href="' . esc_url($order->get_checkout_payment_url()) . '">' . esc_html__('Pay for this order', 'kadence-woocommerce-email-designer') . '</a>';<br />            }<br />        }<br />        $body_text = str_replace('{invoice_pay_link}', $pay_link, $body_text);<br />        $site_title = get_bloginfo('name');<br />        $body_text = str_replace('{site_title}', esc_html($site_title), $body_text);<br />        $order_language = $order->get_meta('wpml_language');<br />        $body_text = apply_filters('wpml_translate_single_string', $body_text, 'admin_texts_kt_woomail', $key.'_body', $order_language);<br />    }<br />    return $body_text;<br />}, 20, 5);

If this solution does not resolve your issue or seems outdated, please check the related known issues and confirm that you have installed the latest versions of themes and plugins. If the problem persists, we highly recommend opening a new support ticket with us for further assistance.

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.

Tagged: 

This topic contains 3 replies, has 0 voices.

Last updated by Bruno Kos 5 days ago.

Assisted by: Bruno Kos.

Author Posts
March 13, 2025 at 9:46 am #16810790

pavelZ-3

Background of the issue:
I am using the Kadence Email Customizer plugin to customize emails on my site under development. I need to translate some strings in these emails into Estonian. For example, the line 'An order has been created for you on {site_title}. {invoice_pay_link}' should be translated, where {site_title} is replaced by the site name and {invoice_pay_link} is replaced by a payment link with the caption 'Pay for this order'. I've written about this problem before (https://wpml.org/forums/topic/proble-with-kadence-email-customizer/), but there we solved it without translating texts via WPML, since the language on the site is the same.

Symptoms:
I need to translate email strings into Estonian using the Kadence Email Customizer plugin.

Questions:
How can I translate email strings into Estonian using WPML with the Kadence Email Customizer plugin?
At the same time, keeping tags, such as {invoice_pay_link} and other similar ones, functional. Now they are sent to the e-mail as a string. Here is an example:
"Teie jaoks on loodud tellimus saidil {site_title}. {invoice_pay_link}"
This is literally what I get in the email.

March 14, 2025 at 10:03 am #16815711

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

Hi,

Can you add this into the functions.php of your child theme and try then?

add_filter('kadence_woomail_order_body_text', function($body_text, $order, $sent_to_admin, $plain_text, $email){
	if ( class_exists( 'WCML_Orders' ) ) {
	$key = $email->id;
	$setting_key = $key . '_body';
	$btn_switch = Kadence_Woomail_Customizer::opt( $key . '_btn_switch' );
	$pay_link = "";
	if ( $order->get_checkout_payment_url() ) {
	if ( true == $btn_switch ) {
					$pay_link = '<p class="btn-container"><a class="btn" href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay for this order', 'kadence-woocommerce-email-designer' ) . '</a></p>';
				} else {
					$pay_link = '<a href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay for this order', 'kadence-woocommerce-email-designer' ) . '</a>';
				}
	}
	$body_text = str_replace( '{invoice_pay_link}', $pay_link, $body_text );
	$body_text = apply_filters( 'wpml_translate_single_string', $body_text, 'admin_texts_kt_woomail', $name, $order_language );
	}
	return $body_text;
},20,5);

Let me know if this works.

I am not sure if it covers the {site_title} also, so for this, can you try this as well? So after you check and confirm whether the above filter works, try this one:

add_filter('kadence_woomail_order_body_text', function($body_text, $order, $sent_to_admin, $plain_text, $email) {
    
    // Check if WCML is active for translation support.
    if (class_exists('WCML_Orders')) {
        
        // Get necessary variables
        $key = $email->id;
        $btn_switch = Kadence_Woomail_Customizer::opt($key . '_btn_switch');

        // Handle {invoice_pay_link}
        $pay_link = "";
        if ($order->get_checkout_payment_url()) {
            if (true == $btn_switch) {
                $pay_link = '<p class="btn-container"><a class="btn" href="' . esc_url($order->get_checkout_payment_url()) . '">' . esc_html__('Pay for this order', 'kadence-woocommerce-email-designer') . '</a></p>';
            } else {
                $pay_link = '<a href="' . esc_url($order->get_checkout_payment_url()) . '">' . esc_html__('Pay for this order', 'kadence-woocommerce-email-designer') . '</a>';
            }
        }

        // Replace the placeholders {invoice_pay_link} and {site_title}
        $body_text = str_replace('{invoice_pay_link}', $pay_link, $body_text);
        $site_title = get_bloginfo('name');
        $body_text = str_replace('{site_title}', esc_html($site_title), $body_text);

        // Translate the body text via WPML
        $order_language = $order->get_meta('wpml_language');
        $body_text = apply_filters('wpml_translate_single_string', $body_text, 'admin_texts_kt_woomail', $key.'_body', $order_language);
    }

    return $body_text;

}, 20, 5);
March 20, 2025 at 8:16 am #16838484

pavelZ-3

Thank you very much, it seems to be working as it should

March 24, 2025 at 2:09 pm #16852542
pavelZ-3

Hello, now a slightly different problem, still related to Kadence and Woocommerce Subscriptions.
Some emails are not fully translated.

I have two languages on my site: Estonian and English. Estonian is set as default language. The lines in the emails are all translated.
But this is what I get if I subscribe in Estonian and try to renew it.
Email header (i.e. subject): “Your Luxador renewal order receipt from märts 24, 2025”

And in the e-mail itself, the English text at the beginning: “Your subscription renewal order has been received and is now being processed. Your order details are shown below for your reference:”

All other content is translated into Estonian correctly, except for “Credit card / debit card” in the payment method and the word “every” in the payment period.

Translated with DeepL.com (free version)

New threads created by Bruno Kos and linked to this one are listed below:

https://wpml.org/forums/topic/split-problem-with-kadence-email-customizer/

March 25, 2025 at 9:58 am #16855948

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

Given that this is another issue, let me close it here and continue on a split ticket.