Created
April 12, 2016 14:09
-
-
Save mattmcgiv/26b7f0ce052892014ac9b79be068723e to your computer and use it in GitHub Desktop.
Get the total number of WooCommerce orders from WordPress
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
| //gets the total number of WooCommerce orders from the WP database | |
| function get_number_of_orders() { | |
| global $wpdb; | |
| //get number of orders from database as array | |
| $number_of_orders_array_n = $wpdb->get_results( | |
| "SELECT COUNT(*) FROM wp_posts WHERE post_type = 'shop_order'", ARRAY_N); | |
| //convert number of orders array into a number | |
| return $number_of_orders_array_n[0][0]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment