Skip to content

Instantly share code, notes, and snippets.

@JackScottAU
Created July 19, 2017 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackScottAU/6fc19671008be78fd7dfc45988138e48 to your computer and use it in GitHub Desktop.
Save JackScottAU/6fc19671008be78fd7dfc45988138e48 to your computer and use it in GitHub Desktop.
Get Customer Emails from WooCommerce
SELECT meta_value AS email, COUNT(meta_value) AS orders
FROM wp_postmeta INNER JOIN wp_posts ON wp_posts.ID = wp_postmeta.post_id
WHERE wp_posts.post_type = 'shop_order' AND wp_postmeta.meta_key = '_billing_email'
GROUP BY meta_value
ORDER BY COUNT(meta_value) DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment