I'm developing a complementary plugin for woocommerce
.
I have a sql request that gets all the order and customer info, but i need to get the language from the order.
How can i detect the language was using a customer when he made an order? Is it registered somewhere?
In other CMS
like prestashop
it's stored as id_lang
in orders and customer tables.
Finally solved, both solutions are OK.
With WPML plugin you can get the value in the table postmeta
with the meta_key = wpml_language
Just added a left join in my SQL query:
SELECT O.ID as id_order, O.post_date_gmt as date, M.meta_value as email, M2.meta_value as firstname, M3.meta_value as lastname, M4.meta_value as iso_code
FROM ".$prefix."posts O
LEFT JOIN ".$prefix."postmeta M ON M.post_id = O.ID AND M.meta_key = '_billing_email'
LEFT JOIN ".$prefix."postmeta M2 ON M2.post_id = O.ID AND M2.meta_key = '_billing_first_name'
LEFT JOIN ".$prefix."postmeta M3 ON M3.post_id = O.ID AND M3.meta_key = '_billing_last_name'
LEFT JOIN ".$prefix."postmeta M4 ON M3.post_id = O.ID AND M4.meta_key = 'wpml_language'
WHERE O.post_type = 'shop_order' AND O.post_status = 'wc-completed'