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.