我想通过使用WordPress WPDB功能显示每个产品/ ID的退款数量。但是我做不到。有人可以帮我吗?
这是我尝试过的一些代码,但是这些都不起作用:-
SELECT order_id FROM wp_woocommerce_order_itemmeta woim
LEFT JOIN wp_woocommerce_order_items oi
ON woim.order_item_id = oi.order_item_id
WHERE meta_key = '_product_id' AND meta_value = 5734
GROUP BY order_id
SELECT * FROM wp_woocommerce_order_itemmeta woim JOIN wp_woocommerce_order_items oi JOIN wp_posts wp_pos ON woim.order_item_id = oi.order_item_id WHERE meta_key = '_product_id' AND meta_value = 5734 and wp_pos.post_status='wc-refunded'
SELECT * FROM `wp_woocommerce_order_itemmeta` WHERE `meta_key`='_product_id' AND `meta_value`='5734'
SELECT COUNT(*) FROM `wp_posts` WHERE `post_type`='shop_order' AND `post_status`='wc-refunded'
SELECT * FROM wp_woocommerce_order_itemmeta woim
JOIN wp_woocommerce_order_items oi
JOIN wp_posts wp_po
ON woim.order_item_id = oi.order_item_id
WHERE meta_key = '_product_id' AND meta_value = 5734 and wp_po.post_type='shop_order' AND wp_po.post_status='wc-refunded'