Key Takeaways
- WooCommerce custom product fields let you display extra product information like dimensions, materials, or care instructions.
- You can add custom fields using code via
functions.phpor with plugins like ACF and YITH Product Add-ons. - Custom field values are saved to the database using
update_post_meta()and retrieved usingget_post_meta(). - Fields added in the backend are reflected on product pages, cart pages, and order status pages.
Custom product fields are additional data points that can be added to products in an online store. These fields allow store owners to collect and display more information about their products beyond the basic details typically included (such as name, price, color, and description).
By adding WooCommerce custom product fields, store owners can provide their customers with more detailed and accurate information about their products, which can help to improve the customer experience and increase sales.
In this tutorial, I’ll show how you can add custom product fields to your WooCommerce store.
What Are Custom Product Fields in WooCommerce?
WooCommerce custom product fields are additional data inputs you can attach to any product in your store. They go beyond the standard fields WooCommerce provides out of the box, such as name, price, SKU, and description.
With custom fields, you can capture and display product-specific information that matters to your customers. Common examples include material composition, care instructions, lead times, compatibility notes, or any specification unique to what you sell.
These fields can appear on product pages, cart pages, checkout, and order confirmation screens, giving both store owners and customers a more complete picture of each product.
Why Should You Add Custom Product Fields in WooCommerce?
Custom product fields offer flexibility in presenting product information. Merchants can create fields for various purposes, such as displaying product dimensions, materials used, care instructions, or any other pertinent details that can influence a customer’s purchasing decision.
WooCommerce Custom fields can significantly enhance the user experience by offering personalized options or configurations. By using custom fields into your WooCommerce setup, you empower both yourself and your customers with a more comprehensive understanding of the products on offer, facilitating smoother transactions.
How to Add Custom Product Fields in WooCommerce (Step-by-Step Tutorial)
Adding custom product fields in WooCommerce involves several steps, but it’s relatively straightforward. Here’s a step-by-step tutorial to guide you through the process:
Step 1 – Customize Product Data Page
- As in the screenshot below, I will show you how to edit the functions.php file (found in the theme folder) to add custom fields to the Product Data page.

Step 2 – Add Hooks in WooCommerce
- The first step is to hook to woocommerce_product_options_general_product_data. The function linked to this hook is responsible for displaying the new fields.
- A second hook, woocommerce_process_product_meta, will save the custom field values.
- Both these actions are carried out in the following code:
// The code for displaying WooCommerce Product Custom Fields add_action( 'woocommerce_product_options_general_product_data', 'woocommerce_product_custom_fields' ); // Following code Saves WooCommerce Product Custom Fields add_action( 'woocommerce_process_product_meta', 'woocommerce_product_custom_fields_save' );
Step 3 – Add Custom Product Fields
- To add the custom fields, I will use the default WooCommerce functions, including:
woocommerce_wp_text_input
- Package: WooCommerce\Admin\Functions
- Located at: includes/admin/wc-meta-box-functions.php
woocommerce_wp_textarea_input
- Package: WooCommerce\Admin\Functions
- Located at includes/admin/wc-meta-box-functions.php
function woocommerce_product_custom_fields () {
global $woocommerce, $post;
echo '<div class=" product_custom_field ">';
// This function has the logic of creating custom field
// This function includes input text field, Text area and number field
echo '</div>';
}
Build Custom Product Fields Without Limits
Our managed WooCommerce hosting includes:
✓ 1-click staging to test custom fields
✓ PHP 8.4 for plugin compatibility
✓ 24/7 expert support
Step 3.1: Include Field Structure
Note: the use of desc_tip to display those nice little bubbles to the right of the field instead of displaying the default field description. This attribute works for every field type.
// Custom Product Text Field
woocommerce_wp_text_input(
array(
'id' => '_custom_product_text_field',
'label' => __( 'My Text Field', 'woocommerce' ),
'placeholder' => 'Custom Product Text Field',
'desc_tip' => 'true'
)
);
- The default value of the step is 1, with the min set to zero. Basically, this means that I expect a positive value here (at least greater than zero).
// Custom Product Number Field
woocommerce_wp_text_input(
array(
'id' => '_custom_product_number_field',
'placeholder' => 'Custom Product Number Field',
'label' => __('Custom Product Number Field', 'woocommerce'),
'type' => 'number',
'custom_attributes' => array(
'step' => 'any',
'min' => '0'
)
)
);
- Use the following to create a
textarea.
// Custom Product Textarea Field
woocommerce_wp_textarea_input(
array(
'id' => '_custom_product_textarea',
'placeholder' => 'Custom Product Textarea',
'label' => __('Custom Product Textarea', 'woocommerce')
)
);
- Use the following code for custom input fields, you must paste this code in
functions.phpfile located in the theme folder.
// Display Fields
add_action('woocommerce_product_options_general_product_data', 'woocommerce_product_custom_fields');
// Save Fields
add_action('woocommerce_process_product_meta', 'woocommerce_product_custom_fields_save');
function woocommerce_product_custom_fields()
{
global $woocommerce, $post;
echo '<div class="product_custom_field">';
// Custom Product Text Field
woocommerce_wp_text_input(
array(
'id' => '_custom_product_text_field',
'placeholder' => 'Custom Product Text Field',
'label' => __('Custom Product Text Field', 'woocommerce'),
'desc_tip' => 'true'
)
);
//Custom Product Number Field
woocommerce_wp_text_input(
array(
'id' => '_custom_product_number_field',
'placeholder' => 'Custom Product Number Field',
'label' => __('Custom Product Number Field', 'woocommerce'),
'type' => 'number',
'custom_attributes' => array(
'step' => 'any',
'min' => '0'
)
)
);
//Custom Product Textarea
woocommerce_wp_textarea_input(
array(
'id' => '_custom_product_textarea',
'placeholder' => 'Custom Product Textarea',
'label' => __('Custom Product Textarea', 'woocommerce')
)
);
echo '</div>';
}
Step 3.2: Save Data in the Database
Once you have created the custom product fields, another function is required to save the values for the update or publish button.
I will create a function woocommerce_product_custom_fields_save. This function is hooked to woocommerce_process_product_meta. It first checks whether the field is empty or filled. If not, a post meta is created using update_post_meta(). I used esc_attr() and esc_html() to secure the data.
Here is the code for saving the value of all the fields:
function woocommerce_product_custom_fields_save($post_id)
{
// Custom Product Text Field
$woocommerce_custom_product_text_field = $_POST['_custom_product_text_field'];
if (!empty($woocommerce_custom_product_text_field))
update_post_meta($post_id, '_custom_product_text_field', esc_attr($woocommerce_custom_product_text_field));
// Custom Product Number Field
$woocommerce_custom_product_number_field = $_POST['_custom_product_number_field'];
if (!empty($woocommerce_custom_product_number_field))
update_post_meta($post_id, '_custom_product_number_field', esc_attr($woocommerce_custom_product_number_field));
// Custom Product Textarea Field
$woocommerce_custom_procut_textarea = $_POST['_custom_product_textarea'];
if (!empty($woocommerce_custom_procut_textarea))
update_post_meta($post_id, '_custom_product_textarea', esc_html($woocommerce_custom_procut_textarea));
}

Step 3.3: Get the Values From the Database
Now that the fields have been created and their values saved, I will display them on the frontend. In this case, I recommend you work with the WooCommerce custom templates.
I will use the popular get_post_meta() function to get those values.
<?php while (have_posts()) : the_post(); ?>
<?php wc_get_template_part('content', 'single-product'); ?>
<?php
// Display the value of custom product text field
echo get_post_meta($post->ID, '_custom_product_text_field', true);
// Display the value of custom product number field
echo get_post_meta(get_the_ID(), '_custom_product_number_field', true);
// Display the value of custom product text area
echo get_post_meta(get_the_ID(), '_custom_product_textarea', true);
?>
<?php endwhile; // end of the loop. ?>

Launch Scalable WooCommerce Stores
Handle unlimited custom fields with:
✓ Auto-scaling for traffic spikes
✓ Dedicated WooCommerce resources
✓ Built-in Redis caching
Step 4: Add Custom Fields on the Product Page
The good thing is that these custom fields can be easily added via the backend. These changes are then reflected in the frontend as custom fields on product pages, cart pages, and similar areas. In fact, these custom fields can also appear on order status pages.
For this, I will show you how to add a new custom field in the Product Data section of a WooCommerce product page:
function woocommerce_product_custom_fields()
{
$args = array(
'id' => 'woocommerce_custom_fields',
'label' => __('Add WooCommerce Custom Fields', 'cwoa'),
);
woocommerce_wp_text_input($args);
}
add_action('woocommerce_product_options_general_product_data', 'woocommerce_product_custom_fields');
Here’s how the snippet would appear on the frontend. As you can see, the custom field has the same label as mentioned in the $args array.

Step 5: Saving Custom Field Data
- Use the following code snippet to add custom fields to product pages.
- The important thing to note about the snippet is that it uses standard WooCommerce functions and actions.
function save_woocommerce_product_custom_fields($post_id)
{
$product = wc_get_product($post_id);
$custom_fields_woocommerce_title = isset($_POST['woocommerce_custom_fields']) ? $_POST['woocommerce_custom_fields'] : '';
$product->update_meta_data('woocommerce_custom_fields', sanitize_text_field($custom_fields_woocommerce_title));
$product->save();
}
add_action('woocommerce_process_product_meta', 'save_woocommerce_product_custom_fields');
How to Display Custom Fields on Product Page in WooCommerce
The following snippet displays the custom fields. The process is simple; it first checks the custom field value and confirms it has a value. If the case is true, it displays the value as the title of the field.
function woocommerce_custom_fields_display()
{
global $post;
$product = wc_get_product($post->ID);
$custom_fields_woocommerce_title = $product->get_meta('woocommerce_custom_fields');
if ($custom_fields_woocommerce_title) {
printf(
'<div><label>%s</label><input type="text" id="woocommerce_product_custom_fields_title" name="woocommerce_product_custom_fields_title" value=""></div>',
esc_html($custom_fields_woocommerce_title)
);
}
}
add_action('woocommerce_before_add_to_cart_button', 'woocommerce_custom_fields_display');
As you can see from the following image, the custom field is visible on the product page. Note that the field title is “WooCommerce product custom fields”, the same as the id value in the snippet.

Using Plugins for WooCommerce Custom Product Fields
As a backup for those who dislike coding or require an easy solution, there are numerous plugins that you can utilize to help you in the use of custom product fields in WooCommerce without coding. Some of them include:
1. Advanced Custom Fields (ACF)
ACF is a very powerful plugin that allows you to create custom fields for every WordPress object, including WooCommerce products. It has a simple-to-use field interface and gets along well with WooCommerce.
- Features: Offers an amazing collection of field types (text, image, date, etc.), conditional logic, and native WooCommerce integration.
- Pros: Very flexible, supports complex field structures, and has great documentation.
- Cons: Too much for simple use cases, there is a learning curve.
2. WooCommerce Product Add-ons
This plugin allows you to add custom fields to your products, which you can use to get more information from customers or offer product variations.
- Features: Offers support for text, checkbox, radio, and select fields, and supports WooCommerce checkout.
- Pros: Easy to use, supports WooCommerce, and offers conditional logic.
- Cons: Less focused on product variations than on information fields.
3. YITH WooCommerce Product Add-ons & Extra Options
This plugin offers a vast range of options to add custom fields and options to WooCommerce products with conditional logic support.
- Features: Supports many field types, including text, checkbox, and select fields, and is WooCommerce compatible.
- Pros: Extremely flexible, compatible with conditional logic, and is WooCommerce compatible.
- Cons: Priced out of range for small stores, and the interface could be disorganized.
How to use these Plugins
- Install the Plugin, by going to your WordPress dashboard, Plugins > Add New, and looking for the plugin you’d like to implement.
- Click on Install Now and then Activate.
- Now set up Custom Fields how you like. Most plugins are straightforward and allow fields to go straight onto your WooCommerce products.
Then there are Fields on Product Pages that can be displayed. There are some of the plugins which will show fields on product pages without you needing to request it. With other plugins, you might need to use shortcodes or widgets in order to show the fields where you want to. Using a plugin is a fast way of adding custom fields on WooCommerce products without coding at all. Each plugin has advantages and disadvantages, hence choose one that addresses your specific needs. Always check if the plugin is compatible with your WordPress and WooCommerce version.
Customize Freely, Host Securely
✓ SSH access for custom code
✓ Isolated development environments
✓ Daily backups of product data
Conclusion
It is important for store owners to carefully consider the types of WooCommerce custom product fields they want to add and how they will be used and displayed on the product page. This can help improve the customer experience and increase sales, as customers are more likely to purchase if they have all the necessary information about a product.
Q. What Are WooCommerce Custom Product Fields?
A. WooCommerce custom product fields are additional data inputs you add to products beyond the default WooCommerce fields. They let you store and display extra product information such as dimensions, materials, care instructions, or any specification unique to your store.
Q. How Do I Add Custom Fields to WooCommerce Products Using Code?
A. Hook into woocommerce_product_options_general_product_data to display the fields and woocommerce_process_product_meta to save them. Use WooCommerce helper functions like woocommerce_wp_text_input() and woocommerce_wp_textarea_input() to create the field markup inside functions.php.
Q. How Do I Save WooCommerce Custom Field Data to the Database?
A. Use update_post_meta() inside your save function hooked to woocommerce_process_product_meta. Always sanitize inputs using esc_attr() for text and number fields and esc_html() for textarea fields before saving.
Q. How Do I Retrieve and Display Custom Field Values on the Product Page?
A. Use get_post_meta($product_id, 'field_key', true) inside your WooCommerce template or in a function hooked to a frontend action like woocommerce_before_add_to_cart_button or woocommerce_single_product_summary.
Q. What is the Difference Between WooCommerce Custom Fields and Attributes?
A. Custom fields store and display additional product-specific information like care instructions or lead times. Attributes define standardized product characteristics like size or color that are used for product variations and filtering in the shop.
Q. What is the Best Plugin for WooCommerce Custom Fields?
A. Advanced Custom Fields (ACF) is the most flexible option for complex field structures. WooCommerce Product Add-ons is better for customer-facing input fields at checkout. YITH WooCommerce Product Add-ons suits stores that need conditional logic across many products.
Q. Can WooCommerce Custom Fields Appear on the Cart and Order Pages?
A. Yes. Custom field values saved to product meta can be displayed on product pages, cart pages, checkout, and order confirmation screens by hooking into the appropriate WooCommerce action hooks for each location.
Q. Do I Need a Plugin to Add Custom Fields in WooCommerce?
A. No. You can add custom fields entirely through code using WooCommerce action hooks and helper functions in your theme’s functions.php file. A plugin is an alternative for those who prefer not to write or maintain custom code.
Salwa Mujtaba
Salwa Mujtaba is a Technical Content Writer at Cloudways. With a strong background in Computer Science and prior experience as a team lead in Cloudways Operations, she brings a deep understanding of the Cloudways Platform to her writing. Salwa creates content that simplifies complex concepts, making them accessible and engaging for readers. When she's not writing, you can find her enjoying good music, reading a book, or spending quality time with her family.