Woocommerce自定义结帐字段如何将它们放在一起?

问题描述:

嗨,大家好我是在退房时制作woocommerce的自定义表格。我想让我的领域彼此相邻。我该如何做到这一点?这是我现在所拥有的,它只是将它们放在彼此之间Woocommerce自定义结帐字段如何将它们放在一起?

add_action('woocommerce_before_checkout_billing_form', 'checkoutFields'); 

function checkoutFields($checkout) { 

    echo '<div id="my-custom-step"><h2>' . __('My Field') . '</h2>'; 

    woocommerce_form_field('orgin_firstname', array(
     'type'   => 'text', 
     'class'   => array('orgin_firstname form-row-first'), 
     'label'   => __('First Name'), 
     'placeholder' => __(''), 
     'required'  => true, 
     ), $checkout->get_value('orgin_firstname')); 

    woocommerce_form_field('orgin_lastname', array(
     'type'   => 'text', 
     'class'   => array('orgin_lastname form-row-last'), 
     'label'   => __('Fill in this field yo'), 
     'placeholder' => __('Enter something '), 
     ), $checkout->get_value('orgin_lastname')); 

    echo '</div>'; 

} 

我添加这些字段的方式也可能很重要。我目前做这个:

jQuery(function(){ 
     jQuery(".orgin_firstname").detach().appendTo(".customSteps") //this is my div I am putting them in 
}) 
    jQuery(function(){ 
     jQuery(".orgin_lastname").detach().appendTo(".orgin_firstname") 
}) 

我意识到自己的错误是追加到orgin_firstname当它应该已经到自定义的步骤。