phpcsswoocommercewoocommerce-themingwoocommerce-checkout-fields

Woocommerce how to change the color of a checkout field text label


Good afternoon,

Maybe someone came across such a question. How to change the text of a defined field in a checkout. All fields refer to one label.

enter image description here


Solution

  • Which one? The actual text of the label or its color?

    For the actual text of the label use the following filter hook! For example if you want to change the first name label in the billing section:

    add_filter('woocommerce_checkout_fields', 'your_custom_checkout_fields', 20);
    
    function your_custom_checkout_fields($fields){
    
        $fields['billing']['billing_first_name']['label'] = 'testing label 101!';
    
        # example of other fields
        # $fields['billing']['billing_last_name']['label'] = 'some label!'; 
        # $fields['billing']['billing_country']['label'] = 'some other label!';
        # $fields['billing']['billing_phone']['label'] = 'other label';
        # $fields['billing']['billing_email']['label'] = 'your label';
    }
    

    If you want to change its color, then use the following css rule:

    .woocommerce #billing_first_name_field label {
    
      color: pink; /* you could replace pink with any color you want!!! */
    
    }