Magento - Making the telephone field not required at checkout

Out of the box, the Magento checkout process requires users to enter a telephone number for both billing and shipping addresses. If your business doesn't have this requirement, you may want to remove this validation from one or both address forms. The steps below will remove the telephone requirement on the shipping address form during checkout. This has been tested with Magento Community Edition 1.7.0.1.

Step 1

The first step is to modify the one page checkout templates for the address form(s) in which you want to remove the telephone requirement. The shipping address form is located here: /app/design/frontend/base/default/template/checkout/onepage/shipping.phtml DO NOT modify the base template file directly. Instead, copy this file into your site's own theme and make your modifications there. Base template files can be overwritten during Magento upgrades, so if you modify these files directly, you'll probably loose all of your work! Open your copy of shipping.phtml and look for the line:

<label for="shipping:telephone" class="required"><?php echo $this->__('Telephone') ?></label>
Replace it with (remove required class):
<label for="shipping:telephone"><?php echo $this->__('Telephone') ?></label>
Next, look for the line:
<input type="text" name="shipping[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="shipping:telephone" onchange="shipping.setSameAsBilling(false);" />
And replace it with (comment out echo):
<input type="text" name="shipping[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php //echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="shipping:telephone" onchange="shipping.setSameAsBilling(false);" />
That's it. Save your new template file.

Step 2

Next, we need to modify the Magento Customer Address class to comment out some validation code. The code is located in an abstract class, so we can't override it. Instead, we'll make a copy of the file in the /app/code/local, which Magento will find and use instead of the core file. Copy the file: /app/code/core/Mage/Customer/Model/Address/Abstract.php To: /app/code/local/Mage/Customer/Model/Address/Abstract.php NOTE: You'll likely have to create the proper folder under /app/code/local. Now, open /app/code/local/Mage/Customer/Model/Address/Abstract.php and on line 375 find the following code:

if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
        $errors[] = Mage::helper('customer')->__('Please enter the telephone number.');
}
Replace the above code with (comment out the entire block):
/*
        // Disable telephone field validation
        if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
            $errors[] = Mage::helper('customer')->__('Please enter the telephone number.');
        }
*/
Save your modified Abstract.php file and proceed to the next step.

Step 3

Some of Magento's field validation logic is determined by the configuration of EAV attribute values, so we'll need to update a few rows in the Magento database. You'll need to make two small edits:

  1. Open the table eav_attribute and search for the row with attribute_code = "telephone". Make note of the attribute_id of this row. Next, set the column is_required to 0 (zero).
  2. Now, open the table customer_eav_attribute and search for the row with the same attribute_id as you noted in the previous step. Set the column validation_rules on this row to NULL.

Step 4

Finally, you'll need to clear all of Magento's caches so that your changes take effect. In the Magento admin, got to System -> Cache Management, and clear all caches. Make sure to click the 'Flush Magento Cache' and 'Flush Cache Storage' buttons as well. This will force Magento to take note of your database changes.

Wrap Up

That's it! When entering a new shipping address at checkout, Magento should no longer require a value for telephone. If you have any suggestions for improving these steps, please leave a comment below.

17 thoughts on “Magento - Making the telephone field not required at checkout”

  • ilia

    Thanks, this helped. Just 2 notes about the difficulty i have faced:
    1 make sure your ftp manager has copied Abstract.php with exact name (starting from capital A, not just abstract.php)
    2 better delete lines - just commenting didn't work for me

    Reply
  • Pwaap

    Thanks!

    A clear and relativly easy way to fix this problem. I was able to completely remove the telephone field.

    Reply
  • Ryan

    How would this be achieved if I just wanted to remove the validation on shipping not billing.

    Reply
  • Ian Baxter

    Ryan,

    This should only remove the validation on the shipping address. In your implementation, is this removing validation on the billing address as well?

    Reply
  • roger

    This is only removing the validation for the phone number on the shipping address. I would like to also remove the validation for the billing address as well.

    Reply
  • Adrian

    Thanks! Worked perfectly (CE 1.7)

    Reply
  • apamix

    Validation seems to have moved over to app/code/core/Mage/Eav/Model/Form.php

    Around line 390, you can find the familiar:

    $result = $dataModel->validateValue($data[$attribute->getAttributeCode()]);

    Replace it with
    if($attribute->getAttributeCode()!='telephone') {
    $result = $dataModel->validateValue($data[$attribute->getAttributeCode()]);
    }

    and things should be ok (tested in Version 1.7.0.2)

    Reply
  • Mark

    Brilliant! I have been looking for a solution to what should be a simple issue for ages and this is the only one that actually worked for me! Kudos to you! Thank you very much!

    Reply
  • ewall

    Thanks ....

    Reply
  • jumping-blueberry
    jumping-blueberry November 17, 2013 at 8:41 pm

    As of version 1.8 Step one was enough to remove the validation.
    I think it's not how the creators of Magento meant it to work... but it's the easiest way for me.

    Validation seems to be done primarily with javascript which means changing the HTML is enough...
    The steps 2-3 aim to changing the output that has already been disabled in Step 1.

    Step 3 was not available in Version 1.8 anyways

    However, thanks for the tips

    Reply
  • jumping-blueberry
    jumping-blueberry November 17, 2013 at 10:16 pm

    forget (don't publish) my comments.
    I was wrong... it all works exactly the way you suggested

    Reply
  • Vsevolod

    $installer->updateAttribute('customer','telephone','is_required',0)

    Reply
  • jess

    Thank you. worked perfectly. I just had to follow the same steps for the billing section.

    Reply
  • Rania

    Thanks heaps

    Reply
  • Maha

    Very useful.. Thanks!

    Reply
  • Greg

    I'm completely new to Magento, and I don't have much hard core programming knowledge of this stuff.

    I'm stuck on STEP 3.

    How do I open this database? And where is it located?

    Reply
Leave a Reply