Created
July 9, 2019 11:48
-
-
Save DevWael/e2d15da37f5249c911380307ca6d628a to your computer and use it in GitHub Desktop.
get all orders count in woocommerce website
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
<?php | |
function prefix_orders_count() { | |
if ( ! class_exists( 'woocommerce' ) ) { | |
return false; | |
} | |
$args = [ | |
'posts_per_page' => - 1, | |
'post_type' => 'shop_order', | |
'post_status' => 'any', | |
'fields' => 'ids', | |
]; | |
$query = new WP_Query( $args ); | |
$orders_count = $query->found_posts; | |
return $orders_count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment