Magento 1.4.2 – Make Registration Fields Not Required

I have tried a very commonly used method to make the telephone field not required during registration, but it doesn’t seem to work with Magento 1.4.2

I’ve made a copy of

magento/app/code/core/Mage/Customer/Model/Address/Abstract.php

to

magento/app/code/local/Mage/Customer/Model/Address/Abstract.php

and removed the following code from the validate function in that file

if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
$errors[] = $helper->__('Please enter telephone.');

}

I have also removed the

class="input-text required-entry"

from the register.phtml file, but I can’t get past the validation. I keep getting the error

“Telephone” is a required value.
“Telephone” length must be equal or greater than 1 characters.

Thanks

3 thoughts on “Magento 1.4.2 – Make Registration Fields Not Required”

  1. The default telephone attribute is set to required in the database. See is_required column of eav_attribute table, search for attribute_code = 'telephone'.

    Alternatively you can run this code just once, such as with an install script.

    $telephone = Mage::getModel('eav/entity_attribute')
               ->loadByCode('customer_address', 'telephone')
               ->setIsRequired(false)
               ->save();
    

    Also you have to remove the asterisk * from the from in you template checkoutonepagebilling.phtml

    Change (Line ~120) from

    <label for="billing:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
    

    to

    <label for="billing:telephone"><?php echo $this->__('Telephone') ?></label>
    

    Delete cache to view changes.

  2. There are a few steps to take (version 1.7.0.2).

    1. As mentioned above: change database table eav_attribute. Phpmyadmin is one easy way to do that.

    2. Comment out these 3 lines:

      if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
              $errors[] = Mage::helper('customer')->__('Please enter the telephone number.');
      }
      

      in files:

      • App/code/core/Mage/Customer/Model/Address/Abstract.php
      • includes/src/Mage_Customer_Model_Address_Abstract.php
      • includes/src/_checkout.php
    3. You can also remove the * in the register.phtml and billing.phtml files in the onepage folders of the app/design/frontend/base/default/template/persistent and app/design/frontend/base/default/template/customer folders.

    Make no mistake, Magento REALLY wanted to make that a required entry!

    That should do it.

  3. I am aware of all the suggested solutions of copying and editing core-files but this will be upgrade-suicide.

    For now (Magento 1.9 and older) the only method that does not require modifying Magento core files is to use a dummy value for the telephone field.

    A simple mock-up solution is to add to the bottom of the ‘address/edit.phtml’ file:

    jQuery(function($){
        $('#form-validate').submit(function(){
            var telephone = $('#telephone');
            if( !telephone.val().length )
                telephone.val("<?= $this->__('Not supplied') ?>");
        });
    });
    

Leave a Reply

Your email address will not be published. Required fields are marked *