简体   繁体   English

Woocommerce自定义结帐字段如何将它们彼此相邻?

[英]Woocommerce custom checkout fields how to put them next to each other?

Hi guys I am making a custom form in woocommerce when checking out. 嗨,大家好,我在结帐时正在woocommerce中创建自定义表单。 I want to make my fields next to each other. 我想使我的田地彼此相邻。 How do I accomplish this? 我该如何完成? This is what I have now and it just places them under each other 这就是我现在所拥有的,只是将它们相互放置

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>';

}

The way I add these fields might be important as well. 我添加这些字段的方式也可能很重要。 I am presently doing this: 我目前正在这样做:

    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上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM