I am unable to place order from admin. I enter all the data in required field. When I place order, error showing in the City field - this is a required field. I am using magento 1.9.3.7 version
can anyone help me to resolve this issue?
I am unable to place order from admin. I enter all the data in required field. When I place order, error showing in the City field - this is a required field. I am using magento 1.9.3.7 version
can anyone help me to resolve this issue?
Try this:
You need to change in some file for this:
In this app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Customer/Edit/Renderer/City.php
file, you need to update some code, you can either override or update in this file because this is a bug:
Current public function render
function :
public function render(Varien_Data_Form_Element_Abstract $element)
{
$country = $element->getForm()->getElement('country_id');
$region = $element->getForm()->getElement('region_id');
if (!is_null($region)) {
$regionId = $region->getValue();
} else {
return $element->getDefaultHtml();
}
$cityId = $element->getForm()->getElement('city_id')->getValue();
$quoteStoreId = $element->getEntityAttribute()->getStoreId();
$html = '<tr>';
$element->setClass('input-text');
$element->setRequired(true);
$html .= '<td class="label">' . $element->getLabelHtml() . '</td><td class="value">';
$html .= $element->getElementHtml();
$selectName = str_replace('city', 'city_id', $element->getName());
$selectId = $element->getHtmlId() . '_id';
$html .= '<select id="' . $selectId . '" name="' . $selectName
. '" class="select required-entry" style="display:none">';
$html .= '<option value="">' . $this->_factory->getHelper('customer')->__('Please select') . '</option>';
$html .= '</select>';
$html .= '<script type="text/javascript">' . "\n";
$html .= '$("' . $selectId . '").setAttribute("defaultValue", "' . $cityId.'");' . "\n";
$html .= 'new CityUpdater("' . $country->getHtmlId() . '", "' . $region->getHtmlId() . '", "' . $element->getHtmlId() . '", "' .
$selectId . '", ' . Mage::helper('improvedaddress')->getCityJson().');' . "\n";
$html .= '</script>' . "\n";
$html .= '</td></tr>' . "\n";
return $html;
}
Update public function render
function :
public function render(Varien_Data_Form_Element_Abstract $element)
{
$country = $element->getForm()->getElement('country_id');
$region = $element->getForm()->getElement('region_id');
if (!is_null($region)) {
$regionId = $region->getValue();
} else {
return $element->getDefaultHtml();
}
$cityId = $element->getForm()->getElement('city_id')->getValue();
$quoteStoreId = $element->getEntityAttribute()->getStoreId();
$html = '<tr>';
$element->setClass('input-text');
$element->setRequired(true);
$html .= '<td class="label">' . $element->getLabelHtml() . '</td><td class="value">';
$html .= $element->getElementHtml();
$selectName = str_replace('city', 'city_id', $element->getName());
$selectId = $element->getHtmlId() . '_id';
$html .= '<select id="' . $selectId . '" name="' . $selectName
. '" class="select required-entry" style="display:none" disabled="disabled">';
$html .= '<option value="">' . $this->_factory->getHelper('customer')->__('Please select') . '</option>';
$html .= '</select>';
$html .= '<script type="text/javascript">' . "\n";
$html .= '$("' . $selectId . '").setAttribute("defaultValue", "' . $cityId.'");' . "\n";
$html .= 'new CityUpdater("' . $country->getHtmlId() . '", "' . $region->getHtmlId() . '", "' . $element->getHtmlId() . '", "' .
$selectId . '", ' . Mage::helper('improvedaddress')->getCityJson().');' . "\n";
$html .= '</script>' . "\n";
$html .= '</td></tr>' . "\n";
return $html;
}
I have updated this code from $html .= '<select id="' . $selectId . '" name="' . $selectName
. '" class="select required-entry" style="display:none">';
To $html .= '<select id="' . $selectId . '" name="' . $selectName
. '" class="select required-entry" style="display:none" disabled="disabled">';
in that function.
Now you need to update this js/magebuzz/improvedaddress.js
file in update: function() {
function :
Current code in that JS:
update: function() {
if (this.cities[this.regionEl.value]) {
var i, option, city, def;
def = this.citySelectEl.getAttribute('defaultValue');
if (this.cityTextEl) {
if (!def) {
def = this.cityTextEl.value.toLowerCase();
}
////need to comment this to avoid issue when saving address without touching city field
//this.cityTextEl.value = '';
}
this.citySelectEl.options.length = 1;
for (cityId in this.cities[this.regionEl.value]) {
city = this.cities[this.regionEl.value][cityId];
option = document.createElement('OPTION');
option.value = city.code;
option.text = city.name.stripTags();
option.title = city.name;
if (this.citySelectEl.options.add) {
this.citySelectEl.options.add(option);
} else {
this.citySelectEl.appendChild(option);
}
if (cityId==def || (city.name && city.name==def) ||
(city.name && city.code.toLowerCase()==def)
) {
this.citySelectEl.value = city.code;
}
}
if (this.cityTextEl) {
this.cityTextEl.style.display = 'none';
}
this.citySelectEl.style.display = '';
}
else {
this.citySelectEl.options.length = 1;
if (this.cityTextEl) {
this.cityTextEl.style.display = '';
}
this.citySelectEl.style.display = 'none';
Validation.reset(this.citySelectEl);
}
}
Updated that update
function:
update: function() {
if (this.cities[this.regionEl.value]) {
var i, option, city, def;
def = this.citySelectEl.getAttribute('defaultValue');
if (this.cityTextEl) {
if (!def) {
def = this.cityTextEl.value.toLowerCase();
}
////need to comment this to avoid issue when saving address without touching city field
//this.cityTextEl.value = '';
}
this.citySelectEl.options.length = 1;
for (cityId in this.cities[this.regionEl.value]) {
city = this.cities[this.regionEl.value][cityId];
option = document.createElement('OPTION');
option.value = city.code;
option.text = city.name.stripTags();
option.title = city.name;
if (this.citySelectEl.options.add) {
this.citySelectEl.options.add(option);
} else {
this.citySelectEl.appendChild(option);
}
if (cityId==def || (city.name && city.name==def) ||
(city.name && city.code.toLowerCase()==def)
) {
this.citySelectEl.value = city.code;
}
}
if (this.cityTextEl) {
this.cityTextEl.style.display = 'none';
}
this.citySelectEl.style.display = '';
this.citySelectEl.disabled = '';
}
else {
this.citySelectEl.options.length = 1;
if (this.cityTextEl) {
this.cityTextEl.style.display = '';
}
this.citySelectEl.disabled = true;
this.citySelectEl.style.display = 'none';
Validation.reset(this.citySelectEl);
}
}
After the changes, it will disable that select so you can submit form without hidden fields validation. Let me know you face any issue related to this.