首页 文章

在WooCommerce注册表单中添加一个复选框

提问于
浏览
1

我想添加一个自定义复选框,以便在WooCommerce注册表单上同意条款和条件 . 我这样做了,但是如何在密码和注册按钮之间显示该复选框 . 这是我的注册表的链接:https://otpeople.com/my-account/

它显示在那里,但我希望它在所有字段的底部,以及指向我的条款和条件页面的链接 .

码:

<?php

   function wooc_extra_register_fields() {

 ?>

    <p class="form-row form-row-wide">

     <label for="reg_billing_first_name"><?php _e( 'Full Name', 'woocommerce' ); ?><span class="required">*</span></label>

     <input type="text" required class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />

   </p>

     <div class="clear"></div>



   <p class="form-row form-row-wide">

     <label for="reg_billing_phone"><?php _e( 'Mobile Number', 'woocommerce' ); ?><span class="required">*</span></label>

     <input type="Number" required class="input-text" name="billing_phone" id="reg_billing_phone" value="<?php if ( ! empty( $_POST['billing_phone'] ) ) esc_attr_e( $_POST['billing_phone'] ); ?>" />

   </p>



   <p class="form-row form-row-wide">

     <label for="reg_num"><?php _e( 'MCI Registration Number', 'woocommerce' ); ?><span class="required">*</span></label>

     <input type="text"  required class="input-text" name="reg_num" id="reg_num" value="<?php if ( ! empty( $_POST['reg_num'] ) ) esc_attr_e( $_POST['reg_num'] ); ?>" />

   </p>

   <p class="form-row form-row-wide">

     <label for="Year_of_reg"><?php _e( 'MCI Year of Registration', 'woocommerce' ); ?><span class="required">*</span></label>

     <input type="Number" required class="input-text" name="Year_of_reg" id="Year_of_reg" value="<?php if ( ! empty( $_POST['Year_of_reg'] ) ) esc_attr_e( $_POST['Year_of_reg'] ); ?>" />

   </p>


   <p class="form-row form-row-wide">

     <label for="qualification"><?php _e( 'Qualification', 'woocommerce' ); ?><span class="required">*</span></label>

     <input type="text" required class="input-text" name="qualification" id="qualification" value="<?php if ( ! empty( $_POST['qualification'] ) ) esc_attr_e( $_POST['qualification'] ); ?>" />

   </p>
      <label for="reg_billing_check_box"><?php _e( 'Agree to Terms & Condition', 'woocommerce' ); ?><span class="required">*</span></label>


    <input type="checkbox" class="input-text" name="billink_checkbox" id="reg_billing_first_name" value="&lt;?php if ( ! empty( $_POST['billing_checkbox'] ) ) esc_attr_e( $_POST['billing_checkbox'] ); ?&gt;"/>

1 回答

  • 1

    我猜你有这个代码的注册区域的开始部分

    add_action( 'woocommerce_register_form_start', 'wooc_extra_register_fields' );
    

    您可以使用_end部分,在这种情况下,您的复选框将显示在所有字段之后:

    add_action( 'woocommerce_register_form_end', 'wooc_extra_register_fields' );
    

    要使提交按钮位于底部,请使用此CSS:

    .register .woocommerce-Button {position: absolute !important; bottom: 45px;}
    .register {padding-bottom:70px !important}
    

相关问题