Add default value to City field in Billing and Shipping The 2019 Stack Overflow Developer Survey Results Are InCreate a Store Config value, its not saved and unable to retrieve the value“State” field in checkout billing and shipping forms not displayingChanging City in Shipping to Drop Down optionsgrab fields from billing checkoutpageHow to hide or remove state/province field from billing pageCannot remove telephone and region/province from billing information on checkoutCity value validation fails in onepage checkout only“Phone” is a required value on Guest CheckoutOnepage Checkout Variable ErrorAdd Customer Note (comments) on billing Address and Save it

Can someone be penalized for an "unlawful" act if no penalty is specified?

What is the closest word meaning "respect for time / mindful"

Why isn't the circumferential light around the M87 black hole's event horizon symmetric?

Why did Acorn's A3000 have red function keys?

How to type this arrow in math mode?

Why is the Constellation's nose gear so long?

Have you ever entered Singapore using a different passport or name?

What do the Banks children have against barley water?

Did Section 31 appear in Star Trek: The Next Generation?

FPGA - DIY Programming

What is the meaning of Triage in Cybersec world?

What is the accessibility of a package's `Private` context variables?

Who coined the term "madman theory"?

Why not take a picture of a closer black hole?

Return to UK after having been refused entry years ago

Does coating your armor in silver add any effects?

Resizing object distorts it (Illustrator CC 2018)

Why isn't airport relocation done gradually?

Can one be advised by a professor who is very far away?

How to answer pointed "are you quitting" questioning when I don't want them to suspect

What is the motivation for a law requiring 2 parties to consent for recording a conversation

What does Linus Torvalds mean when he says that Git "never ever" tracks a file?

Right tool to dig six foot holes?

What is the meaning of the verb "bear" in this context?



Add default value to City field in Billing and Shipping



The 2019 Stack Overflow Developer Survey Results Are InCreate a Store Config value, its not saved and unable to retrieve the value“State” field in checkout billing and shipping forms not displayingChanging City in Shipping to Drop Down optionsgrab fields from billing checkoutpageHow to hide or remove state/province field from billing pageCannot remove telephone and region/province from billing information on checkoutCity value validation fails in onepage checkout only“Phone” is a required value on Guest CheckoutOnepage Checkout Variable ErrorAdd Customer Note (comments) on billing Address and Save it



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Just like there is a default value for 'State/Province' field which is: 'Please select region, state or province' I need to add a default value to City field in billing and shipping steps in checkout.
In my case the City is drop-down list getting its list of cities from database.



In app>design>frontend>base>default>template>checkout>onepage>billing.phtml, the city field code is:



<div class="field">
<label for="billing:city" class="required"><em>*</em><?php echo $this->__('City') ?>
</label>

<div class="input-box">
<input type="text" title="<?php echo $this->__('City') ?>"
name="billing[city]"
value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>"
id="billing:city"/>
</div>
</div>









share|improve this question
















bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • I don't see any dropdown (ex: <select>) in your code.

    – Adarsh Khatri
    Aug 21 '15 at 6:43

















1















Just like there is a default value for 'State/Province' field which is: 'Please select region, state or province' I need to add a default value to City field in billing and shipping steps in checkout.
In my case the City is drop-down list getting its list of cities from database.



In app>design>frontend>base>default>template>checkout>onepage>billing.phtml, the city field code is:



<div class="field">
<label for="billing:city" class="required"><em>*</em><?php echo $this->__('City') ?>
</label>

<div class="input-box">
<input type="text" title="<?php echo $this->__('City') ?>"
name="billing[city]"
value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>"
id="billing:city"/>
</div>
</div>









share|improve this question
















bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • I don't see any dropdown (ex: <select>) in your code.

    – Adarsh Khatri
    Aug 21 '15 at 6:43













1












1








1








Just like there is a default value for 'State/Province' field which is: 'Please select region, state or province' I need to add a default value to City field in billing and shipping steps in checkout.
In my case the City is drop-down list getting its list of cities from database.



In app>design>frontend>base>default>template>checkout>onepage>billing.phtml, the city field code is:



<div class="field">
<label for="billing:city" class="required"><em>*</em><?php echo $this->__('City') ?>
</label>

<div class="input-box">
<input type="text" title="<?php echo $this->__('City') ?>"
name="billing[city]"
value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>"
id="billing:city"/>
</div>
</div>









share|improve this question
















Just like there is a default value for 'State/Province' field which is: 'Please select region, state or province' I need to add a default value to City field in billing and shipping steps in checkout.
In my case the City is drop-down list getting its list of cities from database.



In app>design>frontend>base>default>template>checkout>onepage>billing.phtml, the city field code is:



<div class="field">
<label for="billing:city" class="required"><em>*</em><?php echo $this->__('City') ?>
</label>

<div class="input-box">
<input type="text" title="<?php echo $this->__('City') ?>"
name="billing[city]"
value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>"
id="billing:city"/>
</div>
</div>






magento-1.9 drop-downs default-values






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 '17 at 10:32









Teja Bhagavan Kollepara

2,98841949




2,98841949










asked Aug 21 '15 at 6:24









Tallal HassanTallal Hassan

158214




158214





bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • I don't see any dropdown (ex: <select>) in your code.

    – Adarsh Khatri
    Aug 21 '15 at 6:43

















  • I don't see any dropdown (ex: <select>) in your code.

    – Adarsh Khatri
    Aug 21 '15 at 6:43
















I don't see any dropdown (ex: <select>) in your code.

– Adarsh Khatri
Aug 21 '15 at 6:43





I don't see any dropdown (ex: <select>) in your code.

– Adarsh Khatri
Aug 21 '15 at 6:43










2 Answers
2






active

oldest

votes


















0














If I understand you, you want to force your users to have default value on city section then change this:



value="<?php echo "your city name"; //$this->escapeHtml($this->getAddress()->getCity()) ?>" 


This will make default city on city field.



PS



By default Magento pools city data for registered customer from database using $this->escapeHtml($this->getAddress()->getCity()) function.



So when you change this, it will never pool that data.






share|improve this answer























  • Let me check this.Please note that i am using an extension for drop-down city list so I will edit the extension's billing.phtml and shipping.phtml files.Does that too would pose issue to pool data for registered customers if i follow your answer?

    – Tallal Hassan
    Aug 21 '15 at 6:41












  • Yes, every extension I believe are written magento way.

    – Adarsh Khatri
    Aug 21 '15 at 6:42











  • Your answer works.But there is already an empty space at the top of drop-down city list i want that space be taken up by default value.If possible please take a few seconds to check my site www.apollo-sports.com.pk/magento select any product and go to check out to see what there in billing.please?First select country Romania and then the first State and then cities will appear

    – Tallal Hassan
    Aug 21 '15 at 6:47



















0














If like the state/province you just want to show what is effectively help text, I suggest you add a placeholder attribute to the input box. So something like...



<<input type="text" title="<?php echo $this->__('City') ?>" 
name="billing[city]"
value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>"
id="billing:city"
placeholder="<?php echo $this->__('Please enter city'); ?>"/>


Then if they empty the value out the placeholder text will appear again.



Regards,
Andy






share|improve this answer























  • Hi I tried your way but the placeholder text disappears upon selecting any country and / or State :(

    – Tallal Hassan
    Aug 21 '15 at 6:58











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f79428%2fadd-default-value-to-city-field-in-billing-and-shipping%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














If I understand you, you want to force your users to have default value on city section then change this:



value="<?php echo "your city name"; //$this->escapeHtml($this->getAddress()->getCity()) ?>" 


This will make default city on city field.



PS



By default Magento pools city data for registered customer from database using $this->escapeHtml($this->getAddress()->getCity()) function.



So when you change this, it will never pool that data.






share|improve this answer























  • Let me check this.Please note that i am using an extension for drop-down city list so I will edit the extension's billing.phtml and shipping.phtml files.Does that too would pose issue to pool data for registered customers if i follow your answer?

    – Tallal Hassan
    Aug 21 '15 at 6:41












  • Yes, every extension I believe are written magento way.

    – Adarsh Khatri
    Aug 21 '15 at 6:42











  • Your answer works.But there is already an empty space at the top of drop-down city list i want that space be taken up by default value.If possible please take a few seconds to check my site www.apollo-sports.com.pk/magento select any product and go to check out to see what there in billing.please?First select country Romania and then the first State and then cities will appear

    – Tallal Hassan
    Aug 21 '15 at 6:47
















0














If I understand you, you want to force your users to have default value on city section then change this:



value="<?php echo "your city name"; //$this->escapeHtml($this->getAddress()->getCity()) ?>" 


This will make default city on city field.



PS



By default Magento pools city data for registered customer from database using $this->escapeHtml($this->getAddress()->getCity()) function.



So when you change this, it will never pool that data.






share|improve this answer























  • Let me check this.Please note that i am using an extension for drop-down city list so I will edit the extension's billing.phtml and shipping.phtml files.Does that too would pose issue to pool data for registered customers if i follow your answer?

    – Tallal Hassan
    Aug 21 '15 at 6:41












  • Yes, every extension I believe are written magento way.

    – Adarsh Khatri
    Aug 21 '15 at 6:42











  • Your answer works.But there is already an empty space at the top of drop-down city list i want that space be taken up by default value.If possible please take a few seconds to check my site www.apollo-sports.com.pk/magento select any product and go to check out to see what there in billing.please?First select country Romania and then the first State and then cities will appear

    – Tallal Hassan
    Aug 21 '15 at 6:47














0












0








0







If I understand you, you want to force your users to have default value on city section then change this:



value="<?php echo "your city name"; //$this->escapeHtml($this->getAddress()->getCity()) ?>" 


This will make default city on city field.



PS



By default Magento pools city data for registered customer from database using $this->escapeHtml($this->getAddress()->getCity()) function.



So when you change this, it will never pool that data.






share|improve this answer













If I understand you, you want to force your users to have default value on city section then change this:



value="<?php echo "your city name"; //$this->escapeHtml($this->getAddress()->getCity()) ?>" 


This will make default city on city field.



PS



By default Magento pools city data for registered customer from database using $this->escapeHtml($this->getAddress()->getCity()) function.



So when you change this, it will never pool that data.







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 21 '15 at 6:36









Adarsh KhatriAdarsh Khatri

6,78511644




6,78511644












  • Let me check this.Please note that i am using an extension for drop-down city list so I will edit the extension's billing.phtml and shipping.phtml files.Does that too would pose issue to pool data for registered customers if i follow your answer?

    – Tallal Hassan
    Aug 21 '15 at 6:41












  • Yes, every extension I believe are written magento way.

    – Adarsh Khatri
    Aug 21 '15 at 6:42











  • Your answer works.But there is already an empty space at the top of drop-down city list i want that space be taken up by default value.If possible please take a few seconds to check my site www.apollo-sports.com.pk/magento select any product and go to check out to see what there in billing.please?First select country Romania and then the first State and then cities will appear

    – Tallal Hassan
    Aug 21 '15 at 6:47


















  • Let me check this.Please note that i am using an extension for drop-down city list so I will edit the extension's billing.phtml and shipping.phtml files.Does that too would pose issue to pool data for registered customers if i follow your answer?

    – Tallal Hassan
    Aug 21 '15 at 6:41












  • Yes, every extension I believe are written magento way.

    – Adarsh Khatri
    Aug 21 '15 at 6:42











  • Your answer works.But there is already an empty space at the top of drop-down city list i want that space be taken up by default value.If possible please take a few seconds to check my site www.apollo-sports.com.pk/magento select any product and go to check out to see what there in billing.please?First select country Romania and then the first State and then cities will appear

    – Tallal Hassan
    Aug 21 '15 at 6:47

















Let me check this.Please note that i am using an extension for drop-down city list so I will edit the extension's billing.phtml and shipping.phtml files.Does that too would pose issue to pool data for registered customers if i follow your answer?

– Tallal Hassan
Aug 21 '15 at 6:41






Let me check this.Please note that i am using an extension for drop-down city list so I will edit the extension's billing.phtml and shipping.phtml files.Does that too would pose issue to pool data for registered customers if i follow your answer?

– Tallal Hassan
Aug 21 '15 at 6:41














Yes, every extension I believe are written magento way.

– Adarsh Khatri
Aug 21 '15 at 6:42





Yes, every extension I believe are written magento way.

– Adarsh Khatri
Aug 21 '15 at 6:42













Your answer works.But there is already an empty space at the top of drop-down city list i want that space be taken up by default value.If possible please take a few seconds to check my site www.apollo-sports.com.pk/magento select any product and go to check out to see what there in billing.please?First select country Romania and then the first State and then cities will appear

– Tallal Hassan
Aug 21 '15 at 6:47






Your answer works.But there is already an empty space at the top of drop-down city list i want that space be taken up by default value.If possible please take a few seconds to check my site www.apollo-sports.com.pk/magento select any product and go to check out to see what there in billing.please?First select country Romania and then the first State and then cities will appear

– Tallal Hassan
Aug 21 '15 at 6:47














0














If like the state/province you just want to show what is effectively help text, I suggest you add a placeholder attribute to the input box. So something like...



<<input type="text" title="<?php echo $this->__('City') ?>" 
name="billing[city]"
value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>"
id="billing:city"
placeholder="<?php echo $this->__('Please enter city'); ?>"/>


Then if they empty the value out the placeholder text will appear again.



Regards,
Andy






share|improve this answer























  • Hi I tried your way but the placeholder text disappears upon selecting any country and / or State :(

    – Tallal Hassan
    Aug 21 '15 at 6:58















0














If like the state/province you just want to show what is effectively help text, I suggest you add a placeholder attribute to the input box. So something like...



<<input type="text" title="<?php echo $this->__('City') ?>" 
name="billing[city]"
value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>"
id="billing:city"
placeholder="<?php echo $this->__('Please enter city'); ?>"/>


Then if they empty the value out the placeholder text will appear again.



Regards,
Andy






share|improve this answer























  • Hi I tried your way but the placeholder text disappears upon selecting any country and / or State :(

    – Tallal Hassan
    Aug 21 '15 at 6:58













0












0








0







If like the state/province you just want to show what is effectively help text, I suggest you add a placeholder attribute to the input box. So something like...



<<input type="text" title="<?php echo $this->__('City') ?>" 
name="billing[city]"
value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>"
id="billing:city"
placeholder="<?php echo $this->__('Please enter city'); ?>"/>


Then if they empty the value out the placeholder text will appear again.



Regards,
Andy






share|improve this answer













If like the state/province you just want to show what is effectively help text, I suggest you add a placeholder attribute to the input box. So something like...



<<input type="text" title="<?php echo $this->__('City') ?>" 
name="billing[city]"
value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>"
id="billing:city"
placeholder="<?php echo $this->__('Please enter city'); ?>"/>


Then if they empty the value out the placeholder text will appear again.



Regards,
Andy







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 21 '15 at 6:45









SmartieSmartie

2,8201727




2,8201727












  • Hi I tried your way but the placeholder text disappears upon selecting any country and / or State :(

    – Tallal Hassan
    Aug 21 '15 at 6:58

















  • Hi I tried your way but the placeholder text disappears upon selecting any country and / or State :(

    – Tallal Hassan
    Aug 21 '15 at 6:58
















Hi I tried your way but the placeholder text disappears upon selecting any country and / or State :(

– Tallal Hassan
Aug 21 '15 at 6:58





Hi I tried your way but the placeholder text disappears upon selecting any country and / or State :(

– Tallal Hassan
Aug 21 '15 at 6:58

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f79428%2fadd-default-value-to-city-field-in-billing-and-shipping%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

منجزی محتویات تیره‌های طایفه منجزی[ویرایش] مشاهیر طایفه منجزی[ویرایش] محل سکونت[ویرایش] پانویس[ویرایش] منابع[ویرایش] منوی ناوبری«نمودار اجتماعی طوایف بختیاری»«BakhtyārBAḴTĪĀRĪ TRIBE»«اسامی طوایف و شعب ایل بختیاری»ووگسترش آن

بیوانفورماتیک محتویات تاریخچه[ویرایش] اهداف[ویرایش] کاربردهای بیوانفورماتیک[ویرایش] زمینه‌های مهم بیوانفورماتیک[ویرایش] موضوعات سیستم نرم‌افزاری بیوانفورماتیک[ویرایش] مراکز و ابزار[ویرایش] جستارهای وابسته[ویرایش] پیوند به بیرون[ویرایش] منابع[ویرایش] منوی ناوبریووانجمن بیوانفورماتیک ایرانمرکز بیوانفورماتیک دانشگاه تهرانمرکز ملی تحقیقات بیوانفورماتیکانستیتو بیو-آی‌تیبانک داده‌های دی ان ایمرکز ملی اطلاعات بیوتکنولوژیانستیتوی بیوانفورماتیک اروپاپورتال بیوانفورماتیک ایران«فرهنگ واژه‌های مصوب فرهنگستان ـ دفتر هشتم، بخش لاتین»وووو4611085-900870420ووو