Skip Navigation

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 4 replies, has 1 voice.

Last updated by Marcel 9 hours, 8 minutes ago.

Assisted by: Marcel.

Author Posts
February 13, 2025 at 1:00 pm #16702148

mykhailoK-8

Background of the issue:
Hi! I had a problem on site https://wpml.org/forums/topic/instructions-to-payment-method-sent-in-incorrect-language/, this ticket was marked as resolved, but I have found the bug. I'm using wpml + woocommerce and custom integration with crm. It sends order on order creation
add_action( 'woocommerce_checkout_update_order_meta', function ( $order_id ) {
do_action( 'onebox_send_order', $order_id );
}, 9999 );
add_action( 'onebox_send_order', [ $this, 'send_order' ] );

public function send_order(
int $order_id, array $args = [
'customfields' => []
]
): void {
//handle data
$response = $this->send_request( 'order/set/', [ $order_data ], $order );

if ( isset( $response['dataArray'] ) ) {
$order->update_meta_data( 'onebox_id', $response['dataArray'][0] );
$order->save();
}
}

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,
Marcel

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,
Marcel

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,
Marcel

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:
wp-content/plugins/woocommerce-multilingual/inc/class-wcml-orders.php

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,
Marcel

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

2025-02-28 12_47_15-Ваш заказ на сайте Azi оформлен! - marchak2001@gmail.com - Gmail.png
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:

product titles are shown in the appropriate language based on your view rather than the original purchased values.

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.
- To enforce translation for admin options in the backend, use the following hook: wpml_st_force_translate_admin_options.
For additional information, please refer to this document.

For additional information, please refer to this documentation: Sending Emails with WPML.

Best regards,
Marcel