Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Prevent “Telephone” being a required field
 
Patrick Rynhart
Jr. Member
 
Total Posts:  9
Joined:  2008-07-12
 

Hi,

At the checkout when entering billing information, I’d like to prevent “Telephone” being a required field (i.e. make it optional).  If someone could please advise how this is done it would be most appreciated.

Regards,

Patrick

 
Magento Community Magento Community
Magento Community
Magento Community
 
Patrick Rynhart
Jr. Member
 
Total Posts:  9
Joined:  2008-07-12
 

To do this on the onepage checkout:

1) Edit the files:

/app/design/frontend/default/<theme>/template/checkout/onepage/billing.phtml
/app/design/frontend/default/<theme>/template/checkout/onepage/shipping.phtml

and remove “required-entry” as a class from the input control for id="billing:telephone" and “shipping:telephone” respectively

Also remove <span class="required">*</span> (i.e. the red asterisk)

2) In /app/code/core/Mage/Customer/Model/Address/Abstract.php, comment the lines:

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

To do this on the “My account” page (i.e. for customers who have an account):

Edit /app/design/frontend/default/modern/template/customer/address/edit.phtml and remove the “required-entry” and the red asterisk.

Follow Step 2 above if you haven’t already.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nicolas46
Sr. Member
 
Total Posts:  210
Joined:  2008-04-09
Toulouse
 

Maybe this work also (I havn’t test) :
Go to the table “eav_attribute” in your database and change the field “is _require” of the attribute “telephone”

 
Magento Community Magento Community
Magento Community
Magento Community
 
Patrick Rynhart
Jr. Member
 
Total Posts:  9
Joined:  2008-07-12
 

Hi Nicolas,

You’d like to think so - my original attempt involved this database change.

However, at this stage, the check is hard coded in the phtml files.  During a billing.save() or shipping.save(), the form checks for the “required-entry” class; it will not allow the user to proceed if these fields are left blank.

Following this, further validation occurs in /app/code/core/Mage/Customer/Model/Address/Abstract.php.  As before, this check is also hard coded - the check is literally:

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

i.e. no checks are made as to whether the attribute is required or optional.

Regards,

Patrick

 
Magento Community Magento Community
Magento Community
Magento Community
 
team_in_medias
Sr. Member
 
Avatar
Total Posts:  113
Joined:  2008-05-06
Aachen, Germany
 
Patrick Rynhart - 27 July 2008 12:51 PM

To do this on the onepage checkout:

1) Edit the files:

/app/design/frontend/default/<theme>/template/checkout/onepage/billing.phtml
/app/design/frontend/default/<theme>/template/checkout/onepage/shipping.phtml

and remove “required-entry” as a class from the input control for id="billing:telephone" and “shipping:telephone” respectively

Also remove <span class="required">*</span> (i.e. the red asterisk)

You should do those changes in /app/design/frontend/default/<theme>/template/customer/address/edit.phtml too for customers who have registered before ordering and for editing adresses.

Andreas

 
Magento Community Magento Community
Magento Community
Magento Community
 
exsso
Member
 
Avatar
Total Posts:  51
Joined:  2008-08-06
Singapore
 

Hi all,

First of all a big thank you to Patrick! smile I have been looking for a way to disable telephone but failed. The crucial step is in Abstract.php which I left out. Even after changing values in eav_attribute table does not help. Now it works!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jonathan123
Sr. Member
 
Total Posts:  215
Joined:  2008-09-14
 

Thanks for this, this really should be configurable. I’d like my checkout process to be as streamlined as possible and do not need the customers telephone number.

 
Magento Community Magento Community
Magento Community
Magento Community
 
wwessie
Member
 
Total Posts:  63
Joined:  2009-07-16
 

I have done exactly what u say but it dont work

I have already renewd my cache but is still doesnt work

And my Magento versie 1.3.2.3

 
Magento Community Magento Community
Magento Community
Magento Community
 
AITOC
Guru
 
Avatar
Total Posts:  618
Joined:  2009-02-19
US
 

Hello,

It is possible to disable phone number field with the help of our Configurable Checkout module. Please feel free to check it out here:
http://www.magentocommerce.com/extension/1565

 
Magento Community Magento Community
Magento Community
Magento Community
 
Christian Baer
Jr. Member
 
Avatar
Total Posts:  6
Joined:  2009-11-27
Berlin, Germany
 
Patrick Rynhart - 27 July 2008 12:51 PM

2) In /app/code/core/Mage/Customer/Model/Address/Abstract.php, comment the lines:

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

How could I do this with a module? I don’t want to change the core…

Regards

 
Magento Community Magento Community
Magento Community
Magento Community
 
loeffel
Guru
 
Avatar
Total Posts:  427
Joined:  2009-02-03
 

Thanks Patrick, I had only removed the phone and province field in the template files, so it would still require those two fields. The changes in Abstract.php did the trick. Thank you!

@ wwessie: Working fine in 1.4 and I doubt the files changed for 1.3 - revise your steps

@ Christian Baer: copy the entire folder structure to code/local and you should be save for updates

 
Magento Community Magento Community
Magento Community
Magento Community
 
loeffel
Guru
 
Avatar
Total Posts:  427
Joined:  2009-02-03
 

Thanks Patrick - I had only removed two fields in the template itself, so it would still ask for those when sending the form. The changes in Abstract.php did the trick. Thanks again!

@ wwessie: This is working great with v1.4 and I doubt the files were changed in 1.3 - revise your steps!

@ Christian Baer: copy the entire folder structure to app/local and you should be save for updates

 
Magento Community Magento Community
Magento Community
Magento Community
 
loeffel
Guru
 
Avatar
Total Posts:  427
Joined:  2009-02-03
 

Thanks Patrick - I had only removed two fields in the template itself, so it would still ask for those when sending the form. The changes in Abstract.php did the trick. Thanks again!

@ wwessie: This is working great with v1.4 and I doubt the files were changed in 1.3 - revise your steps!

@ Christian Baer: copy the entire folder structure to app/local and you should be save for updates

 
Magento Community Magento Community
Magento Community
Magento Community
 
loeffel
Guru
 
Avatar
Total Posts:  427
Joined:  2009-02-03
 

Thanks Patrick, I had only removed the fields in the template file itself so it would still ask for them when sending the form - the changes in Abstract.php did the trick!

@ wwessie: Working great with v1.4 and I doubt the files were changed in v1.3 - revise your steps!

@ Christian Baer: copy the entire folder structure to app/local and you should be save for updates.

 
Magento Community Magento Community
Magento Community
Magento Community
 
loeffel
Guru
 
Avatar
Total Posts:  427
Joined:  2009-02-03
 

Wow - what happend up there - sorry about that, but magento forum is weird sometimes.

I noticed a big problem with this method. If you access a customer in the backend and want to change something, it will not save the data because in the backend telephone is still a required entry!

 
Magento Community Magento Community
Magento Community
Magento Community
 
qualia
Jr. Member
 
Total Posts:  18
Joined:  2010-10-09
 
Patrick Rynhart - 27 July 2008 12:51 PM

To do this on the onepage checkout:

1) Edit the files:

/app/design/frontend/default/<theme>/template/checkout/onepage/billing.phtml
/app/design/frontend/default/<theme>/template/checkout/onepage/shipping.phtml

and remove “required-entry” as a class from the input control for id="billing:telephone" and “shipping:telephone” respectively

Also remove <span class="required">*</span> (i.e. the red asterisk)

2) In /app/code/core/Mage/Customer/Model/Address/Abstract.php, comment the lines:

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

To do this on the “My account” page (i.e. for customers who have an account):

Edit /app/design/frontend/default/modern/template/customer/address/edit.phtml and remove the “required-entry” and the red asterisk.

Follow Step 2 above if you haven’t already.

Thanks for this! This does work, but only if you edit /app/code/core/Mage/Customer/Model/Address/Abstract.php and NOT /app/code/local/Your_Company/Customer/Model/Address/Abstract.php, for example…

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2