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.
More posts from themightymo.com
How to fix the “Warning: Class ‘Automattic\WooCommerce\StoreApi\Routes” issue in WordPress + WooCommerce
Today when I visited a customer’s website, I saw an error similar to this: etc. After trying all sorts of troubleshooting, the solution ended up being simple. Download a fresh copy of WooCommerce from WordPress.org and FTP it up to the server, replacing the existing WooCommerce files. Problem solved. Isn’t that nice? Many thanks to…
Here’s a bit of plain CSS that’ll create rainbow text on your WordPress site or anywhere, really.
I ran into a rather serious issue recently: a human on my team (me) intentionally (but accidentally) deleted an Amazon S3 bucket that was serving files to a WordPress site. The solution to the problem follows: Cry when you realize you cannot restore a deleted S3 bucket. Search your computer, your co-workers’ computers, your former…