Jump to content

Cannot add custom field to Customer


tempnull
 Share

Recommended Posts

Hello, i'm new to Prestashop and want to add a custom field 'Phone Number' into Customer module

I found a tutorial and follow it, but it didn't work

https://devdocs.prestashop.com/1.7/development/components/grid/tutorials/modify-grid-in-module/

 

then, i start from the beginning, try Hook in the doc, and it failed again 

https://devdocs.prestashop.com/1.7/development/components/grid/tutorials/modify-grid-in-module/

 

after some researches, i found that the hook function should be registered first

https://devdocs.prestashop.com/1.7/modules/sample-modules/grid-and-identifiable-object-form-hooks-usage/

 

so, which file contains the Install() function i can register my hook? it will work after registered in install?

do i need to call the hook somewhere to trigger it?

thanks!

Share this post


Link to post
Share on other sites

How to register hook

First, create a hook function in your main .php file of your module. Like this:

public function hookyour_hook_nameHook() {
	dump("it works");
}

Next step, registration of the hook:

1. Programmatically:

During the installation ( function install() ) you have next line:

return parent::install() &&
            $this->registerHook('your_custom_hook_name');

actually, you can register hook anywhere you want with next line:

$this->registerHook('your_custom_hook_name');

2. In the BO of prestashop (I prefer this one):

Go to Design->Positions->Transplant a module (top-right corner)->"choose_your_module"->"choose hook you created" ->Save

 

P.S. the hook "triggers" by itself, you don't need to call it somewhere

P.S2. You can fast create a module here, than follow the instructions I described to you above.

 

Edited by Amantha Bill (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
 Share

×
×
  • Create New...

Important Information

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