Advertisement
phpface

Get customer total profilt

Dec 27th, 2018
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.42 KB | None | 0 0
  1. select sum(pm1.meta_value) as total_profit from wp_postmeta as pm1
  2. inner join wp_posts as p on pm1.post_id = p.ID
  3. inner join wp_postmeta as pm2 on pm2.post_id = p.ID
  4. where pm1.meta_key = '_order_profit' and pm2.meta_key = '_customer_user' and pm2.meta_value = 17
  5. and p.post_type = 'shop_order' and p.post_status in ( 'wc-completed', 'wc-processing' )
  6. and p.post_date between '2018-12-25 00:00:00' and '2018-12-26 00:00:00'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement