cancel
Showing results for 
Search instead for 
Did you mean: 

Make street address optional

Make street address optional

HELP NEEDED!!!

I'm working on a project using magento 1.9.3.1 and I need to make the street address optional  since my country lacks formal addresses. I tried editing the billing.phtml file from app/design/frontend/base/default/template/checkout/onepage/billing.phtml like this:

 

<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
<li class="wide" style="display:none">
<label for="billing:street1" class="required"><em>*</em><?php echo $this->__('Address') ?></label>
<div class="input-box">
<input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address')) ?>" name="billing[street][]" id="billing:street1" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
</div>
</li>

 

from a forum but its not working. Any help is welcome as I am on a deadline.

1 REPLY

Re: Make street address optional

1)First Update the customer attribute street to required false
 
$installer->startSetup();
 
$installer->updateAttribute('customer_address', 'street', 'required', false);  
 
$installer->endSetup();
 
2)After that you need to remove the backend validation for street address which lies in file /app/code/local/Mage/customer/Model/Address/Abstract.php:
 
check for function _basicCheck() which has validation for street
 protected function _basicCheck(){
 if (!Zend_Validate::is($this->getStreet(1), 'NotEmpty')) {
            $this->addError(Mage::helper('customer')->__('Please enter the street.'));
        }
}
 
remove or comment the above validation by overwriting the file ,then your Street address will be optional during checkout