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.
This is how the PIN Code field was represented as required field before applying the code.
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.