Jump to content

How to make city field in address page to Dropdown menu with custom options that i give?


Recommended Posts

Please avoid creating duplicate threads ;)

you can edit address.tpl, or order-opc-new-account.tpl if yo uuse that. FInd the field, replace the input type="test" with a select and hardcode your custom values by naming the field as the previous input (same name="....")

  • Like 3
Link to comment
Share on other sites

also modify authentication.tpl because there is city field too

{elseif $field_name eq "city"}
						<p class="required text">
							<label for="city">{l s='City'} <sup>*</sup></label>
							<input type="text" class="text" name="city" id="city" value="{if isset($smarty.post.city)}{$smarty.post.city}{/if}" />
						</p>
  • Like 1
Link to comment
Share on other sites

 

also modify authentication.tpl because there is city field too

{elseif $field_name eq "city"}
						<p class="required text">
							<label for="city">{l s='City'} <sup>*</sup></label>
							<input type="text" class="text" name="city" id="city" value="{if isset($smarty.post.city)}{$smarty.post.city}{/if}" />
						</p>

Thanks.... Nemo1 & Vikia for your Valueable help,....  I have change the files as per your guidence... its working perfectly... Thanks a lot again...

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

I'm also trying to create a drop down menu for cities, but I don't get to fill this menu with the different cities. it's empty. 

I don't know how to set the content of this drop down menu depending on the selected country.

 

the used code is the following:

<p class="required city select">
    <label for="city">{l s='City'} <sup>*</sup></label>
    <select name="city" id="id_city">
	<option value="">-3</option>
    </select>
</p>	

BTW: I modified either address.tpl or authentication.tpl, but I just get a empty drop down menu

 

Thanks in advance!!

  • Like 1
Link to comment
Share on other sites

Just one, concretly Spain.

 

My goal is to get the next structure:

 

- Country

- City

- Town

 

Of this way, When I select a country (only Spain), the drop down for 'City' is filled with the cities of Spain. And when a city is selected, the drop down for 'Town' is filled with the towns of this city.

 

Thanks!!

  • Like 1
Link to comment
Share on other sites

  • 4 months later...

Hi Vekia,

Could you please provide the code to be replaced in both address.tpl and authentication.tpl to make city field as dropdown?

 

I have tried to implement the above steps but left with failed.

 

Currently we offer our services in only one city. We wanted to hardcode the same in our store. we are using PrestaShop 1.6.0.8

 

Thanks in advance.

Link to comment
Share on other sites

  • 2 months later...

Hi all,

 

Dear all prestashop expert.  I'm a beginner without any programming language background.  I'm interested about how Ananth G. solved his problem?  Could someone explain what should we do in our address & authetication.tpl?  I've changed/modify as nemo & vekia said but the city field is still empty without dropdown menu.   I wanna change city as my province, then country as my county, then state become my little town.  Could someone help me please?  Thanks in advance.

Link to comment
Share on other sites

  • 7 months later...

Just one, concretly Spain.

 

My goal is to get the next structure:

 

- Country

- City

- Town

 

Of this way, When I select a country (only Spain), the drop down for 'City' is filled with the cities of Spain. And when a city is selected, the drop down for 'Town' is filled with the towns of this city.

 

Thanks!!

I need the exact thing. Please can anyone give me a hint? Thanks.

Link to comment
Share on other sites

  • 2 weeks later...

It's more complicated than it sounds.
You'd need to add a whole new entity (say, Town), with its own class and separate database table (with an association to the country, and eventually state).
Then, you'd have to modify the template as well

  • Like 1
Link to comment
Share on other sites

 

also modify authentication.tpl because there is city field too

{elseif $field_name eq "city"}
						<p class="required text">
							<label for="city">{l s='City'} <sup>*</sup></label>
							<input type="text" class="text" name="city" id="city" value="{if isset($smarty.post.city)}{$smarty.post.city}{/if}" />
						</p>

 

Greetings Vekia, thanks for your help, how can i make a city drop down that changes values with the state chosen? thhanks!

Link to comment
Share on other sites

  • 7 months later...

Edit this file “order-opc-new-account.tpl”

 

Search for  <label for="city">{l s='City'} <sup>*</sup></label>

 

Add red line like below

 

Comment blue line like below

 

----------CODE--------------

 

<label for="city">{l s='City'} <sup>*</sup></label>

 

<select name="city" id="city" class="form-control">

<option value="Udaipur">Udaipur</option>

</select>



 

{*

<input type="text" class="text form-control validate" name="city" id="city" data-validate="isCityName" value="{if isset($guestInformations) && isset($guestInformations.city) && $guestInformations.city}{$guestInformations.city}{/if}" />

*}

Link to comment
Share on other sites

  • 1 month later...

 

also modify authentication.tpl because there is city field too

{elseif $field_name eq "city"}
						<p class="required text">
							<label for="city">{l s='City'} <sup>*</sup></label>
							<input type="text" class="text" name="city" id="city" value="{if isset($smarty.post.city)}{$smarty.post.city}{/if}" />
						</p>

Why is there city field in authentication.tpl? where is that field in the front page? and there are two other city fields except the one you mentioned should I change these as well?

Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...