How to add a heading in between checkout fields of Woocommerce

后端 未结 3 690
感情败类
感情败类 2020-12-11 06:59

I am customizing the WooCommerce checkout page fields. I want to add a heading (text) in between the fields. I have reordered the fields like this

add_filte         


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-11 07:09

    we can use the filter 'woocommerce_form_field_' . $type... where $type is the type of the input... in our case billing_company is of type text... this filter returns the html of the field, in our case billing field, billing_company.. the filter has 4 arguments being passed, these are $field, $key, $args, $value... we just need two of these...

    add_action( 'woocommerce_form_field_text','reigel_custom_heading', 10, 2 );
    function reigel_custom_heading( $field, $key ){
        // will only execute if the field is billing_company and we are on the checkout page...
        if ( is_checkout() && ( $key == 'billing_company') ) {
            $field .= '

    ' . __('Custom Heading Here') . '

    '; } return $field; }

提交回复
热议问题