Optional input fields in WooCommerce checkout is marked with (optional)
text. This text can be removed without editing any WooCommerce template, by using woocommerce_form_field
filter.
function careless_remove_checkout_optional_text( $field, $key, $args, $value ) {
if( is_checkout() && ! is_wc_endpoint_url() ) {
$optional = ' <span class="optional">(' . esc_html__( 'optional', 'woocommerce' ) . ')</span>';
$field = str_replace( $optional, '', $field );
}
return $field;
}
add_filter( 'woocommerce_form_field' , 'careless_remove_checkout_optional_text', 10, 4 );
Code goes in the functions.php
file of your active theme.