cancel
Showing results for 
Search instead for 
Did you mean: 

Telephone number on customer address shouldn't be required

Telephone number on customer address shouldn't be required

Feature request from hostep, posted on GitHub Aug 17, 2015

Hi guys

Why is the telephone number still required on a customer address? We hear from our shop owners that a lot of customers refuse to enter something in there or just enter gibberish.

An ideal solution would be if you could add a configuration option in the backend similar to the Gender, Tax/Vat Number and Date of Birth fields. So an option for showing the telephone number where you can choose between No, Optional or Required. What do you think?

I had to implement this today into a Magento CE 1.x store and it was kind of a terrible experience, changing stuff in the database, remove the hard coded validation of that field (which is still present btw: https://github.com/magento/magento2/blob/93312cae42824274722fe7a285d5ce8e40f177a1/app/code/Magento/C...), ...

Related to https://github.com/magento/magento2/issues/624

(1)
30 Comments
apiuser
New Member

Comment from joellarsson130, posted on GitHub Jul 15, 2016

I can disable the Zend_validate but can't make sure about the JS

apiuser
New Member

Comment from nanda1990, posted on GitHub Jul 18, 2016

i want to add mobile sms otp in cash on delivery payment method in magento 2 i know otp code but i dont know how to get telephone number. or where to get telephone session telephone

Thanks and Regards

apiuser
New Member

Comment from andidhouse, posted on GitHub Jul 19, 2016

@ilol

If there is no chance to make this as an option in a magento release it would be great to have a documentation explaining how to delete tel. number or make it not a required field. Many people asked for this and i can not find any official documentation here. Can you pls provide this for the moment for us?

apiuser
New Member

Comment from ludwig-gramberg, posted on GitHub Jul 19, 2016

just a rough overview: in di.xml we addressed:

  • <preference for="Magento\Sales\Model\Order\Address\Validator" type="Your\Module\Model\Order\Address\Validator" />
  • <preference for="Magento\Customer\Model\Address" type="Your\Module\Model\Address" />
  • <preference for="Magento\Quote\Model\Quote\Address" type="Your\Module\Model\Quote\Address" />
  • <preference for="Magento\Customer\Model\ResourceModel\AddressRepository" type="Your\Module\Model\ResourceModel\AddressRepository" />

in each instance we extended the original class and replaced the following methods:

  • \Magento\Sales\Model\Order\Address\Validator::validateForCustomer
  • \Magento\Quote\Model\Quote\Address::validate
  • \Magento\Customer\Model\ResourceModel\AddressRepository::_validate the method is private so you will have to implement a copy of this method and replace the save method instead, using your own _validateX method
  • \Magento\Customer\Model\Address::validate

database:

in the database we changed the telephone attribute required flag and removed the validation (not sure if the last part is necessary, maybe if someone enters a value you still want it validated)

my general observation implementing this using various approaches was, that the system is very cluttered in terms of where information is coming from, you got the attribute in the database, you got the layout.xml defining the javascript thats being rendered, you got the configprovider files where some properties are coming from as well and then you have the validators in several places. I feel like there should be single central point which defines what needs to be validated and how.

baldwin_pieter
Core Contributor

Email me when someone replies

pikaminskimage
Contributor
Status changed to: Investigating
 
illia_oliinyk
Adobe Team

Related: #6578
Initial issue was registered as MAGETWO-58099

lisali
Contributor

Why is this still not fixed? It's absolutely RIDICULOUS not being able to make the telephone number field optional. I know that if a merchant requires this when I check out online, I abandon the cart, or give them a fake number. I shop online all the time, and NEVER give out my number. What will it take for this to be implemented?

LColton
Visitor

A shop selling virtual products with bitcoins isn't going to be needing phone numbers, addresses, or anything besides a name and email. 

soren_1
Senior Member

I have created a module which removes the requirement on the telephone input:
https://github.com/zsoerenm/magento2-optionaltelephone
It can be installed via composer