Edit type of field in registration form woocommerce

I use the following code to add custom fields in user registration on the “My Account” page using woocommerce,it worked succesfully, but now i want to change the type of one fields be displayed as a select to display only 3 state:
– Paris,
– London
– Algiers
So how can I edit this code:

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

I have tried this but it doesn’t work!

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

Thank you in advanced!

Related posts

Leave a Reply

1 comment

  1. Solved
    The solution I found for now is the following:

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