Magento: Removing mandatory validation of telephone field

Searching the web for ways to remove the mandatory validation of the telephone field in Magento I found quite a lot results non of which actually worked with Magento ver. or up. The biggest problem seems to be to completely remove the validation and mandatory state of the telephone field throughout the whole Magento store. Some solutions fixed it in the checkout, some fixed the client side validation but not a single solution fixed it all.

The final solution contains three steps which are:

1. Remove client-side (javascript) validation

If they not already exist within your theme copy the following files from the base/default theme to your theme:

  • template/customer/address/edit.phtml
  • template/checkout/onepage/shipping.phtml
  • template/checkout/onepage/billing.phtml

In each of these files, look for the <input> that defines the telephone field and remove the required class from the label, remove the required-attribute class from the input and make sure to remove the *.

2. Redefine the Mage_Customer_Model_Address_Abstract class

Copy the file app/code/core/Mage/Customer/Model/Address/Abstract.php to app/code/local/Mage/Customer/Model/Address/Abstract.php . This ensures that upgrades will not break your modifications. Now open the file and look for the part where it validates the telephone field, it should look something like this:

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

You can either completely remove this part or comment it out by placing it between /* and */ .

3. Change the Customer EAV in the database

Except for the validation we just removed in the abstract class Magento keeps a validation definition in it’s EAV tables. In the table customer_eav_attribute look for the row with id attribute_id 30 and clear the contents of the column validation_rules. Next in the table eav_attribute loo for the row with attribute_id 30 and make sure that the value of the column is_required is 0.

Completing the above steps will effectively clear the validation and the mandatory state of the Telephone field.