# Remove Optional Checkout Fields

> Removes the company and second address line fields from the classic checkout form to make it shorter.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, checkout, fields
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-remove-checkout-fields/

## Code

```php
add_filter( 'woocommerce_checkout_fields', function ( $fields ) {
    // Field keys to remove.
    $remove = array( 'billing_company', 'billing_address_2', 'shipping_company', 'shipping_address_2' );

    foreach ( $remove as $key ) {
        $group = 0 === strpos( $key, 'shipping_' ) ? 'shipping' : 'billing';
        unset( $fields[ $group ][ $key ] );
    }

    return $fields;
} );
```

## Notes

Applies to the classic checkout shortcode. Block checkout fields are managed in the Site Editor.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remove Optional Checkout Fields" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
