PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

 

Can telephone number be made mandatory during checkout?

25 replies to this topic
#1
wiredworx

    PrestaShop Newbie

  • Members
  • Pip
  • 2 posts
As the title says - does anyone know if there is a setting which makes the customer have to fill in at least one telephone number? I am having an issue as my dropshipper requires it but customers keep not filling it in! :)

Any help gratefully received.

Thanks
Rob.

#2
jhnstcks

    PrestaShop Fanatic

  • Moderators
  • 1913 posts
If you edit your classes/address.php file at the top is the following section of code.

    protected    $fieldsRequired = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'postcode', 'city', 'county');


change it to

    protected    $fieldsRequired = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'postcode',  'city', 'county', 'phone'); 


then in your theme folder edit the authentication.tpl file.

            



<input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" />




change the above code to




<input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" />
*



That will display the little astrix to show that it is required field.
Helpful hints and tips to Empower your Prestashop site - Join us on Facebook and get involved, tell us the things that help you.
If you think someone's answer helped, please give him/her a Positive Reputation vote by liking their post.
E-commerce hosting from Scotserve, fast, reliable and affordable.

#3
wiredworx

    PrestaShop Newbie

  • Members
  • Pip
  • 2 posts
That's just what I was after. Thank you so much! :)

#4
esoso

    PrestaShop Apprentice

  • Members
  • PipPip
  • 52 posts
Thank you so much!
UGG Boots Store provide Cheap UGG Boots,Womens Boots

#5
Ostfarsan

    PrestaShop Newbie

  • Members
  • Pip
  • 15 posts
Thank you. Very useful for me.

One problem with this is that the "phone" is not required when changing the address via the "Update Address" in My Account

#6
sgtbash

    PrestaShop Apprentice

  • Members
  • PipPip
  • 107 posts
Hey all,

Remember to change it in address.tpl in your theme directory also, as there is no asterix on there either:

Around line 87...

Change:



<input type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{else}{$address->phone|escape:'htmlall':'UTF-8'}{/if}" />




To:



<input type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{else}{$address->phone|escape:'htmlall':'UTF-8'}{/if}" />
*




Dan
Nineplus USA - Now on Prestashop 1.4.7

#7
Drew

    PrestaShop Apprentice

  • Members
  • PipPip
  • 40 posts
Hi guys and girls

I have tried using the code above but for some reason I end up with this error message

"There is 1 error :

1. County is required"

however I have no filed called county on the sign up form

if any one has any ideas on a fix that would be fantastic

I'm using prestashop 1.2.5 and I have tried it on a clean install of prestashop as well just to check
www.moor-pro.com - a whole sale store for beauty therapists

#8
jhnstcks

    PrestaShop Fanatic

  • Moderators
  • 1913 posts
Delete county of the line of code.
Helpful hints and tips to Empower your Prestashop site - Join us on Facebook and get involved, tell us the things that help you.
If you think someone's answer helped, please give him/her a Positive Reputation vote by liking their post.
E-commerce hosting from Scotserve, fast, reliable and affordable.

#9
Drew

    PrestaShop Apprentice

  • Members
  • PipPip
  • 40 posts
It worked thanks very much :)
www.moor-pro.com - a whole sale store for beauty therapists

#10
SpyrosT

    PrestaShop Apprentice

  • Members
  • PipPip
  • 305 posts
Tnx ppl, worked great!

#11
dzindzilia

    PrestaShop Newbie

  • Members
  • Pip
  • 10 posts
Hi,
I tried that modification. Everything worked, Except:
If existing customer wants to update his profile and enters some data in the phone field, when saving he gets this error:
Hack attempt (Address -> phone is empty)

If nothing is entered in the phone field, so normal error message appears, that phone field has to be filled.

Can you advice what should I fix to make it work correctly?

#12
nuttis

    PrestaShop Apprentice

  • Members
  • PipPip
  • 130 posts
Hi

I tried to do this thing for the birthday field but even if the custumer fills in their birthday an error comes up that the field is required. And also i get strange icons in the list of day/month/year.

Help someone?

Attached Files



#13
bluehat09

    PrestaShop Newbie

  • Members
  • Pip
  • 19 posts
Thank you. That was easy.

#14
JCKeely

    PrestaShop Newbie

  • Members
  • Pip
  • 1 posts

Quote

If you edit your classes/address.php file at the top is the following section of code.

protected $fieldsRequired = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'postcode', 'city', 'county');

change it to

protected $fieldsRequired = array('id_country', 'alias', 'lastn


Thanks, thought it was just me who couldn't find the instructions to force a telephone number entry! Works- thanks, JC
Go outside, the graphics are amazing. (Unknown)
JC, Phone Service Mgr

#15
Timothy Jarman

    PrestaShop Apprentice

  • Members
  • PipPip
  • 71 posts
Hey man thanks so so much for that.

Am i right in assuming then if its not the HOME phone you want as compulsory but you want the MOBILE to be the one, then is it the code phone_mobile?

Also one thing :) this * works but on my theme the * is in the color Red, but when i put this on the phone one it is White :( how do i color this Red?


THanks
Fancy Dress Costumes - Fantasy Costumes UK and Worldwide delivery - Fancy Dress Costumes, Shoes & Accessories - www.Fantasy-Costumes.co.uk

#16
peterkwok

    PrestaShop Newbie

  • Members
  • Pip
  • 13 posts
jhnstcks,great thanks for that,i am new on prestashop,and just got some order from customers,but everytime i have to confirm the phone numbers with customers,or the express company wont get the cartons,your answer help me a lot,thanks again

#17
Ostfarsan

    PrestaShop Newbie

  • Members
  • Pip
  • 15 posts

From 1291758648:

Hey man thanks so so much for that.

Am i right in assuming then if its not the HOME phone you want as compulsory but you want the MOBILE to be the one, then is it the code phone_mobile?

Also one thing :) this * works but on my theme the * is in the color Red, but when i put this on the phone one it is White :( how do i color this Red?


THanks


I also having this problem. Does anyone know how to do the asterix red?

#18
finlander

    PrestaShop Apprentice

  • Members
  • PipPip
  • 181 posts
How to make phone number(s) NOT required in PrestaShop 1.4?
Phone number is not listed in $fieldsRequired in Address.php, so some other code is making it required. How to make it NOT required in 1.4?

#19
Ostfarsan

    PrestaShop Newbie

  • Members
  • Pip
  • 15 posts
Hey!

Try to edit your classes/address.php from:



<input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" />
*



to:



<input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" />



and then edit your then in your theme folder edit the authentication.tpl file from:



<input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" />
*




to:



<input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" />






I have not tested yet, but I think it will work.

Regards,
J

#20
finlander

    PrestaShop Apprentice

  • Members
  • PipPip
  • 181 posts
thank you, I'll try that.

I also found this bit of code in AddressController.php that may also be making phone number required. When I commented this out, I still got the required error though. They really did something to make it difficult to make phone number NOT required, didn't they?

    if (!Tools::getValue('phone') AND !Tools::getValue('phone_mobile'))
$this->errors[] = Tools::displayError('You must register at least one phone number');


J. -- your recommendation will not work with 1.4. It's much different.