Jump to content
electriz

[TUTORIAL] Adding new fields to the registration form in PrestaShop 1.7

Recommended Posts

Nice tutorial but you don't respect PrestaShop developments basics.

You explain to modify core files.

So everything will be lost in case of update.

The best way for doing it is to use overrides or to create module. 

Regards, 

 

Edited by hhennes (see edit history)

Share this post


Link to post
Share on other sites
On 13.04.2018 at 9:11 AM, hhennes said:

Nice tutorial but you don't respect PrestaShop developments basics.

You explain to modify core files.

So everything will be lost in case of update.

The best way for doing it is to use overrides or to create module. 

Regards, 

 

 

I'm aware of that so I point the files and places to modify.

However you are right and I will include info about moving changed files to override/ directory - to prevent losing it.
 

Share this post


Link to post
Share on other sites

Nice tutorial but you don't respect PrestaShop developments basics.

You explain to modify core files.

So everything will be lost in case of update.

The best way for doing it is to use overrides or to create module. 

 

 

 

What does it means hennes?

Thanks

Share this post


Link to post
Share on other sites

Hi,

I mean that this tutoriel doesn't use the best way to add new fields ;)
If you update your prestashop instance all changes will be lost.
As the changes are done in core files, which will be replaced during the update.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Hhennes, 

And what do you think is the best option? 

 

Share this post


Link to post
Share on other sites

In my point of view, the best way is often to make a module.
Then to use the native hooks ( if possible ), in order to be the less invasive on the website.

 

Regards

Share this post


Link to post
Share on other sites

Well, it shows You place to modify in the Core files, but in the end You move it to the override/.

So even if core files are changed, your override will stay.

Some modules may be better, but maybe some people wants to save a few bucks and to this by themselves? That's why I'm showing one way to do this. And I'm not saying it's the best one. Just one of them.

P.S. Even hook names and their appearance in different PS verions are changing, so you still can not be sure if using a module it will last forever. To be "the less invasive" you would have to use all built-in modules only or most popular with frequent updates to the latest PS versions.

Edited by electriz (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

Ok, thank you for your explanation!

Nice tutorial

 

Share this post


Link to post
Share on other sites

very nice the tutorial.

but i have 2 questions don't know how to do it.

1.  Donot know how to Replace in DESTINATION files.

2.How can translate the 'My field required' ?i can't find it in the translations in the backoffice.

 

Thank you very much

123321.png

Share this post


Link to post
Share on other sites
On 7/8/2017 at 2:27 AM, electriz said:

I've written a tutorial about extending registration form by adding your new fields:

 

http://prestacraft.com/adding-new-fields-to-the-registration-form-in-prestashop-1-7/

 

Enjoy :)

Thank you so much for the tutorial! 

I have added the field but labels are not appearing in the back-office internationals-> translations !
  Please help.

Edited by tulsa.lale (see edit history)

Share this post


Link to post
Share on other sites

Please provide help in 1.7.6 .  Structure and architecture for admincustomercontroller is totally different.

Share this post


Link to post
Share on other sites
On 5/11/2020 at 11:23 AM, wfpaisa said:

I made this module, so maybe it's useful ps_customercedula

 

https://github.com/wfpaisa/prestashop-custom-field

I have experimented with your module and I found it very interesting to continue developing, in PS 1.7.6.x the structure between customer data and address data changes a lot, as Doug Macaida could say ... "Your module will work" although it is basic It is an excellent starting point to continue developing, personally I have a lot of experience in other areas but not in layout and PHP programming, currently I am trying on your module to create a variant to add mobile phone fields and DNI number in the first registration form and I have problems with the order of the new fields since, as in your base module "cedula" the fields appear below the service acceptance checkbox when I want them to appear under lastname for example ..., there is also the issue that in the customer view panel shows, even if it is not the mobile phone, but that is another step.
Very good work of yours, is the only thing that worked on it to at least prove the point in PS 1.7.6.x !!

Share this post


Link to post
Share on other sites
On 6/26/2020 at 2:19 PM, MrKairo said:

I have experimented with your module and I found it very interesting to continue developing, in PS 1.7.6.x the structure between customer data and address data changes a lot, as Doug Macaida could say ... "Your module will work" although it is basic It is an excellent starting point to continue developing, personally I have a lot of experience in other areas but not in layout and PHP programming, currently I am trying on your module to create a variant to add mobile phone fields and DNI number in the first registration form and I have problems with the order of the new fields since, as in your base module "cedula" the fields appear below the service acceptance checkbox when I want them to appear under lastname for example ..., there is also the issue that in the customer view panel shows, even if it is not the mobile phone, but that is another step.
Very good work of yours, is the only thing that worked on it to at least prove the point in PS 1.7.6.x !!

Thanks MrKairo, It's always good to know that sharing helps. At least it's a basis for achieving what I want, and it would have helped me a lot

Share this post


Link to post
Share on other sites
On 6/27/2020 at 11:41 PM, wfpaisa said:

Thanks MrKairo, It's always good to know that sharing helps. At least it's a basis for achieving what I want, and it would have helped me a lot

I have taken as reference what was exposed in the PrestaCraft tutorial present in this thread, in my case it would be the ideal solution but it is evident that the development is based on a version prior to 1.7.6.5 where things have changed a lot from the structural ..., you will have noticed that for example the path  adminxxx/themes/default/template/controllers/customer/helpers/view has been replaced by /adminxxx/themes/default/template/controllers/customer_threads/helpers/view and inside the view.tpl does not have the same structure as in the mentioned tutorial.
Well, I'm still on the road, if I achieve my goal I'll share it with you in this thread.


Best regards!

Share this post


Link to post
Share on other sites

Any development on this topic, i am interested in this solution, i am not a developer, please share your results.

Share this post


Link to post
Share on other sites
Posted (edited)
On 5/11/2020 at 4:23 PM, wfpaisa said:

I made this module, so maybe it's useful ps_customercedula

 

https://github.com/wfpaisa/prestashop-custom-field

Override Customer.php

No need to edit the definition array 😉

<?php

class Customer extends CustomerCore
{

    public $cedula;

    public function __construct($id = null)
    {
        self::$definition['fields']['cedula'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName');

        parent::__construct($id);
    }

}

 

Edited by D. Tengler (see edit history)

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More