获取 Woocommerce 客户订单语言 [英] Get Woocommerce customer order language

查看:54
本文介绍了获取 Woocommerce 客户订单语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 woocommerce 开发一个补充插件.我有一个获取所有订单和客户信息的 sql 请求,但我需要从订单中获取语言.

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?

在其他 CMS 中,例如 prestashop,它在订单和客户表中存储为 id_lang.

In other CMS like prestashop it's stored as id_lang in orders and customer tables.

推荐答案

终于解决了,两个方案都OK.

Finally solved, both solutions are OK.

使用 WPML 插件,您可以使用 meta_key = wpml_language

With WPML plugin you can get the value in the table postmeta with the meta_key = wpml_language

刚刚在我的 SQL 查询中添加了一个左连接:

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'

这篇关于获取 Woocommerce 客户订单语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆