Remove checkout fields you don’t need
Removes company name and the second address line from the checkout. Edit the list to remove other fields.
<?php
// Field names: billing_company, billing_address_2, billing_state,
// billing_phone, shipping_company, shipping_address_2, shipping_state...
$remove = array( 'billing_company', 'billing_address_2', 'shipping_company', 'shipping_address_2' );
add_filter(
'woocommerce_checkout_fields',
static function ( $fields ) use ( $remove ) {
foreach ( $remove as $name ) {
$group = strtok( $name, '_' );
unset( $fields[ $group ][ $name ] );
}
return $fields;
},
20
);
Good to know
Applies to the classic checkout. With the block checkout, turn fields off in the Checkout block’s settings instead.
In these packs
- WooCommerce essentials: The small WooCommerce changes shop owners ask for most.