在注册表格woocommerce中编辑字段类型

时间:2016-06-13 13:59:45

标签: javascript php html wordpress woocommerce


我使用以下代码to add custom fields in user registration on the "My Account" page使用woocommerce,它成功运行,但现在我想更改一个字段的类型显示为select以仅显示3状态:
- 巴黎,
- 伦敦
- 阿尔及尔
如何编辑此代码:

<p class="form-row form-row-last">
    <label for="reg_billing_state"><?php _e( 'State', 'woocommerce' ); ?> <span class="required">*</span></label>
    <input type="text" class="input-text" name="billing_state" id="reg_billing_state" value="<?php if ( ! empty( $_POST['billing_state'] ) ) esc_attr_e( $_POST['billing_state'] ); ?>" />

    </p>

我试过这个,但它不起作用!

<p class="form-row form-row-last">
    <label for="reg_billing_state"><?php _e( 'Commune', 'woocommerce' ); ?> <span class="required">*</span></label>
    <input  list="states" class="input-text" name="billing_state" id="reg_billing_state" value="<?php if ( ! empty( $_POST['billing_state'] ) ) esc_attr_e( $_POST['billing_state'] ); ?>" />
    <datalist id="states">
    <option value="Paris">
    <option value="London">
    <option value="Algiers">
  </datalist> 
    </p>

先谢谢你了!

1 个答案:

答案 0 :(得分:0)

<强>解决
我现在找到的解决方案如下:

<p class="form-row form-row-last">
    <label for="reg_billing_state"><?php _e( 'Commune', 'woocommerce' ); ?> <span class="required">*</span></label>
    <select id="reg_billing_state" class="input-text" name="billing_state">
        <option value="Alger">Alger</option>
        <option value="Zeralda">Zeralda</option>
        <option value="Beni Messous">Beni Messous</option>
    </select>
</p>
相关问题