• I am trying to get some simple formated text after 4th field of checkout form , when loading it displays in the right position , but when fully loaded text jumps to the top of form. The code to add test i used in form-billing.php

    $fields = $checkout->get_checkout_fields( 'billing' );
    
                $i = 0; //twof
    
                foreach ( $fields as $key => $field ) {
    
                    $i ++;
                    if ($i == 5) {
                        echo 'Some text';
                    }
                    if ( isset( $field['country_field'], $fields[ $field['country_field'] ] ) ) {
                        $field['country'] = $checkout->get_value( $field['country_field'] );
                    }
                    $field['input_class'][] = 'form-control';
                    woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
                }

    i have also tried:

    
    add_filter('woocommerce_form_field_text', function ($field, $key, $args, $value) {
        if ($key === 'billing_first_name') {
            $field .= 'footnote text <a href="/">with link</a>';
        }
    
        return $field;
    }, 10, 4);
    

    same issue, text jumps to the top of form when fully loaded.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Fernando a11n

    (@fhaps)

    Automattic Happiness Engineer

    @eskruolis I know you were looking for some coding advice to fix the above snippets. However, in case you’d like to explore a plugin option, I thought you might be able to give Checkout Field Editor a shot.

    It would likely not help for longer text elements, but if this would be more of a heading, the extension does include the option to add extra headings on the checkout form. See an example here:

    Hope that helps.

    Thread Starter Eigirdas Skruolis

    (@eskruolis)

    @fhaps Thanks for your advice, but i am developer not consumer , so therefore 3d party plugin solution is not what i am after, i could simply use $('#billing_email').before( '<h3>Some Text</h3>' ); jQuery to add the headings , i wanted to implement it using php template generation, regardless , i. tried plugin demo and it does not have heading option anywhere, other way i could do is create input field and display only label of it , and target css for it to make it heading-like , which i want to avoid also , cheers for advise though!

    Plugin Support Damianne P (a11n)

    (@drwpcom)

    Hi @eskruolis. Sorry that we missed your last post.

    For development oriented questions, I recommend posting to one of the following places:

    `

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding text above some fields checkout form’ is closed to new replies.