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.
Enjoy!
PHP Snippet: Show Post / Product / Order / Page Hidden Custom Fields @ Edit Post Page
/**
* @snippet Show Hidden Custom Fields @ WooCommerce Product / Order Admin
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 9
* @community https://businessbloomer.com/club/
*/
add_filter( 'is_protected_meta', '__return_false' );
If you use ACF plugin, it seems you also need this line:
add_filter( 'acf/settings/remove_wp_meta_box', '__return_false' );
Doesn’t work
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 also do not see this – I also don’t even see custom fields – https://snipboard.io/LqndU3.jpg
Uhm, it may be the new version of WooCommerce hiding those… let me check
No it’s not. In my case it’s ACF hiding it. If you happen to have it too, you can use this quick snippet:
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.
Excellent!
Works fine and added it today 7 August 2021
Cool!
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!
Hi Rodolfo
Thanks for the tip — very useful. Is there any way to see the meta keys/values that have been added to product variations?
Thanks
tom
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!
Hi Rodolfo!
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