Created
April 13, 2015 14:16
-
-
Save ChuckMac/62ee5c0bcfc0eb8d6780 to your computer and use it in GitHub Desktop.
WooCommerce - Order Tax Report By State / Date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT i.order_id as "Order #", pm4.meta_value as "Order Completed Date", tm.name as "Order Status", pm.meta_value as "Billing State", pm2.meta_value as "Order Total", pm3.meta_value as "Order Tax" | |
FROM wp_woocommerce_order_items i | |
INNER JOIN wp_postmeta pm | |
on pm.post_id = i.order_id | |
INNER JOIN wp_postmeta pm2 | |
on pm2.post_id = i.order_id | |
INNER JOIN wp_postmeta pm3 | |
on pm3.post_id = i.order_id | |
INNER JOIN wp_postmeta pm4 | |
on pm4.post_id = i.order_id | |
INNER JOIN wp_term_relationships tr | |
on tr.object_id = i.order_id | |
INNER JOIN wp_terms tm | |
WHERE | |
pm.meta_key = '_billing_state' | |
AND | |
pm.meta_value = 'XX' | |
AND | |
tm.term_id = tr.term_taxonomy_id | |
AND | |
pm2.meta_key = '_order_total' | |
AND | |
pm3.meta_key = '_order_tax' | |
AND | |
pm4.meta_key = '_completed_date' | |
AND | |
DATE(pm4.meta_value) >= '2015-01-01' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Chuck, this looks like exactly what I need on a new project. Did you create an entire plugin for this code or add it to an existing WC file?