skip to Main Content

WordPress Code Snippets


Display User’s Orders Count in My Account

Show the number of orders a user has on their account page.

add_action('woocommerce_account_dashboard', 'codebykp_display_orders_count');
function codebykp_display_orders_count() {
    $customer_orders = wc_get_orders(array(
        'customer_id' => get_current_user_id(),
        'limit' => -1,
    ));
    $order_count = count($customer_orders);
    echo '<p>You have ' . esc_html($order_count) . ' orders.</p>';
}


I’m a WordPress developer with 10+ years of experience in WooCommerce and custom plugins. I combine technical expertise with design flair to help you create standout, user-friendly websites. Let’s transform your digital presence!

Best WordPress Hosting
Back To Top
Search