我使用以下代码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>
先谢谢你了!
答案 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>