Created
July 14, 2014 10:28
-
-
Save 8lane/d0222d81362f4ea1fa2d to your computer and use it in GitHub Desktop.
Get total amount of customers in WooCommerce
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
| function totalCustomers() { | |
| global $wpdb; | |
| $result = $wpdb->get_row(" | |
| SELECT SUM(pm.meta_value) AS total_sales | |
| FROM $wpdb->posts AS p | |
| LEFT JOIN $wpdb->postmeta AS pm ON (p.ID = pm.post_id AND pm.meta_key = 'total_sales') | |
| WHERE p.post_type = 'product' | |
| "); | |
| return $result->total_sales; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment