This thread is resolved. Here is a description of the problem and solution.
Problem:
The client reported an issue where the language data disappears after saving an order in WooCommerce with WPML and custom CRM integration. The problem occurs when the
$order->save()
method is executed, leading to the disappearance or defaulting of the 'wpml_language' meta instead of retaining the secondary language.
Solution:
We analyzed the issue and found that the 'wpml_language' value remains set to the correct language (Russian in this case). The apparent issue arises because the system dynamically adjusts the display language on the order edit page based on the user's current view settings, not the original language of the purchase. This behavior is controlled by the function
WCML_Orders::get_order_items_language_to_filter
located in wp-content/plugins/woocommerce-multilingual/inc/class-wcml-orders.php. Here, the language displayed is determined by the user's admin language settings or the default site language if no specific action is triggered for the customer. This ensures that product titles and other details are shown in the appropriate language as per the current view settings.
If this solution does not resolve your issue or seems irrelevant due to updates or specific circumstances, we recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.
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: WCML
Related documentation:
This topic contains 4 replies, has 1 voice.
Last updated by Marcel 5 days, 18 hours ago.
Assisted by: Marcel.
Author | Posts |
---|---|
February 13, 2025 at 1:00 pm #16702148 | |
mykhailoK-8 |
Background of the issue: public function send_order( if ( isset( $response['dataArray'] ) ) { When the $order->save() is done, the language data dissapears. If I comment this row it works. As I understand, WPML somehow interfere when the order is saved by woocommerce. What is the correct way to fix the problem, so wpml language won't be erased. By missing language I mean that wpml_language meta is missing or has default language instead of secondary language. I'm using HPOS so it will be a problem to replace $order->save() with just update_post_meta Symptoms: Questions: |
February 13, 2025 at 1:04 pm #16702292 | |
mykhailoK-8 |
Symptoms: incorrect payment instructions language in email and incorrect language of products in email |
February 18, 2025 at 5:39 pm #16720455 | |
Marcel Supporter
Languages: English (English ) German (Deutsch ) Timezone: Europe/Madrid (GMT+01:00) |
Hi, Thanks for the update! There is still an internal ticket open from your previous case, and we're currently investigating the issue to identify what might be causing it. Best regards, |
February 20, 2025 at 12:44 pm #16729581 | |
mykhailoK-8 |
Previous ticket was marked as resolved so I've opened a new one |
February 20, 2025 at 1:12 pm #16729663 | |
Marcel Supporter
Languages: English (English ) German (Deutsch ) Timezone: Europe/Madrid (GMT+01:00) |
Hi, Yes, that’s fine. I was referring to an internal ticket in our bug tracker system, not the forum case itself. There was additional information from your previous case. However, based on the information we have right now, we can only make an educated guess. It’s possible that $order->save() is being hooked or modified in our code due to a race condition—but this is just speculation at this point. To properly debug this, we need a clear way to reproduce the issue. Could you please provide a Duplicator package of your site along with detailed instructions on how to trigger the order to your CRM to reproduce the issue? Specifically, are there any particular steps involved in creating an order that lead to this behavior? Thank you! Best regards, |
February 25, 2025 at 1:04 pm #16745797 | |
Marcel Supporter
Languages: English (English ) German (Deutsch ) Timezone: Europe/Madrid (GMT+01:00) |
Hi, We’ve debugged the issue, and the order still has a language assigned to it. However, we’re unable to identify where the language is missing. How can we verify if the language is indeed missing? We purchased a product in Russian, and the order table contains the WPML language key, with no data lost. Could it be that this information isn’t making it to your CRM? Looking forward to your insights. Best regards, |
February 25, 2025 at 2:37 pm #16746394 | |
mykhailoK-8 |
I don't know why it doesn't reproduce on any other sites, for example on local or dev version, however it is crucial that this will be live site and this is one of the problem which stops moving it for production. I'll send you a video with the steps hidden link. After complete an order, and go to admin area the list of products is in Ukrainian, however wpml_language is set to ru. Same problem with email, the list of products and payment instruction is in ukrainian. Could you validate the error on azi.ua, using ftp or ssh access? |
February 27, 2025 at 3:58 pm #16757105 | |
Marcel Supporter
Languages: English (English ) German (Deutsch ) Timezone: Europe/Madrid (GMT+01:00) |
Hi, We have looked into the issue, and as far as we can see, the wpml_language value is still set to ru. However, after analyzing the behavior, we believe this is not actually an issue. Since you are viewing the order page in Ukrainian, the system dynamically adjusts the display. This means product titles are shown in the appropriate language based on your view rather than the original purchased values. For reference, you can check the function WCML_Orders::get_order_items_language_to_filter in: Here's the relevant condition: private function get_order_items_language_to_filter( $order ) { if ( $this->is_on_order_edit_page() ) { $language = $this->sitepress->get_user_admin_language( get_current_user_id(), true ); } elseif ( $this->is_order_action_triggered_for_customer() ) { $language = self::getLanguage( $order->get_id() ) ?: $this->sitepress->get_default_language(); } else { $language = $this->sitepress->get_current_language(); } } Since this is the order edit page, the system applies your selected language instead of the stored purchase language. Let us know if you have any further questions! Best Regards, |
February 28, 2025 at 10:48 am #16760285 | |
mykhailoK-8 |
Yes, thanks, however in email I see same strange behaviour, and the order items are still in ukrainian (main lang) instead of russian (secondary kang). The order was made on russian lang. All other details are in russian lang, only order items are in ukrainian |
February 28, 2025 at 11:37 am #16760537 | |
Marcel Supporter
Languages: English (English ) German (Deutsch ) Timezone: Europe/Madrid (GMT+01:00) |
Hi, this behavior appears to be expected:
However, this issue is separate from your original concern about the incorrect order language in your CRM. If you want to have this investigated further, please create a new support ticket with detailed steps to reproduce the problem. Also, consider how you're viewing the email—whether in your inbox or within the WP order backend: - The admin option backend is translated only when necessary. For additional information, please refer to this documentation: Sending Emails with WPML. Best regards, |