How To Remove Checkout Fields in WooCommerce

Sometimes you don’t need all the fields in checkout page. Using this code snippet you can easily remove the billing or shipping fields from your checkout page.

The function lionplugins_remove_checkout_fields hooks into woocommerce_checkout_fields, which allows us to change the checkout fields. We remove the fields by using PHP built-in function unset.


function lionplugins_remove_checkout_fields( $fields ) {

    // remove billing fields
    unset($fields['billing']['billing_first_name']);
    unset($fields['billing']['billing_last_name']);
    unset($fields['billing']['billing_company']);
    unset($fields['billing']['billing_address_1']);
    unset($fields['billing']['billing_address_2']);
    unset($fields['billing']['billing_city']);
    unset($fields['billing']['billing_postcode']);
    unset($fields['billing']['billing_country']);
    unset($fields['billing']['billing_state']);
    unset($fields['billing']['billing_phone']);
    unset($fields['billing']['billing_email']);
   
    // remove shipping fields 
    unset($fields['shipping']['shipping_first_name']);    
    unset($fields['shipping']['shipping_last_name']);  
    unset($fields['shipping']['shipping_company']);
    unset($fields['shipping']['shipping_address_1']);
    unset($fields['shipping']['shipping_address_2']);
    unset($fields['shipping']['shipping_city']);
    unset($fields['shipping']['shipping_postcode']);
    unset($fields['shipping']['shipping_country']);
    unset($fields['shipping']['shipping_state']);
    
    // remove order comment fields
    unset($fields['order']['order_comments']);
    
    return $fields;
}

add_filter( 'woocommerce_checkout_fields', 'lionplugins_remove_checkout_fields' );

Leave a Reply

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