我有一个自定义数量_bv_qty
,与某个订单项元中的某些_qty
的{{1}}不同。
我尝试通过过滤器更改报告查询,但是它更改了所有其他没有order item
的商品的数量字段。
_bv_qty
我需要选择性加入才能替换几种产品:
SELECT SUM(order_item_meta__qty.meta_value) as order_item_count
FROM wp_posts AS posts
INNER JOIN wp_woocommerce_order_items AS order_items ON posts.ID = order_items.order_id
INNER JOIN wp_woocommerce_order_itemmeta AS order_item_meta__qty
ON (order_items.order_item_id = order_item_meta__qty.order_item_id) AND
(order_item_meta__qty.meta_key = '_qty')
INNER JOIN wp_woocommerce_order_itemmeta AS order_item_meta__product_id_array
ON order_items.order_item_id = order_item_meta__product_id_array.order_item_id
WHERE posts.post_type IN ('shop_order', 'shop_order_refund')
AND posts.post_status IN ('wc-completed', 'wc-processing', 'wc-on-hold', 'wc-refunded')
AND posts.post_date >= '2019-07-01 00:00:00'
AND posts.post_date < '2019-07-15 00:00:00'
AND ((order_item_meta__product_id_array.meta_key IN ('_product_id', '_variation_id') AND
order_item_meta__product_id_array.meta_value IN ('97')))
如何在报告中以不同方式计算我的商品的总数量?