Add custom css class to WooCommerce checkout fields

后端 未结 4 732
名媛妹妹
名媛妹妹 2020-12-13 01:07

I would like to be able to add a custom CSS class to my WooCommerce checkout fields. I\'m using twitter Bootstrap and I would like to be able to use their .form-control clas

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 01:33

    icc97's answer is almost there but doesn't work.

    I took icc97's answer, and debugged it:

    add_filter('woocommerce_checkout_fields', 'addBootstrapToCheckoutFields' );
    public function addBootstrapToCheckoutFields($fields) {
        foreach ($fields as &$fieldset) {
            foreach ($fieldset as &$field) {
                // if you want to add the form-group class around the label and the input
                $field['class'][] = 'form-group'; 
    
                // add form-control to the actual input
                $field['input_class'][] = 'form-control';
            }
        }
        return $fields;
    }
    

提交回复
热议问题