Jump to content

How can I edit the registration.


fiante55

Recommended Posts

  • 4 weeks later...

I'm trying to set a store with downloadable products only, so I basically don't need the whole "Your address" section of the registration.

Now, simply cutting that out of the authentication.tpl is not enough, since it still check and reports missing fields - alias, address (1), postcode...

I'm not that great with php, and my guess was that I should be looking at authentication.php, but I can't find what I need to modify there at all.

Even if it's not removing the fields completely but filling the ones not needed by default with a "downloadable" value, it'd still be great.

Can anyone please point me in the right direction?

Link to comment
Share on other sites

first things to look at are in authentication.php (.tpl only display the required fields...)

Somewhere in the code U'll find :

if (Tools::isSubmit('submitAccount'))
{
   $create_account = 1;
   $smarty->assign('email_create', 1);
   $validateDni = Validate::isDni(Tools::getValue('dni'));
.....



Look at every line starting like if(Tools:Validate( ..........
Then you should be able to understand how to remove or add a required field here

More générally , every test regarding required fields or validity of them is done here

Link to comment
Share on other sites

Thank you for the help Broceliande, but it appears I'm just not succeeding...

The form in the tpl sends "postcode","city" and "address1" values to the authentication.php, but none of those are be seen referenced in the php file itself. I see the checks for "passwd", "country", "id_customer" and whatnot, but not the fields I want removed... Am I looking for the wrong thing? Are they aggregated under a different name or something?

Link to comment
Share on other sites

Sorry if i misexplained... that happens to frenchies like me...
authentication.php has to be checked in order to know how fields are required , so that you can remove them safely from authentication.tpl
If you remove a field from tpl wich is required, you'll get an error after postprocessing
(hope i explained better :s )

Also, what i told was only kept from my human memory.
If you don't success, just hit me one more time and i'll have a real look into this part of code.

Link to comment
Share on other sites

Regarding the "frenchies" thing, I'm from Quebec, so yeah...
...
I'm not sure if I'm not misunderstanding your last post.
Fields that are not required are easy to note remove from the tpl, as they don't have a * next to them.
...
I'll try to explain myself again too.
What I wish to remove are the "Address", "Postal code" and "City". Now, those fields are by default required, so I need to un-require them first, or the registration keeps reporting errors. However, the more I look at the authentication.php, the more it seems to me that it's not there that the check for those fields is done. So, I end up having no clue how to proceed and/or I'm likely doing something very wrong.

I've searched the forums and it seems there were a few others asking the same question, but none got an answer. Can someone please shed some light on the issue?

Basically, the question boils down to "how to make a registration field non required so I can remove it?"
That, or "how can I enter dummy data by defaylt in those fields, like "digital product only", so clients don't have to fill them out?"

Link to comment
Share on other sites

I should have seen wich fields you wanted to remove. I would have been more attentive & explainfull...

Solution will be in the Address class
You'll find the file in /classes/Address.php

Around line 80 you'll get the required fields,
so

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


should become

protected $fieldsRequired = array('id_country', 'alias', 'lastname', 'firstname');


But that's not enough , cause fields are also validated and some of them may not validate if they are empty (while they aren't supposed to be)

around line 84

    protected    $fieldsValidate = array('id_customer' => 'isNullOrUnsignedId', 'id_manufacturer' => 'isNullOrUnsignedId',
                                       'id_supplier' => 'isNullOrUnsignedId', 'id_country' => 'isUnsignedId', 'id_state' => 'isNullOrUnsignedId',
                                       'alias' => 'isGenericName', 'company' => 'isGenericName', 'lastname' => 'isName',
                                       'firstname' => 'isName', 'address1' => 'isAddress', 'address2' => 'isAddress',
                                       'postcode' => 'isPostCode', 'city' => 'isCityName', 'other' => 'isMessage',
                                       'phone' => 'isPhoneNumber', 'phone_mobile' => 'isPhoneNumber', 'deleted' => 'isBool');



has to be changed to :

    protected    $fieldsValidate = array('id_customer' => 'isNullOrUnsignedId', 'id_manufacturer' => 'isNullOrUnsignedId',
                                       'id_supplier' => 'isNullOrUnsignedId', 'id_country' => 'isUnsignedId', 'id_state' => 'isNullOrUnsignedId',
                                       'alias' => 'isGenericName', 'company' => 'isGenericName', 'lastname' => 'isName',
                                       'firstname' => 'isName',  'other' => 'isMessage',
                                       'phone' => 'isPhoneNumber', 'phone_mobile' => 'isPhoneNumber', 'deleted' => 'isBool');



I think this will be enough , you shouldn't get error messages about those fields anymore.
Hope this won't break anything in BO though. This has to be tested , i didn't.

Edit : i forgot to mention that some fields are required because they are used by other tools or classes, so this tweak i just gave may just be stupid. Most probably more changes will be needed resulting from those 3 fields removal.

Link to comment
Share on other sites

  • 3 months later...
  • 7 months later...

For anyone also looking, you don't need to edit any code !

I spent the last 2 hours editing address.php address.tpl and authentication.tpl then reverted back because nothing was actually working.

 

What you need to do is :

- Go to the back office -> Shipping

- Then Choose your country

- Clic on edit and you will be able to specify if you need post code, company, city, etc.

 

You actually need to do it for each country if you are serving more than one.

 

It's dumb to "hide" those options there and not in the customer section.

 

I'm on 1.4.5.1 btw.

 

Hope it will help :)

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Did you try it? I tested it by removing address1 and address2 and it seems it doesnt work.

 

Im using PrestaShop™ 1.4.7.0

 

 

For anyone also looking, you don't need to edit any code !

I spent the last 2 hours editing address.php address.tpl and authentication.tpl then reverted back because nothing was actually working.

 

What you need to do is :

- Go to the back office -> Shipping

- Then Choose your country

- Clic on edit and you will be able to specify if you need post code, company, city, etc.

 

You actually need to do it for each country if you are serving more than one.

 

It's dumb to "hide" those options there and not in the customer section.

 

I'm on 1.4.5.1 btw.

 

Hope it will help :)

Link to comment
Share on other sites

  • 4 weeks later...

This works for me, is there a way to create a single templeta and apply it to all countries?

 

 

For anyone also looking, you don't need to edit any code !

I spent the last 2 hours editing address.php address.tpl and authentication.tpl then reverted back because nothing was actually working.

 

What you need to do is :

- Go to the back office -> Shipping

- Then Choose your country

- Clic on edit and you will be able to specify if you need post code, company, city, etc.

 

You actually need to do it for each country if you are serving more than one.

 

It's dumb to "hide" those options there and not in the customer section.

 

I'm on 1.4.5.1 btw.

 

Hope it will help :)

Link to comment
Share on other sites

  • 7 months later...

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...