PHP WordPress WooCommerce
WooCommerce - Storing WPML Language With Orders
398 days agoThis code allows you to store the language with the WooCommerce orders.
<?php
add_action('woocommerce_checkout_update_order_meta', 'save_language_to_order', 10, 2);
function save_language_to_order($order_id, $posted)
{
$lang = apply_filters('wpml_current_language', null);
if ($lang) {
$lang = "en";
}
update_post_meta($order_id, '_order_language', $lang);
}
// This can be retrieved with
$order_lang = get_post_meta($order_id, '_order_language');
