How to remove fields from the order page Woocommerce

How to remove fields from the order page Woocommerce

Woocommerce

To do this, you can use a plug-in type WooCommerce Checkout Manager.
And you can insert a simple function into the functions.php file of your theme:

<?php add_filter( 'woocommerce_checkout_fields' , 'customize_checkout_fields' );
  
function customize_checkout_fields( $fields ) {
 
    return $fields;}?>

In this function, you need to put the identifiers of the fields you want to delete. List of 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['order']['order_comments']);
unset($fields['billing']['billing_email']);
unset($fields['account']['account_username']);
unset($fields['account']['account_password']);
unset($fields['account']['account_password-2']);

For example, to remove the “Last Name” field, the function should look like this:

<?php  add_filter( 'woocommerce_checkout_fields' , 'customize_checkout_fields' );
function customize_checkout_fields( $fields ) {

unset($fields['billing']['billing_last_name']);

    return $fields; } ?>