当前位置: 首页 > 知识库问答 >
问题:

查询挂起的订单

华星文
2023-03-14

我想要一个mysql查询,以获得我所有的订单挂起状态。有人知道怎么做。

我在WoodPress网站上使用woocommerce,但我只希望mysql查询不带wordpress函数。

谢啦

共有3个答案

彭炳
2023-03-14

我花了一个周末的时间在查询上,结果如下:

select
nombre,apellido,direccion,direccion2,codigo,poblacion,provincia,correo, telefono
from (
    select
(select meta_value from wp_postmeta pm1 where p.ID = pm1.post_id and meta_key = "_billing_first_name") as nombre,
(select meta_value from wp_postmeta pm1 where p.ID = pm1.post_id and meta_key = "_billing_last_name") as apellido,
(select meta_value from wp_postmeta pm1 where p.ID = pm1.post_id and meta_key = "_billing_address_1") as direccion,
(select meta_value from wp_postmeta pm1 where p.ID = pm1.post_id and meta_key = "_billing_address_2") as direccion2,
(select meta_value from wp_postmeta pm1 where p.ID = pm1.post_id and meta_key = "_customer_user") as codigo,
(select meta_value from wp_postmeta pm1 where p.ID = pm1.post_id and meta_key = "_billing_city") as poblacion,
(select meta_value from wp_postmeta pm1 where p.ID = pm1.post_id and meta_key = "_billing_state") as provincia,
(select meta_value from wp_postmeta pm1 where p.ID = pm1.post_id and meta_key = "_billing_email") as correo,
(select meta_value from wp_postmeta pm1 where p.ID = pm1.post_id and meta_key = "_billing_phone") as telefono

from
wp_posts AS p
    WHERE post_type = "shop_order" and id in (SELECT object_id
FROM wp_posts 
LEFT OUTER JOIN wp_term_relationships ON wp_posts.ID=wp_term_relationships.object_id 
WHERE post_type = "shop_order" 
AND term_taxonomy_id=9
)

) A
谢烨烨
2023-03-14

好吧,伙计们,这是一个奇怪的问题,但我通过简单地使用自定义查询来修复它。以某种方式添加“post\u status”=

所以我所做的是使用自定义查询并将挂起修改为wc挂起

陈寒
2023-03-14

你真的应该使用内置的数据库函数,因为这符合Wordpress编码标准。

您可以查看WC_查询类。

或者你可以尝试下面这样的方法。您需要将元密钥更改为他们正在使用的任何元密钥。此外,元值可能不同于挂起,post_type可能不同于shop_order。

    $pending = new WP_Query(
        array(
            'post_type' => array('shop_order'),
            'meta_query' => array(
                array(
                    'key'   => 'status',
                    'value' => array('pending'),
                )
            )
        )
    );

下面是一个关于如何对WooCommerce订单进行元查询的示例。

 类似资料:
  • 我从sqlite数据库中获取一些数据,在添加order by子句之前,我的查询工作正常 我的查询结构如下 选择*从测试,其中测试像'%test%'COLLATE NOCASE LIMIT 100 OFFSET 0 这运行得很好,我在数据库的前100行获得了包含单词test的所有记录,但是当我以这种方式添加ORDER BY子句时 选择*从TESTI,其中TESTO喜欢'%test%'COLLATE

  • 说明 微信支付查询订单SDK。 官方文档:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_2 类 请求参数类 请求参数 类名:\Yurun\PaySDK\Weixin\OrderQuery\Request 属性 名称 类型 说明 $_apiMethod string 接口名称 $transaction_id string

  • 说明 支付宝境外到店支付-订单查询 官方文档:https://global.alipay.com/service/external_QR_Code/28 类 请求参数类 请求参数 类名:\Yurun\PaySDK\AlipayCrossBorder\InStore\Query\Request 属性 名称 类型 说明 $service string 接口名称 $partner_trans_id st

  • 请求地址 https://api.es.xiaojukeji.com/river/Approval/getOrder 返回数据格式 JSON 请求类型 GET 请求参数 参数名称 数据类型 必选 说明 client_id string yes 申请应用时分配的AppKey access_token string yes 授权后的access token timestamp string yes 当

  • 3.2 查询订单 3.2.1 描述 通过调用该接口为指定订单号的订单明细 3.2.2 请求地址 地址:https://api.bokecs.com/recharge/order/get?orderNo=15 3.2.3 请求方式 GET 3.2.4 请求参数 1) 请求入参 元素名称 是否必须 元素描述 orderNo 是 订单号 2) 请求出参 { "code": "", "message":

  • 问题内容: 我在编写sql从表中获取可用空间时遇到问题。 我的表结构如下。 一个房间可以链接到许多预订,一个预订可以包含很多房间 我已经尝试过了,但是如果一个房间在两个不同的日期链接到两个不同的预订会比较麻烦,那么只有第一个预订ID才能进行比较 有人可以帮我编写SQL,以便在入住和退房之间获得可用的房间。 问题答案: 如果您想要的只是在所需日期的整个范围内可用的房间列表,那么类似以下的方法可能会起