You can add custom fields by editing your theme’s functions.php
file. Use WooCommerce hooks like woocommerce_product_options_general_product_data
to add fields and woocommerce_process_product_meta
to save them.
Add custom fields to WooCommerce product page without plugins and unlock full control over your store layout — no bloat, no unnecessary code, and lightning-fast performance. In this guide, you’ll learn exactly how to do it the clean way with just a few lines of PHP.
What Are Custom Fields in WooCommerce?
Custom fields let you add extra information to your product pages, such as manufacturer details, expiration dates, shipping instructions, or anything else specific to your product.
This helps personalize your store and improve the shopping experience for your customers.
Why Avoid Plugins for Adding Custom Fields?
- Performance: Fewer plugins = faster site
- Security: Custom code is leaner and more controlled
- Flexibility: You can place the field exactly where you want
How to Add Custom Fields to WooCommerce Product Page (Step-by-Step)
1. Add Custom Field in the Product Admin Panel
Paste the following code into your theme’s functions.php
file:
add_action('woocommerce_product_options_general_product_data', 'add_custom_product_field');
function add_custom_product_field() {
woocommerce_wp_text_input( array(
'id' => '_custom_product_note',
'label' => __('Custom Product Note', 'woocommerce'),
'desc_tip' => true,
'description' => __('Enter a custom note for this product.', 'woocommerce')
));
}
2. Save the Custom Field Data
add_action('woocommerce_process_product_meta', 'save_custom_product_field');
function save_custom_product_field($post_id) {
$custom_field = $_POST['_custom_product_note'] ?? '';
if (!empty($custom_field)) {
update_post_meta($post_id, '_custom_product_note', sanitize_text_field($custom_field));
}
}
3. Display the Custom Field on the Frontend
To show the field on your single product page:
add_action('woocommerce_single_product_summary', 'display_custom_product_note', 25);
function display_custom_product_note() {
global $post;
$note = get_post_meta($post->ID, '_custom_product_note', true);
if ($note) {
echo '<p class="custom-note">' . esc_html($note) . '</p>';
}
}
Real Use Case Examples
- Product Origin: Show where the item was made
- Custom Shipping Info: Add delivery instructions
- Storage Tips: Include extra care instructions
Bonus: Add Custom Field to Cart & Checkout
If you want your field data to appear in the cart or checkout, use the following snippets:
Show Custom Field in Cart
add_filter('woocommerce_get_item_data', 'add_custom_field_to_cart', 10, 2);
function add_custom_field_to_cart($item_data, $cart_item) {
if (!empty($cart_item['data'])) {
$note = get_post_meta($cart_item['product_id'], '_custom_product_note', true);
if ($note) {
$item_data[] = array(
'key' => __('Note', 'woocommerce'),
'value' => wc_clean($note),
'display' => '',
);
}
}
return $item_data;
}
Final Thoughts
Adding custom fields to WooCommerce product pages without plugins gives you maximum performance and control. Whether you want to display dynamic notes, storage info, or shipping details, using clean PHP code keeps your site lean and SEO-friendly.
Next up? Learn how to customize the WooCommerce checkout page and boost your conversion rates even more.
Need help? Contact Babar Ilyas for professional WooCommerce development services.
After customizing your product pages, make sure your checkout experience is on point too — here’s a guide on how to customize the WooCommerce checkout page without bloating your store. And if your admin panel is getting sluggish, check out this fix to improve WooCommerce dashboard performance and speed things up.