Woo Checkout Editor "optional" text

Hello, i would like to remove the (optional) text displayed by default with the non mandatory fields.
What should I do ?
Thanks.

Hi @qifactory,

To remove it, you can add the code below in your child theme’s functions.php file

add_filter( 'woocommerce_form_field' , 'remove_checkout_optional_fields_label', 10, 4 );
function remove_checkout_optional_fields_label( $field, $key, $args, $value ) {
    // Only on checkout page
    if( is_checkout() && ! is_wc_endpoint_url() ) {
        $optional = '&nbsp;<span class="optional">(' . esc_html__( 'optional', 'woocommerce' ) . ')</span>';
        $field = str_replace( $optional, '', $field );
    }
    return $field;
}

Hope that helps

That worked pretty well-

Thanks for your support.

You’re welcome!
Thanks for letting us know that it has worked for you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.