How to rearrange/customize html in woocommerce checkout form fields

前端 未结 3 1581
天涯浪人
天涯浪人 2021-01-07 05:41

I want to accomplish 2 things in my woocommerce checkout form: 1. Put some text between some groups of fields, for example (h3):

my custom heading&

3条回答
  •  被撕碎了的回忆
    2021-01-07 05:51

    For the first one you can do the following to display single input field

    checkout_fields['billing']['billing_first_name'], 
        $checkout->get_value( 'billing_first_name' )
    );
    
    ?>
    

    where you can replace first_name with any key of the checkout billing fields

    So for your example it will be something like this

    my custom heading

    checkout_fields['billing']['billing_email'], $checkout->get_value( 'billing_email' ) ); ?>

    As for the second I'm not sure how you can achieve that. I needed something similar and i used javascript to reposition the labels.

    something like :

    jQuery('form.checkout label').each(function(){
        jQuery(this).insertAfter(jQuery(this).parent().find('input'));
    })
    

提交回复
热议问题