Disable WooCommerce Checkout Fields

I’m working on a site where I have to disable the WooCommerce checkout field.  While StackOverflow is full of chunks that remove the checkout fields totally.  So I dig in WooCommerce and found the below solution.

add_filter( 'woocommerce_checkout_fields' , 'disbale_checkout_fields' );

// Disable WooCommerce Checkout Fields.
function disbale_checkout_fields( $fields ) {
     
     $fields['billing']['billing_first_name']['custom_attributes'] = array( 'disabled' => true );
     $fields['billing']['billing_last_name']['custom_attributes'] = array( 'disabled' => true );
     $fields['billing']['billing_country']['custom_attributes'] = array( 'disabled' => true );
     $fields['billing']['billing_company']['custom_attributes'] = array( 'disabled' => true );
     $fields['billing']['billing_address_1']['custom_attributes'] = array( 'disabled' => true );
     $fields['billing']['billing_address_2']['custom_attributes'] = array( 'disabled' => true );
     $fields['billing']['billing_city']['custom_attributes'] = array( 'disabled' => true );
     $fields['billing']['billing_state']['custom_attributes'] = array( 'disabled' => true );
     $fields['billing']['billing_postcode']['custom_attributes'] = array( 'disabled' => true );
     $fields['billing']['billing_phone']['custom_attributes'] = array( 'disabled' => true );
     $fields['billing']['billing_email']['custom_attributes'] = array( 'disabled' => true );

     return $fields;
}

 

Be First to Comment

Leave a Reply

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