Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Make Checkout Shipping Postcode Field Not Required in WooCommerce?

If your business provides services or subscriptions and doesn’t need to ship physical items, there’s no need to make the PIN Code field mandatory. The code below helps you make the Shipping form PIN Code field optional instead of the default required value.

add_filter( 'woocommerce_default_address_fields' , 'ts_filter_default_address_fields', 20, 1 );
function ts_filter_default_address_fields( $address_fields ) {
    // Only on checkout page
    if( ! is_checkout() ) return $address_fields;

    // All field keys in this array
    $key_fields = array('postcode');

    // Loop through each address fields (billing and shipping)
    foreach( $key_fields as $key_field )
        $address_fields[$key_field]['required'] = false;

    return $address_fields;
}

Output

The following output shows that the PIN Code field has been changed from a required to an optional field.

How to Make Checkout Shipping Postcode Field Not Required in WooCommerce?

This is how the PIN Code field was represented as required field before applying the code.

How to Make Checkout Shipping Postcode Field Not Required in WooCommerce?

Depending on your store’s preference you can choose to make any fields optional or mandatory. Similar to the above customization you can also make fields mandatory or optional on the WooCommerce checkout page.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x