Skip to content

Instantly share code, notes, and snippets.

@fearlex
Created March 10, 2019 14:35
Show Gist options
  • Save fearlex/cd5811687c7ce5ffe46d43d06a738531 to your computer and use it in GitHub Desktop.
Save fearlex/cd5811687c7ce5ffe46d43d06a738531 to your computer and use it in GitHub Desktop.
Woocommerce Orders queries
##-- Show Orders Current Postmeta
SELECT DISTINCT pm.meta_key FROM wp_postmeta AS pm LEFT JOIN wp_posts AS p ON p.ID = pm.post_id WHERE p.post_type = 'shop_order';
##-- Show Last 20 Orders
SELECT SQL_CALC_FOUND_ROWS hush_posts.ID
FROM hush_posts
WHERE 1=1
AND hush_posts.post_type = 'shop_order'
AND ((hush_posts.post_status = 'wc-pending'
OR hush_posts.post_status = 'wc-processing'
OR hush_posts.post_status = 'wc-on-hold'
OR hush_posts.post_status = 'wc-completed'
OR hush_posts.post_status = 'wc-cancelled'
OR hush_posts.post_status = 'wc-refunded'
OR hush_posts.post_status = 'wc-failed'))
ORDER BY hush_posts.menu_order, hush_posts.post_date DESC
LIMIT 0, 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment