This thread is resolved. Here is a description of the problem and solution.
Problem:
You are trying to capture the language of the customer in WooCommerce orders using WPML, but the meta key 'wpml_language' does not work.
Solution:
The correct meta key to use is 'wpml_languages', which is stored in the 'wp_wc_orders_meta' table. This key reflects the language of the order based on the active user language at the time the order is created on the frontend. Here is how you can retrieve the language from the 'wpml_languages' meta key:
$order = wc_get_order( $order_id ); // Retrieve the 'wpml_languages' meta value $wpml_languages = $order->get_meta( 'wpml_languages' ); // If the data is serialized, unserialize it if ( !empty( $wpml_languages ) ) { $languages = unserialize( $wpml_languages ); // Assuming the first entry is the primary language of the order $order_language = isset( $languages[0] ) ? $languages[0] : null; // Output or use the $order_language echo 'Order language: ' . $order_language; }
If this solution does not resolve your issue, or if it seems outdated or irrelevant to your specific case, we highly 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 further assistance is needed, please open a new support ticket at WPML support forum.
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 1 reply, has 0 voices.
Last updated by 1 week, 2 days ago.
Assisted by: Andreas W..