sql 在WooCommerce订阅中选择有效订阅用户

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 在WooCommerce订阅中选择有效订阅用户相关的知识,希望对你有一定的参考价值。

select
    p.ID as order_id,
    p.post_date,
    max( CASE WHEN pm.meta_key = '_billing_email' and p.ID = pm.post_id THEN pm.meta_value END ) as billing_email,
    max( CASE WHEN pm.meta_key = '_billing_first_name' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_first_name,
    max( CASE WHEN pm.meta_key = '_billing_last_name' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_last_name,
    max( CASE WHEN pm.meta_key = '_order_total' and p.ID = pm.post_id THEN pm.meta_value END ) as order_total,
    max( CASE WHEN pm.meta_key = '_payment_method' and p.ID = pm.post_id THEN pm.meta_value END ) as payment_method,
    max( CASE WHEN pm.meta_key = '_order_tax' and p.ID = pm.post_id THEN pm.meta_value END ) as order_tax,
    max( CASE WHEN pm.meta_key = '_paid_date' and p.ID = pm.post_id THEN pm.meta_value END ) as paid_date,
    ( select group_concat( order_item_name separator '|' ) from wp_woocommerce_order_items where order_id = p.ID ) as order_items
from
    wp_posts as p,
    wp_postmeta as pm
where
    post_type = 'shop_subscription' and
    p.ID = pm.post_id and
    post_date BETWEEN '2012-01-01' AND '2016-08-01'
    and post_status = 'wc-active'
group by
    p.ID

以上是关于sql 在WooCommerce订阅中选择有效订阅用户的主要内容,如果未能解决你的问题,请参考以下文章

从逗号分隔的订单ID中获取有效的WooCommerce订阅

更改现有定期付款的 woocommerce 订阅率

从 Woocommerce 订阅价格中隐藏“免费试用”文本

如何在 Woocommerce 订阅中设置下一个付款日期?

在 Woocommerce 变量订阅中添加 select2 javascript 和 css

Woocommerce 订阅 - 在订阅 ID 旁边添加产品名称