Remove Woocommerce checkout fields

We can manage Woocommerce checkout form filed to suit our purpose. To do this we can use filter to customize the Woocommerce check out field forms.
We can remove as well as add new field to checkout form

To remove follow the following example below :

add_filter( 'woocommerce_checkout_fields' , 'manage_woocommerce_checkout_fields' );
function manage_woocommerce_checkout_fields( $checkoutfields ) {
     unset($checkoutfields['billing']['billing_first_name']); 
     unset($checkoutfields['billing']['billing_last_name']); 
     unset($checkoutfields['billing']['billing_company']); 
     unset($checkoutfields['billing']['billing_address_1']); 
     unset($checkoutfields['billing']['billing_address_2']); 
     unset($checkoutfields['billing']['billing_city']); 
     unset($checkoutfields['billing']['billing_postcode']); 
     unset($checkoutfields['billing']['billing_country']); 
     unset($checkoutfields['billing']['billing_state']); 
     unset($checkoutfields['billing']['billing_email']); 
     unset($checkoutfields['billing']['billing_phone']); 
     unset($checkoutfields['shipping']['shipping_first_name']);
     unset($checkoutfields['shipping']['shipping_last_name']);
     unset($checkoutfields['shipping']['shipping_company']);
     unset($checkoutfields['shipping']['shipping_address_1']);
     unset($checkoutfields['shipping']['shipping_address_2']);
     unset($checkoutfields['shipping']['shipping_city']);
     unset($checkoutfields['shipping']['shipping_postcode']);
     unset($checkoutfields['shipping']['shipping_country']);
     unset($checkoutfields['shipping']['shipping_state']);
     unset($checkoutfields['account']['account_username']); 
     unset($checkoutfields['account']['account_password']);
     unset($checkoutfields['account']['account_password-2']);
     unset($checkoutfields['order']['order_comments']);
     return $checkoutfields;
}

To add new field follow the below example

add_filter( 'woocommerce_checkout_fields' , 'new_filed' );
function new_field(){

$fields['billing']['_new_field'] = array(
    'placeholder'   => 'Type here',
    'required'  => false,
    'class'     => array('form-row-wide'),
    'clear'     => true,
    'type'      => 'text',
     );

     return $fields;
} 

Leave comment

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