Where to find the select html tag for countries on the checkout page
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
add a comment |
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
Possibly related: magento.stackexchange.com/questions/3682/…
– B00MER
May 12 '14 at 22:53
add a comment |
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
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
magento-1.8 checkout onepage-checkout
asked May 12 '14 at 22:26
laukoklaukok
36651635
36651635
Possibly related: magento.stackexchange.com/questions/3682/…
– B00MER
May 12 '14 at 22:53
add a comment |
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
add a comment |
3 Answers
3
active
oldest
votes
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();
}
add a comment |
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">
Worked perfectly - no need to overwrite core files or create new - spot on!
– Simon
Jan 27 '15 at 8:48
add a comment |
Thanks, it works well - yes no need to overwrite core files or create new
New contributor
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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();
}
add a comment |
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();
}
add a comment |
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();
}
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();
}
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
add a comment |
add a comment |
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">
Worked perfectly - no need to overwrite core files or create new - spot on!
– Simon
Jan 27 '15 at 8:48
add a comment |
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">
Worked perfectly - no need to overwrite core files or create new - spot on!
– Simon
Jan 27 '15 at 8:48
add a comment |
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">
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">
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
add a comment |
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
add a comment |
Thanks, it works well - yes no need to overwrite core files or create new
New contributor
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
add a comment |
Thanks, it works well - yes no need to overwrite core files or create new
New contributor
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
add a comment |
Thanks, it works well - yes no need to overwrite core files or create new
New contributor
Thanks, it works well - yes no need to overwrite core files or create new
New contributor
New contributor
answered 21 mins ago
Phuc Le DiemPhuc Le Diem
1
1
New contributor
New contributor
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Possibly related: magento.stackexchange.com/questions/3682/…
– B00MER
May 12 '14 at 22:53