Knowledgebase
How to remove the phone field from the checkout or make it optional in Magento
When customers, whether registered or guests, want to order something from your store and proceed to the checkout, by default they are required to provide a telephone number at the billing information step (and at the shipping information step in case the customer wants to specify a different shipping address). With some changes to your Magento files you can remove the phone field completely or you can make it an optional field.
As an example we'll assume that your Magento is version 1.7 or a newer one and it is installed directly in the public_html folder on your Magento hosting account, making the frontend accessible at yourdomain.com, and that you use the default theme that comes prepackaged with the installation archive.
First, find the file billing.phtml that's located in public_html/app/design/frontend/base/default/template/checkout/onepage on your hosting account (of course, if you use a different theme than the default one, you might have to check for the same file in the folder of that theme). Edit the file and comment out the following code (around line 119):
<div class="field"> <label for="billing:telephone" class="required"><em>*</em> <?php echo $this->__('Telephone') ?></label> <div class="input-box"> <input type="text" name="billing[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="billing:telephone" /> </div> </div>To comment it out put an exclamation mark and two hyphens after the first bracket (e.g. <!--div class) and two hyphens before the last one (e.g. /div-->). You can edit files from the Files section of the Pixie control panel, or you can download it with an FTP client (e.g. FileZilla), edit it on your local computer with a text editor (e.g. Notepad) and upload it back in the same folder overwriting the old file.
Then in public_html/app/design/frontend/base/default/template/checkout/onepage/shipping.phtml find the code (around line 110):
<div class="field"> <label for="shipping:telephone" class="required"><em>*</em> <?php echo $this->__('Telephone') ?></label> <div class="input-box"> <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);" /> </div> </div>and comment it out.
Then edit the file public_html/app/design/frontend/base/default/template/persistent/checkout/onepage/billing.phtml and comment out the code (around line 120):
<div class="field"> <label for="billing:telephone" class="required><em>*</em> <?php echo $this->__('Telephone') ?></label> <div class="input-box"> <input type="text" name="billing[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="billing:telephone" /> </div> </div>These three modifications will ensure that the phone field is hidden during the checkout process. Phone validation, however, will still be performed, and at this point if a customer tries to check out, an error message will pop out informing the customer that a telephone number is required even though the actual fields are not displayed. You need to make another a couple of modifications to disable phone validation.
Edit the file Abstract.php that's in public_html/app/code/core/Mage/Customer/Model/Address on your hosting account and comment out the following code (around line 375):
if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) { $errors[] = Mage::helper('customer')->__('Please enter the telephone number.'); }To comment out PHP code put a forward slash and an asterisk at the beginning (e.g. /*) and an asterisk and a forward slash at the end (e.g. */).
You also have to make one change to the database in which your Magento is installed. You can do that with phpMyAdmin which can be accessed from the Databases section of the Pixie control panel (there's a phpMyAdmin link in the black area on the right). Inside phpMyAdmin click on the name of the database in the frame on the left. This will show its tables in the right frame. Find the table magento_eav_attribute and click on its name (in your case the database table prefix will probably be different than magento). This will show the content of the table. Find the row with telephone for attribute_code and click on the Edit button of that row. Note that it may not be on the first page; you can use the drop-down menu above/below the rows to change the pages. After you click on the edit button, on the next page find the column labeled is_required and change its value from 1 to 0. Then click on the Go button at the bottom of the page and that's it.
After you're done with these changes you can check the result on the frontend.
If you want to, instead of completely removing the field you can make the phone field an optional one so that the customer has a choice of whether to specify a telephone number or not. This is done in a similar way but with some differences.
Make the modification in the Abstract.php file and the change in the magento_eav_attribute table of the database in which your Magento is installed as described above in this article.
You don't have to modify the two billing.phtml files and the shipping.phtml file. If, however, you want to remove the red asterisk that indicates that the field is required, find the code shown above for each of the files and in all three files delete the part:
<em>*</em>
Then refresh the frontend of your site and test the changes.
The changes to the Abstract.php file and the database will also make optional the phone field in the customer account settings on the frontend in Magento. For information on how to visually remove the whole field (or just the red asterisk) check out the article on removing or making optional the phone field in the customer account settings in Magento.
Note that it's not a bad idea to override the core PHP files instead of modifying the original ones. If you need more information on how to do it check out the article on overriding core files in Magento. When it comes to the template files, if you want to avoid modifying the original ones you can use a subtheme. For more information read the article on creating a subtheme in Magento.
If you want to remove other fields from the checkout page, you may find useful the articles: