Remove "(optional)" From Checkout Field Labels
Hides the "(optional)" text WooCommerce adds after the labels of fields that are not required.
Opens WPIDE on
Code
add_filter( 'woocommerce_form_field', function ( $field ) {
return preg_replace( '#\s*<span class="optional">.*?</span>#', '', $field );
} );
Notes
Required fields still show their asterisk.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.