# Skip Address Fields When Local Pickup Is Chosen

> Hides and stops requiring the street address fields on the classic checkout when the customer picks Local Pickup, since you will not deliver the order.

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

## Code

```php
$wpide_pickup_hidden = array( 'address_1', 'address_2', 'city', 'postcode', 'state', 'company' ); // Billing fields to skip.

$wpide_pickup_selected = function () {
    $chosen = WC()->session ? (array) WC()->session->get( 'chosen_shipping_methods', array() ) : array();

    // phpcs:ignore WordPress.Security.NonceVerification -- WooCommerce verifies the checkout nonce.
    if ( isset( $_POST['shipping_method'] ) ) {
        $chosen = array_map( 'wc_clean', (array) wp_unslash( $_POST['shipping_method'] ) );
    }

    foreach ( $chosen as $method ) {
        if ( 0 === strpos( (string) $method, 'local_pickup' ) ) {
            return true;
        }
    }

    return false;
};

add_filter( 'woocommerce_checkout_fields', function ( $fields ) use ( $wpide_pickup_hidden, $wpide_pickup_selected ) {
    if ( ! $wpide_pickup_selected() ) {
        return $fields;
    }

    foreach ( $wpide_pickup_hidden as $key ) {
        if ( isset( $fields['billing'][ 'billing_' . $key ] ) ) {
            $fields['billing'][ 'billing_' . $key ]['required'] = false;
        }
    }

    return $fields;
}, 30 );

add_action( 'wp_footer', function () use ( $wpide_pickup_hidden ) {
    if ( ! is_checkout() || is_wc_endpoint_url() ) {
        return;
    }

    $selectors = implode( ',', array_map( function ( $key ) {
        return '#billing_' . $key . '_field';
    }, $wpide_pickup_hidden ) );
    ?>
    <script>
    jQuery( function ( $ ) {
        var fields = <?php echo wp_json_encode( $selectors ); ?>;
        function toggle() {
            var method = $( 'input[name^="shipping_method"]:checked, select[name^="shipping_method"], input[type="hidden"][name^="shipping_method"]' ).first().val() || '';
            $( fields ).toggle( method.indexOf( 'local_pickup' ) !== 0 );
        }
        $( document.body ).on( 'updated_checkout', toggle );
        toggle();
    } );
    </script>
    <?php
} );
```

## Notes

Name, email and phone stay required, and the address fields come back if the customer switches to a delivery method.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Skip Address Fields When Local Pickup Is Chosen" 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/
