My Courses > CustomizeWoo > Module 5 > Lesson 03: Custom Fields
Custom Fields
Custom fields (post meta, metadata) allow you to store additional information with each WordPress post (WooCommerce products included). They can then be displayed/used anywhere.
Video
Please note: English captions are enabled by default (click on “CC” in the video player to disable). Also, you can click on the “gear” icon to manage quality and playback speed. Enjoy!
Useful Links
WooCommerce: Add Custom Product Fields (e.g. RRP) Without a Plugin: https://www.businessbloomer.com/woocommerce-display-rrp-msrp-manufacturer-price/
WooCommerce: Add Custom Field to Product Variations: https://www.businessbloomer.com/woocommerce-add-custom-field-product-variation/
WordPress Custom Fields: https://wordpress.org/support/article/custom-fields/
HI Rodolfo,
I want to show an specific attribute in the single_product_summary after the price and on the left site. I know you told this in one of the courses but I can’t find the specific course anymore. Can you guide me in the right direction?
Marco
Thanks for your question Marco π
So, to display a custom field you can use https://businessbloomer.com/woocommerce-show-number-products-sold-product-page/ (in this case it gets the total sales, but you can get the custom field value with get_post_meta() – here’s an example: https://businessbloomer.com/woocommerce-show-product-custom-field-in-the-category-pages/)
Let me know
Ciao Rodolfo,
I am not getting there. The attribute is pa_merk and I want it after woocommerce_single_product_summary. I think it is easy but I am not seeing it. Could you …..:-)
Ah – sorry – so it’s a product attribute. Try with:
YEP, that’s it. Thanks
And if I want that attribute to link to the archive page?
I would search through the WooCommerce plugin files for the wc_display_product_attributes() function. At some stage within this function you find this for a single attribute:
So, you first need to get the $attribute_value.
Another option: https://docs.woocommerce.com/document/display-product-attribute-archive-links/
Thanks for all that!
Thank you – but I need to just add a number (Item Code) to be displayed – what should be the ‘data type’?
You can just remove that line, as it’s not a price π
Hi Rodolfo,
I have watched the lesson you have recommended and read the article, but something is still not clear;
I have used this code – from your website – to add a custom field on variation products:
Can you let me know what changes I need to add to this code in order for the custom field to be displayed also on simple products pages?
If it’s to much trouble – can you recommend a professional that can to it for money? I know it’s fairly easy for an experienced developer – I just need it solved fast and I am just in the
beginning of my WooCommerce programming journey..
Thank you!
Hello Yonatan!
For simple products you can use this version: https://businessbloomer.com/woocommerce-display-rrp-msrp-manufacturer-price/
Let me know π
Do you have a list of options for where custom fields can be placed? Similar options to woocommerce_product_options_pricing, woocommerce_variation_options_pricing, etc.
Hey Bradley! No, I don’t have a “visual hook guide” for the product admin – I’ve been holding on with this as they’re changing the product editor so it may be a waste of time.
You could simply do a search through the WooCommerce plugin files, and look for “do_action” inside the Product Data templates:
/woocommerce/includes/admin/meta-boxes/views/html-product-data-general.php
/woocommerce/includes/admin/meta-boxes/views/html-product-data-inventory.php
/woocommerce/includes/admin/meta-boxes/views/html-product-data-shipping.php
/woocommerce/includes/admin/meta-boxes/views/html-product-data-linked-products.php
/woocommerce/includes/admin/meta-boxes/views/html-product-data-attributes.php
/woocommerce/includes/admin/meta-boxes/views/html-product-data-advanced.php
Hope this helps!