Skip Navigation

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

Problem:
Email shortcode that is used for email title is not translated

Solution:
the code used:

add_filter('woocommerce_email_subject_new_order', 'change_admin_email_subject', 1, 2);

function change_admin_email_subject( $subject, $order ) {
global $woocommerce;

$subject = str_replace( "{order_firstname}", $order->billing_first_name, $subject );
$subject = str_replace( "{order_lastname}", $order->billing_last_name, $subject );

return $subject;
}

Just needs to use priority after WCML :
11 for example

add_filter('woocommerce_email_subject_new_order', 'change_admin_email_subject', 11, 2);

and all will be fine.

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 9 replies, has 2 voices.

Last updated by John 7 months ago.

Assigned support staff: Riffaz.

Author Posts
March 14, 2020 at 10:28 pm #5687101

John

When wpml is activated the following code gets disabled.

add_filter('woocommerce_email_subject_new_order', 'change_admin_email_subject', 1, 2);

function change_admin_email_subject( $subject, $order ) {
global $woocommerce;

$subject = str_replace( "{order_firstname}", $order->billing_first_name, $subject );
$subject = str_replace( "{order_lastname}", $order->billing_last_name, $subject );

return $subject;
}

March 17, 2020 at 2:42 pm #5702557

John

Hey you forgot to put url 🙂
Waiting for your response

March 18, 2020 at 7:37 am #5707935

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

Sorry, here is the link hidden link

Regards,

March 27, 2020 at 3:37 am #5775255

John

Password doesn't work ... :(, but it will be more faster...if you simple add the the code above in functions.php
Then go to woocommerce new order email and put this as subject:
New order from {order_firstname} {order_lastname} website ({order_number}) - {order_date}
If wpml is activated you will see the order_firstname won't parse but if it is deactivated then this will work.
Thanks waiting for your answer regarding this issue.

March 29, 2020 at 7:07 am #5787551

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

I added the code to functions.php
changed email subject in woocommerce new order email
and I am getting same email subject with and without WPML. screenshot attached.
You can check your self by changing the email to yours in WooCommerce > Settings > emails > new order > Manage > recipient

hidden link
username: wpml
password: otgs

So it works in a fresh installation as you expect.

please try,
1)
disable all the plugins except WPML and check

2)
disable all the browser, server and plugin caches and try

Let me know the results, please.

Regards,
Riffaz.

March 31, 2020 at 12:06 am #5799765

John

Hello issue still persists, you have forgot to active wpml woocommerce that is the reason you haven't had that error.
hidden link

March 31, 2020 at 1:25 pm #5804385

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

I see the issue now. thanks.

I escalated this to our developers. please be patient till we get back to you again.

Regards,

April 2, 2020 at 2:03 pm #5823483

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

Our developers finished checking.

We don't have a workaround at this time.

Also on another note - if you are using that hook, you won't probably get a translation of that string ever, so we suggest to change the string in the settings or template for the email instead.

As it is a complex work and it should go to the core WCML we will need more time to find a workaround and implement it in the core WCML.

We will update you again once we have a solution.

Regards,

April 22, 2020 at 11:09 am #5967593

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

Our developers found the solution for this.

needs to use priority after WCML :
11 for example

add_filter('woocommerce_email_subject_new_order', 'change_admin_email_subject', 11, 2);

and all will be fine.
screenshot attached.

Please check.
This will fix your issue.

Regards,

April 25, 2020 at 6:26 pm #5993655

John

My issue is resolved now. Thank you!