On a recent job, a client asked me to display the logged-in username in WooCommerce. It sounded like a simple task, but it actually opened the door to some interesting use cases. He specifically wanted the username to appear on the Checkout page—perhaps to personalize the experience—and also within the Order confirmation email sent to the customer.
This kind of functionality can be useful in many scenarios: showing a personalized greeting, tagging orders with usernames for internal reference, or even building custom conditional logic based on the current user.
Luckily, WooCommerce gives us access to the current user object pretty easily. Whether you’re editing templates or using hooks, retrieving the logged-in username is a quick win that can help enhance the user experience and add a touch of personalization to the purchase flow.
Here’s a simple code snippet you can use to get the logged-in username in WooCommerce.
Continue reading WooCommerce: Display Logged in Username @ Checkout