Background of the issue:
I am trying to ensure that Woocommerce emails are sent in the correct language based on the wpml_language field from the order meta. For example, when I complete an order, a shipment tracking link gets sent by Woocommerce.
Symptoms:
Occasionally, the emails get sent in an incorrect language. I encountered it twice within the last 30 orders. For example, the last customer that made an order had the email sent in 'en', even though in 'wp_wc_orders_meta' table I can see that the 'wpml_language' field was set to 'lt' for that particular order.
Questions:
Why are Woocommerce emails sometimes sent in the incorrect language?
How can I ensure emails are sent in the language specified in the wpml_language field?
If you do not have any custom code, then if the order is generated by the user int he front end, it will send the email with the language user was in the time of checkout.
If you use the WordPress Dashboard > Woocommerce > orders send email buttons there, then the email will take the language of the dashboard that you use.
You can change the dashboard language by going to Users > Profile.
1. The email is not a custom email. It is an email that is sent by Woocommerce automatically when the order status is changed to "Completed".
2. The admin dashboard language does necessarily match the order language, but I think it is unreasonable to expect a shop manager to switch languages based on the language that the customer used during checkout.
3. As I said the issue appears to be sporadic. Sometimes the content is sent in the correct language, sometimes it's not. Interestringly, the subject is always translated correctly.
Could you please provide pointers on how to debug this further?
my name is Marcel and I will take over your ticket.
Without clear steps to reproduce the issue, troubleshooting will be challenging. Ideally, please start by setting up a staging environment. Disable all unused plugins, switch to a default theme like Storefront, and place a few test orders. If we can replicate the issue there, we can then examine a duplicator copy for local debugging.