Last active
August 30, 2019 22:46
-
-
Save luiseduardobraschi/def4c0e06dd68c826d4787b4c23d6f5e to your computer and use it in GitHub Desktop.
[WooCommerce BR] Get orders from user by ID or e-mail
This file contains 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 wp_posts.* FROM wp_posts | |
INNER JOIN wp_users AS users ON users.user_email = 'EMAIL_YOU_WANT' | |
INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id | |
WHERE 1=1 | |
AND wp_postmeta.meta_key = '_customer_user' | |
AND wp_postmeta.meta_value = users.ID | |
AND wp_posts.post_type = 'shop_order' | |
GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC |
This file contains 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 wp_posts.* FROM wp_posts | |
INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id | |
WHERE 1=1 | |
AND wp_postmeta.meta_key = '_customer_user' | |
AND wp_postmeta.meta_value = 'ID_YOU_WANT' | |
AND wp_posts.post_type = 'shop_order' | |
GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment