WooCommerce: Add A New Checkout Field.

Code

We know that checkout page is one of the most important parts of every WooCommerce store.Let’s found out how to add custom fields in WooCommerce checkout.

WooCommerce checkout page is the most important page for both seller and customer. Customers have to provide important information like addresses, billing details, payment method,order notes etc on this page.
And if this page produces an error, no customer will be able to make any purchase! So we can imagine how important this page is to the sellers.

Many times as per our need we need some more information from users when they are buying a product, like GST number, PAN Number , photo, registration number etc.

As Per Requirements ,to add some extra fields to checkout field and to save them in order meta for future use.
It’s simply done by 4 steps:

  1. Add html of new field
  2. Validate new field
  3. Save that field value in order meta
  4. Show Data on order page and emails

Step 1 : Add html of new field

we can add fields on checkout form using “woocommerce_form_field” function. and to show it before order note, we will integrate it in “woocommerce_before_order_notes” hook.

function NewCheckoutField( $checkout ) { 
  $current_user = wp_get_current_user();
  $saved_license_no = $current_user->license_no;
  woocommerce_form_field('gst_no', array(        
    'type' => 'text',        
    'class' => array( 'form-row-wide'),        
    'label' => 'GST Number',        
    'placeholder' => 'GST Number',        
    'required' => true,        
  ), $checkout->get_value( 'gst_no') ); 
}
add_action('woocommerce_before_order_notes', 'NewCheckoutField' );

Step 2 : Validation

If The added field has validation like required then we can validate and show error using “woocommerce_checkout_process” hook.

function ValidateCheckoutField() {    
  if ( ! $_POST['gst_no'] ) {
    wc_add_notice('Please enter your GST Number','error' );
  }
}  
add_action('woocommerce_checkout_process','ValidateCheckoutField');

Step 3 : Save Meta Data

After checkout process we need to save received value to order meta so we can view it on order page and get these data using order id.

function SaveCheckoutFieldMeta( $order_id ) { 
  if ( $_POST['gst_no'] ){
    update_post_meta( $order_id,'_gst_no',esc_attr( $_POST['gst_no'] ) );
  }
}
add_action('woocommerce_checkout_update_order_meta','SaveCheckoutFieldMeta');

Step 4 : Show Meta Data on Order Page And Emails

function ShowGSTField( $order ) {    
  $order_id = $order->get_id();
  if (get_post_meta( $order_id,'_gst_no', true ) ) {
    echo '<p><strong>GST Number:</strong> ' . get_post_meta( $order_id,'_gst_no', true ) . '</p>';
 &nbsp}
}
add_action('woocommerce_admin_order_data_after_billing_address','ShowGSTField', 99, 1 );
 
function SaveCheckoutFieldMetaOnEmail( $order, $sent_to_admin, $plain_text, $email ) {
  if ( get_post_meta( $order->get_id(),'_gst_no', true ) ){
    echo '<p><strong>GST Number:</strong> ' . get_post_meta( $order->get_id(),'_gst_no', true ) . '</p>';
  }
}
add_action('woocommerce_email_after_order_table','SaveCheckoutFieldMetaOnEmail', 99, 4 );
null

Enjoy

Related reading:

Shiv Kumawat

Executive Director & CEO

Shiv Kumawat is the CEO of Eoxys IT Solution LLP, a Jaipur-based IT and GenAI development company he has led since 2009. Eoxys has delivered 700+ projects, building custom AI agents, chatbots, mobile apps and web platforms for businesses worldwide. Shiv writes about practical AI app development and what it takes to ship software that works.

Latest Posts

Isometric illustration of an AI-powered fintech app connected to payment cards, a security shield, an AI chip and a verified AI agent payment token

AI for Fintech Apps: Use Cases, Guardrails and What to Build

On 13 October 2026, American Express published a framework to stop AI agents from making purchases a customer never approved,…

Shiv Kumawat
October 14, 2026
Isometric illustration of an AI agent robot connected to a calculator, coin stacks and cloud APIs, showing the cost to build an AI agent

How Much Does It Cost to Build an AI Agent in 2026?

Ask ten agencies about the cost to build an AI agent and you will get ten different numbers. The answer…

Shiv Kumawat
October 13, 2026
Illustration of how to build a ChatGPT plugin for your business: a chat window with a business app docked in a sidebar panel, connected to a storefront, servers and a database

Build a ChatGPT Plugin for Your Business: What DevDay Changed

At DevDay on 29 September 2026, OpenAI opened up the platform it uses to build ChatGPT’s own features. Plugins can…

Shiv Kumawat
October 12, 2026
,

Leave a Reply

Your email address will not be published. Required fields are marked *