Ecommerce Shopify WordPress Discussion

Displaying the number of orders by status in WooCommerce

have a good time I wanted to display the number of orders by status on the customer account page of my WordPress site, in such a way that the number of completed orders, canceled orders, and orders in progress are calculated separately and displayed through a shortcode. I tried the below but I have not received a response Thank you for your advice 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' );
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.