I was working on a WooCommerce project recently and I didn’t want to waste time searching through all the hidden product post meta.
Post meta are basically product custom fields that are added via the update_post_meta() WordPress function by WooCommerce itself, a custom plugin, a snippet, a theme. For example, “total_sales” is a default WooCommerce product custom field that updates every time the product is purchased. You can “get” total sales with the get_post_meta() WordPress function.
In the same way, there are dozens of default and third party product custom fields that are stored inside the WooCommerce product meta. If the product custom field “meta key” starts with an underscore (“_”), however, this won’t be visible in the “Custom Fields” section of the edit product page screen. Which is a bummer.
So, today, I’ll show you a quick trick so you can always know what the values for product meta keys are without having to mess with print_r() or error_log() in your PHP functions. In the image below, you see the final outcome.
Please note this also shows order hidden meta.
PHP Snippet: Show Post/Product/Order/Page Hidden Custom Fields @ Edit Post Page
Please let me know in the comments if everything went as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting.
Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.
14 thoughts on “WooCommerce: View Product/Order Hidden Custom Fields (“Protected Meta”)”
Maybe your “custom fields” section is hidden? If yes, try clicking on the top right “Screen options” and check custom fields. Let me know
I added the snippet at the bottom of child theme functions.php and no meta fields appear at the product backend page.
This still works for sure as I use it on client sites. Sure you have the custom fields meta box visible on that page?
Gosh, this saved me a ton of time in troubleshooting some issues with funky subscriptions. Added the snippet to my site today using the Code Snippets plugin from the WP repo. Was able to view custom fields added to a subscription order and the related renewal orders. Using WooCommerce 6.0.0 on WordPress 5.8.3. Excellent work Rodolfo. I think I’ll just drop this little tweak into my site’s functionality plugin.
Works fine and added it today 7 August 2021
Hello, how to completely remove these fields from Woocommerce orders? We have e.g. mailchimp_woocommerce_landing_site and 30+ other theme fields. Best!
Hi Seba, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Thanks for the tip — very useful. Is there any way to see the meta keys/values that have been added to product variations?
Hello Tom, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
thank you for your useful information. You are right – there are a dozen of hidden or visible custom/meta fields in every product and order. I found even very old meta I created long-long time ago for products I do not have right now.
Is there any reason to keep these in site’s DB or to wipe them for DB speed reason?
Great! No, I don’t think this slows down the DB by a lot, unless you have 100,000 products