Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function display_woocommerce_order_count( $atts, $content = null ) {
- $args = shortcode_atts( array(
- 'status' => 'completed',
- ), $atts );
- $statuses = array_map( 'trim', explode( ',', $args['status'] ) );
- $order_count = 0;
- foreach ( $statuses as $status ) {
- // if we didn't get a wc- prefix, add one
- if ( 0 !== strpos( $status, 'wc-' ) ) {
- $status = 'wc-' . $status;
- }
- $order_count += wp_count_posts( 'shop_order' )->$status;
- }
- ob_start();
- echo number_format( $order_count );
- return ob_get_clean();
- }
- add_shortcode( 'wc_order_count', 'display_woocommerce_order_count' );
Add Comment
Please, Sign In to add comment