Where to find the select html tag for countries on the checkout page












3















Where can I the html select tag for countries on the checkout page?



<div class="field form-group">
<label for="billing:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
<div class="input-box">
<?php echo $this->getCountryHtmlSelect('billing') ?>
</div>
</div>


with this $this->getCountryHtmlSelect('billing'), it returns the html select tag below,



<select name="billing[country_id]" id="billing:country_id" class="validate-select" title="Country" >
<option value="" > </option>
<option value="AF" >Afghanistan</option><option value="AL" >Albania</option>
<option value="DZ" >Algeria</option>
...


But I need to add a class name to the select tag,



class="form-control validate-select"


But where can I find this select tag?










share|improve this question























  • Possibly related: magento.stackexchange.com/questions/3682/…

    – B00MER
    May 12 '14 at 22:53
















3















Where can I the html select tag for countries on the checkout page?



<div class="field form-group">
<label for="billing:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
<div class="input-box">
<?php echo $this->getCountryHtmlSelect('billing') ?>
</div>
</div>


with this $this->getCountryHtmlSelect('billing'), it returns the html select tag below,



<select name="billing[country_id]" id="billing:country_id" class="validate-select" title="Country" >
<option value="" > </option>
<option value="AF" >Afghanistan</option><option value="AL" >Albania</option>
<option value="DZ" >Algeria</option>
...


But I need to add a class name to the select tag,



class="form-control validate-select"


But where can I find this select tag?










share|improve this question























  • Possibly related: magento.stackexchange.com/questions/3682/…

    – B00MER
    May 12 '14 at 22:53














3












3








3


1






Where can I the html select tag for countries on the checkout page?



<div class="field form-group">
<label for="billing:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
<div class="input-box">
<?php echo $this->getCountryHtmlSelect('billing') ?>
</div>
</div>


with this $this->getCountryHtmlSelect('billing'), it returns the html select tag below,



<select name="billing[country_id]" id="billing:country_id" class="validate-select" title="Country" >
<option value="" > </option>
<option value="AF" >Afghanistan</option><option value="AL" >Albania</option>
<option value="DZ" >Algeria</option>
...


But I need to add a class name to the select tag,



class="form-control validate-select"


But where can I find this select tag?










share|improve this question














Where can I the html select tag for countries on the checkout page?



<div class="field form-group">
<label for="billing:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
<div class="input-box">
<?php echo $this->getCountryHtmlSelect('billing') ?>
</div>
</div>


with this $this->getCountryHtmlSelect('billing'), it returns the html select tag below,



<select name="billing[country_id]" id="billing:country_id" class="validate-select" title="Country" >
<option value="" > </option>
<option value="AF" >Afghanistan</option><option value="AL" >Albania</option>
<option value="DZ" >Algeria</option>
...


But I need to add a class name to the select tag,



class="form-control validate-select"


But where can I find this select tag?







magento-1.8 checkout onepage-checkout






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 12 '14 at 22:26









laukoklaukok

36651635




36651635













  • Possibly related: magento.stackexchange.com/questions/3682/…

    – B00MER
    May 12 '14 at 22:53



















  • Possibly related: magento.stackexchange.com/questions/3682/…

    – B00MER
    May 12 '14 at 22:53

















Possibly related: magento.stackexchange.com/questions/3682/…

– B00MER
May 12 '14 at 22:53





Possibly related: magento.stackexchange.com/questions/3682/…

– B00MER
May 12 '14 at 22:53










3 Answers
3






active

oldest

votes


















3














The country select box is prepared by the block,



To change its behavior you just need override the function to you local folder like below.



Just copy the coreMageCheckoutBlockOnepageBilling.php to you local folder like



localMageCheckoutBlockOnepageBilling.php



Now you just need to put the below code in that file see I have added the "form-control" to setClass() function.



its done now your class will be added to the select box.



public function getCountryHtmlSelect($type)
{
$countryId = $this->getAddress()->getCountryId();
if (is_null($countryId)) {
$countryId = Mage::helper('core')->getDefaultCountry();
}
$select = $this->getLayout()->createBlock('core/html_select')
->setName($type.'[country_id]')
->setId($type.':country_id')
->setTitle(Mage::helper('checkout')->__('Country'))
->setClass('validate-select form-control')
->setValue($countryId)
->setOptions($this->getCountryOptions());
if ($type === 'shipping') {
$select->setExtraParams('onchange="if(window.shipping)shipping.setSameAsBilling(false);"');
}

return $select->getHtml();
}





share|improve this answer

































    5














    Almost the same as your other question: How to set default shipping method and country?



    Try replacing:



    <?php echo $this->getCountryHtmlSelect('billing') ?>


    With this:



    <?php $_countries = Mage::getResourceModel('directory/country_collection')->loadByStore()->toOptionArray(false) ?>
    <?php if (count($_countries) > 0): ?>
    <select name="billing[country_id]" id="billing:country_id" class="validate-select">
    <option value="">Please choose a country...</option>
    <?php foreach($_countries as $_country): ?>
    <option value="<?php echo $_country['value'] ?>">
    <?php echo $_country['label'] ?>
    </option>
    <?php endforeach; ?>
    </select>
    <?php endif; ?>


    Then all you need to do is add classes to <select name="billing[country_id]" id="billing:country_id" class="validate-select">






    share|improve this answer


























    • Worked perfectly - no need to overwrite core files or create new - spot on!

      – Simon
      Jan 27 '15 at 8:48



















    0














    Thanks, it works well - yes no need to overwrite core files or create new






    share|improve this answer








    New contributor




    Phuc Le Diem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















    • Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review

      – Jai
      2 mins ago











    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%2f19698%2fwhere-to-find-the-select-html-tag-for-countries-on-the-checkout-page%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    The country select box is prepared by the block,



    To change its behavior you just need override the function to you local folder like below.



    Just copy the coreMageCheckoutBlockOnepageBilling.php to you local folder like



    localMageCheckoutBlockOnepageBilling.php



    Now you just need to put the below code in that file see I have added the "form-control" to setClass() function.



    its done now your class will be added to the select box.



    public function getCountryHtmlSelect($type)
    {
    $countryId = $this->getAddress()->getCountryId();
    if (is_null($countryId)) {
    $countryId = Mage::helper('core')->getDefaultCountry();
    }
    $select = $this->getLayout()->createBlock('core/html_select')
    ->setName($type.'[country_id]')
    ->setId($type.':country_id')
    ->setTitle(Mage::helper('checkout')->__('Country'))
    ->setClass('validate-select form-control')
    ->setValue($countryId)
    ->setOptions($this->getCountryOptions());
    if ($type === 'shipping') {
    $select->setExtraParams('onchange="if(window.shipping)shipping.setSameAsBilling(false);"');
    }

    return $select->getHtml();
    }





    share|improve this answer






























      3














      The country select box is prepared by the block,



      To change its behavior you just need override the function to you local folder like below.



      Just copy the coreMageCheckoutBlockOnepageBilling.php to you local folder like



      localMageCheckoutBlockOnepageBilling.php



      Now you just need to put the below code in that file see I have added the "form-control" to setClass() function.



      its done now your class will be added to the select box.



      public function getCountryHtmlSelect($type)
      {
      $countryId = $this->getAddress()->getCountryId();
      if (is_null($countryId)) {
      $countryId = Mage::helper('core')->getDefaultCountry();
      }
      $select = $this->getLayout()->createBlock('core/html_select')
      ->setName($type.'[country_id]')
      ->setId($type.':country_id')
      ->setTitle(Mage::helper('checkout')->__('Country'))
      ->setClass('validate-select form-control')
      ->setValue($countryId)
      ->setOptions($this->getCountryOptions());
      if ($type === 'shipping') {
      $select->setExtraParams('onchange="if(window.shipping)shipping.setSameAsBilling(false);"');
      }

      return $select->getHtml();
      }





      share|improve this answer




























        3












        3








        3







        The country select box is prepared by the block,



        To change its behavior you just need override the function to you local folder like below.



        Just copy the coreMageCheckoutBlockOnepageBilling.php to you local folder like



        localMageCheckoutBlockOnepageBilling.php



        Now you just need to put the below code in that file see I have added the "form-control" to setClass() function.



        its done now your class will be added to the select box.



        public function getCountryHtmlSelect($type)
        {
        $countryId = $this->getAddress()->getCountryId();
        if (is_null($countryId)) {
        $countryId = Mage::helper('core')->getDefaultCountry();
        }
        $select = $this->getLayout()->createBlock('core/html_select')
        ->setName($type.'[country_id]')
        ->setId($type.':country_id')
        ->setTitle(Mage::helper('checkout')->__('Country'))
        ->setClass('validate-select form-control')
        ->setValue($countryId)
        ->setOptions($this->getCountryOptions());
        if ($type === 'shipping') {
        $select->setExtraParams('onchange="if(window.shipping)shipping.setSameAsBilling(false);"');
        }

        return $select->getHtml();
        }





        share|improve this answer















        The country select box is prepared by the block,



        To change its behavior you just need override the function to you local folder like below.



        Just copy the coreMageCheckoutBlockOnepageBilling.php to you local folder like



        localMageCheckoutBlockOnepageBilling.php



        Now you just need to put the below code in that file see I have added the "form-control" to setClass() function.



        its done now your class will be added to the select box.



        public function getCountryHtmlSelect($type)
        {
        $countryId = $this->getAddress()->getCountryId();
        if (is_null($countryId)) {
        $countryId = Mage::helper('core')->getDefaultCountry();
        }
        $select = $this->getLayout()->createBlock('core/html_select')
        ->setName($type.'[country_id]')
        ->setId($type.':country_id')
        ->setTitle(Mage::helper('checkout')->__('Country'))
        ->setClass('validate-select form-control')
        ->setValue($countryId)
        ->setOptions($this->getCountryOptions());
        if ($type === 'shipping') {
        $select->setExtraParams('onchange="if(window.shipping)shipping.setSameAsBilling(false);"');
        }

        return $select->getHtml();
        }






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 13 '14 at 5:13









        Mr_Green

        1,04342647




        1,04342647










        answered May 13 '14 at 5:09









        sandip.vaghasiyasandip.vaghasiya

        611612




        611612

























            5














            Almost the same as your other question: How to set default shipping method and country?



            Try replacing:



            <?php echo $this->getCountryHtmlSelect('billing') ?>


            With this:



            <?php $_countries = Mage::getResourceModel('directory/country_collection')->loadByStore()->toOptionArray(false) ?>
            <?php if (count($_countries) > 0): ?>
            <select name="billing[country_id]" id="billing:country_id" class="validate-select">
            <option value="">Please choose a country...</option>
            <?php foreach($_countries as $_country): ?>
            <option value="<?php echo $_country['value'] ?>">
            <?php echo $_country['label'] ?>
            </option>
            <?php endforeach; ?>
            </select>
            <?php endif; ?>


            Then all you need to do is add classes to <select name="billing[country_id]" id="billing:country_id" class="validate-select">






            share|improve this answer


























            • Worked perfectly - no need to overwrite core files or create new - spot on!

              – Simon
              Jan 27 '15 at 8:48
















            5














            Almost the same as your other question: How to set default shipping method and country?



            Try replacing:



            <?php echo $this->getCountryHtmlSelect('billing') ?>


            With this:



            <?php $_countries = Mage::getResourceModel('directory/country_collection')->loadByStore()->toOptionArray(false) ?>
            <?php if (count($_countries) > 0): ?>
            <select name="billing[country_id]" id="billing:country_id" class="validate-select">
            <option value="">Please choose a country...</option>
            <?php foreach($_countries as $_country): ?>
            <option value="<?php echo $_country['value'] ?>">
            <?php echo $_country['label'] ?>
            </option>
            <?php endforeach; ?>
            </select>
            <?php endif; ?>


            Then all you need to do is add classes to <select name="billing[country_id]" id="billing:country_id" class="validate-select">






            share|improve this answer


























            • Worked perfectly - no need to overwrite core files or create new - spot on!

              – Simon
              Jan 27 '15 at 8:48














            5












            5








            5







            Almost the same as your other question: How to set default shipping method and country?



            Try replacing:



            <?php echo $this->getCountryHtmlSelect('billing') ?>


            With this:



            <?php $_countries = Mage::getResourceModel('directory/country_collection')->loadByStore()->toOptionArray(false) ?>
            <?php if (count($_countries) > 0): ?>
            <select name="billing[country_id]" id="billing:country_id" class="validate-select">
            <option value="">Please choose a country...</option>
            <?php foreach($_countries as $_country): ?>
            <option value="<?php echo $_country['value'] ?>">
            <?php echo $_country['label'] ?>
            </option>
            <?php endforeach; ?>
            </select>
            <?php endif; ?>


            Then all you need to do is add classes to <select name="billing[country_id]" id="billing:country_id" class="validate-select">






            share|improve this answer















            Almost the same as your other question: How to set default shipping method and country?



            Try replacing:



            <?php echo $this->getCountryHtmlSelect('billing') ?>


            With this:



            <?php $_countries = Mage::getResourceModel('directory/country_collection')->loadByStore()->toOptionArray(false) ?>
            <?php if (count($_countries) > 0): ?>
            <select name="billing[country_id]" id="billing:country_id" class="validate-select">
            <option value="">Please choose a country...</option>
            <?php foreach($_countries as $_country): ?>
            <option value="<?php echo $_country['value'] ?>">
            <?php echo $_country['label'] ?>
            </option>
            <?php endforeach; ?>
            </select>
            <?php endif; ?>


            Then all you need to do is add classes to <select name="billing[country_id]" id="billing:country_id" class="validate-select">







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 13 '17 at 12:54









            Community

            1




            1










            answered May 13 '14 at 19:27









            Duke DylanDuke Dylan

            1866




            1866













            • Worked perfectly - no need to overwrite core files or create new - spot on!

              – Simon
              Jan 27 '15 at 8:48



















            • Worked perfectly - no need to overwrite core files or create new - spot on!

              – Simon
              Jan 27 '15 at 8:48

















            Worked perfectly - no need to overwrite core files or create new - spot on!

            – Simon
            Jan 27 '15 at 8:48





            Worked perfectly - no need to overwrite core files or create new - spot on!

            – Simon
            Jan 27 '15 at 8:48











            0














            Thanks, it works well - yes no need to overwrite core files or create new






            share|improve this answer








            New contributor




            Phuc Le Diem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





















            • Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review

              – Jai
              2 mins ago
















            0














            Thanks, it works well - yes no need to overwrite core files or create new






            share|improve this answer








            New contributor




            Phuc Le Diem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





















            • Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review

              – Jai
              2 mins ago














            0












            0








            0







            Thanks, it works well - yes no need to overwrite core files or create new






            share|improve this answer








            New contributor




            Phuc Le Diem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.










            Thanks, it works well - yes no need to overwrite core files or create new







            share|improve this answer








            New contributor




            Phuc Le Diem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            share|improve this answer



            share|improve this answer






            New contributor




            Phuc Le Diem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            answered 21 mins ago









            Phuc Le DiemPhuc Le Diem

            1




            1




            New contributor




            Phuc Le Diem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





            New contributor





            Phuc Le Diem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.






            Phuc Le Diem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.













            • Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review

              – Jai
              2 mins ago



















            • Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review

              – Jai
              2 mins ago

















            Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review

            – Jai
            2 mins ago





            Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review

            – Jai
            2 mins ago


















            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%2f19698%2fwhere-to-find-the-select-html-tag-for-countries-on-the-checkout-page%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

            Magento 2 controller redirect on button click in phtml file

            Polycentropodidae