Add custom billing fields in WooCommerce

Besides removing all unnecessary fields, adding useful fields to the page is also significant. Use this snippet to add the desired fields on your checkout page. Look below the default checkout form given in the image.

Before applying snippet

Now let’s Add this to your function.php in the child theme.

// Add the company code field on the billing form

function wps_custom_checkout_fields( $fields ) {

     $fields['billing']['billing_company_code'] = array(
        'label'         => __('Company Code', 'woocommerce'),
        'placeholder'   => _x('Company code: 3801083518', 'placeholder','woocommerce'),
        'required'      => false,
        'class'         => array('form-row-wide'),
        'clear'         => true, 

        return $fields;


add_filter( 'woocommerce_checkout_fields' , 'wps_custom_checkout_fields' );

 * Display field value on the order edit page
function wps_company_code_field_to_order_detail( $order ) {

     echo '<p>'.__('Company Code').':' . get_post_meta( $order->get_id(), 
     '_shipping_phone', true ) . '</p>';


add_action( 'woocommerce_admin_order_data_after_shipping_address', 'wps_company_code_field_to_order_detail', 10, 1 );

In the above function first, we are forming an array of the field details and then returning it. In the second function, we are getting the order ID and displaying the field on the page. let’s check the final result you will see the field is been added at the last of the form.

After applying snippet

Edit WooCommerce Products from Frontend

Leave a Comment

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

Scroll to Top