How to Display WooCommerce Shipping Name in a WordPress Theme

Today I needed to display the shipping name for a product on the front end of a WooCommerce-enabled WordPress theme.

While the shipping name is attached to WordPress user meta, it is not part of the core user meta that ships with WordPress.  So, we have to use the generic “get_metadata()” function to pull the data like this:

global $current_user;
$fname = get_metadata('user', get_current_user_id(), 'billing_first_name', $single);
echo $fname;

That’s it! Pretty simple, and you can use it to get just about any piece of WooCommerce user data that you want. For example, to get the billing last name, you would switch “billing_first_name” with “billing_last_name” in the code above.

Enjoy!

Posted in

Toby Cryns

Toby Cryns is a freelance CTO, expert WordPress consultant, and teacher.

He offers free advice to improve your freelance biz.

He also publishes small droppings every now and then to twitter.com/tobycryns and twitter.com/themightymo

Follow Toby's contributions on Github and WP.org.