Jump to content

How to make phone number field compulsory


praffy

Recommended Posts

I am using v1.5.3.1 with registration process type as account creation only. I was getting error when I set phone no to yes so I set it to no. Now my problem is that I want every customer must enter atleast one contact no for ordering a product. I am not getting how to do that in v1.5.3. In classes there is no tpl file to edit, not getting how to do. Need help!!!

Link to comment
Share on other sites

Thanks Vekia for replying. By the way thats not my problem. I turned it off and not getting any warning or message, everything is fine. But I want to make phone number field compulsary in address form, where user enters his address details.

Link to comment
Share on other sites

ohh sorry for my misunderstanging, in other words, you want to make phone number REQUIRED ? compulsary = reuqired ;)

if so, you will need to change Address class,

 

classes/Address.php

reuired fields have got reuired=> true param, there is object definition:

 

public static $definition = array(
'table' => 'address',
'primary' => 'id_address',
'fields' => array(
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
'id_manufacturer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_state' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'),
'alias' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32),
'company' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 64),
'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
'vat_number' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
'address1' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'required' => true, 'size' => 128),
'address2' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'size' => 128),
'postcode' => array('type' => self::TYPE_STRING, 'validate' => 'isPostCode', 'size' => 12),
'city' => array('type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => true, 'size' => 64),
'other' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 300),
'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
'phone_mobile' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
'dni' => array('type' => self::TYPE_STRING, 'validate' => 'isDniLite', 'size' => 16),
'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'copy_post' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'copy_post' => false),
),
);
 
just add reuired=>true param to the phone numer :)
  • Like 1
Link to comment
Share on other sites

Thanks vekia. One more question whose answer is not getting. How can I replace currency in pdf with another character. In short what I have to do is I have to replace currency symbol with short text, or with html supported code whichever is possible but that so in pdf.

Link to comment
Share on other sites

  • 4 months later...
  • 1 year later...

 

ohh sorry for my misunderstanging, in other words, you want to make phone number REQUIRED ? compulsary = reuqired ;)

if so, you will need to change Address class,

 

classes/Address.php

reuired fields have got reuired=> true param, there is object definition:

 

public static $definition = array(
'table' => 'address',
'primary' => 'id_address',
'fields' => array(
...
'phone_mobile' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
...
),
);
 
just add reuired=>true param to the phone numer :)

 

 

 

Hi,

 

I needed to make the phone_mobile field required, so I did as suggested above, added the reuired=>true param and it worked but...

 

There's now an issue with guest  checkout. It throws "TECHNICAL ERROR: unable to save adresses ..." js error.

Checking further made me find out that the error came from a POST request:

/address?back=order-opc.php Failed to load resource: the server responded with a status of 500 (Internal Server Error)
 
And further investigateion showed the following error: 
Property Address->phone_mobile is empty at line 837 in file classes/ObjectModel.php
 
So, after all this investigation, I realized that adding reuired=>true param to the phone_mobile field in classes/Address.php was the source of the error, and removing the reuired=>true param solved the "TECHNICAL ERROR: unable to save adresses ..." issue.
 
Question remains: how to make the phone_mobile a required field without causing other issues?
 
Our PrestaShop version is 1.5.6.2 with one page checkout
 
Thanks!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...