Jump to content

Hook actionCustomerAccountUpdate is not working in Prestashop 1.6.1.24


Recommended Posts

And why shouldn't it work?
It's easy!

public function hookActionObjectCustomerUpdateAfter($params) 
{
	$id_customer = (int)$params['object']->id; 
	$customer = new Customer((int)$id_customer);

	$gender = new Gender((int)$customer->id_gender, (int)$customer->id_lang, (int)$customer->id_shop);
	$group = new Group((int)$customer->id_default_group, (int)$customer->id_lang, (int)$customer->id_shop);

	$firstname =  $customer->firstname;
	$lastname = $customer->lastname;
	$company = $customer->company;
  	$genderName = $gender->name;
	$groupName = $group->name;
	
	....
}

 

Edited by knacky (see edit history)
  • Thanks 1
Link to comment
Share on other sites

Upon saving or updating customer address, the hook actionObjectCustomerUpdateAfter  is not working.
I want to get the event of Customer update address as well.

For 1.7.X i am using actionValidateCustomerAddressForm to catch customer address update event.

 

image.png.d6143d3f6d5e19c2d4c18d6b172bc81d.png

Edited by M Iqbal (see edit history)
  • Like 1
Link to comment
Share on other sites

actionObjectAddressUpdateAfter

public function hookActionObjectAddressUpdateAfter($params) 
{
	$id_address = (int)$params['object']->id;
	$address = new Address((int)$id_address);
	
	$company = $address->company;
	$lastname = $address->lastname;
	....
}

 

actionObjectAddressAddAfter

public function hookActionObjectAddressAddAfter($params) 
{
	$id_address = (int)$params['object']->id;
	$address = new Address((int)$id_address);
	
	$company = $address->company;
	$lastname = $address->lastname;
	....
}

 

Edited by knacky (see edit history)
  • Thanks 1
Link to comment
Share on other sites


/* install */
public function install()
{                                 
	if (Shop::isFeatureActive())
	{
		Shop::setContext(Shop::CONTEXT_ALL);
	}
        
	if (!parent::install())
	{
		return false;
	}

	$this->registerHook('actionObjectAddressAddAfter');

	return true;
}

/* uninstall */
public function uninstall()
{                                 
	$this->unregisterHook('actionObjectAddressAddAfter');

	if (Shop::isFeatureActive())
	{
		Shop::setContext(Shop::CONTEXT_ALL);
	}
        
	if (!parent::uninstall())
	{
		return false;
	}

	return true;
}
  
        
     

 

Link to comment
Share on other sites

When you have multiple hooks, it can be used recursively.
E.g:

 

class MyModule extends Module {


    public $hooks = array('actionObjectAddressAddAfter', 'header', 'actionFrontControllerSetMedia');

...
...

/* install */
public function install()
{                                 
	if (Shop::isFeatureActive())
	{
		Shop::setContext(Shop::CONTEXT_ALL);
	}
        
	if (!parent::install())
	{
		return false;
	}

	foreach ($this->hooks as $hook)
	{
		$this->registerHook($hook);
	}

	return true;
}

/* uninstall */
public function uninstall()
{                                 
	foreach ($this->hooks as $hook)
	{
		$this->unregisterHook($hook);
	}

	if (Shop::isFeatureActive())
	{
		Shop::setContext(Shop::CONTEXT_ALL);
	}
        
	if (!parent::uninstall())
	{
		return false;
	}

	return true;
}

 

Link to comment
Share on other sites

3 minutes ago, M Iqbal said:

Yes i have created this uninstall function in my module and it is working fine with 1.7.X but,

when i uninstall the module from 1.6.X like in mentioned image this uninstall function not works.

image.png.26b41f3895b5013cc6387a2cbbf077a7.png

Turn on debug mode and enter an error message here, or make screen errors.

I don't see your installation and uninstallation feature, so I can't give targeted advice.

Edited by knacky (see edit history)
Link to comment
Share on other sites

/**
  * On uninstall event
  *
  * @return bool
  */
public function uninstall()
    {
        if(!$this->getIntegrationID()) {
            $curlData = array(
                "event" => "Uninstall",
                "uuid" => $this->getIntegrationID(),
                "data" => new stdClass()
            );

            Configuration::deleteByName('module');
            Configuration::deleteByName('module_username');
            Configuration::deleteByName('module_password');
            Configuration::deleteByName('integrationId');
            $this->unsetEvents();
            $this->request($this->eventUrl, $curlData, "POST");
        }

        return parent::uninstall();
    }

 

This is what i am doing and it is working fine with Prestashop 1.7 but not for 1.6

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