2016-06-13 94 views
1


我使用下面的代碼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

解決
我發現現在的解決方案是:

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