Created
September 22, 2017 07:48
-
-
Save falexandrou/280080112f7a6b65d30e38d8b919b0fa to your computer and use it in GitHub Desktop.
[WooCommerce] Get current values for a product's sales and stock quantity
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 | |
p.post_title AS "Product title", | |
t1.meta_value AS "Items Sold", | |
t2.meta_value AS "Current Stock Quantity", | |
NOW() AS "Current Date" | |
FROM | |
wp_posts p | |
LEFT JOIN (SELECT meta_value, post_id FROM wp_postmeta WHERE meta_key='total_sales') t1 ON t1.post_id=p.ID | |
LEFT JOIN (SELECT meta_value, post_id FROM wp_postmeta WHERE meta_key='_stock') t2 ON t2.post_id=p.ID | |
WHERE p.ID=102176; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment