[ad_1]
Hello dear supporter.
I want to display the number of completed orders as a short code.
I found this code:
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' );but it shows the number of all completed orders of the entire site!
I want to have the number of completed orders for each user as a short code to show that number in the user account created with Elementor.
Can you help me, please? Thanks.
Unfortunately, I don’t know English and I use Google Translate. I apologize if my message was inappropriate.
