Jump to content

hookActionCartSave not working properly.


M Iqbal

Recommended Posts

Hello support,
I am trying to use  hookActionCartSave hook in my custom module but that hooks fire when i go to checkout and add customer information or login customer in Prestashop 1.6 and 1.7.

I want the event when user add product to cart.
As per Prestashop documentation i try to use actionCartUpdateQuantityBefore but no luck.

Can anyone please help.

Thank you.

Link to comment
Share on other sites

Basically, I am currently using hook hookActionCartSave , but this hooks fire when i go to checkout page and enter customer address / login customer after adding product to cart.

I need an event when a product will be add / remove / qty update in cart.

Link to comment
Share on other sites

That hook is executed when you add / delete a product, I tell you for sure.
Do a simple test, type "exit;" in the hook, and check in the console, on the network, if the execution stops (you can also give a var_dump with a text, to see if it returns that text to you).

  • Like 1
Link to comment
Share on other sites

  • 3 years later...

 

I have the same problem with version 8.

i added a echo with script-tag and then called console.log('hook called'), but nothing happend.

but there won't be a console.log, using var_dump creates an error

Link to comment
Share on other sites

8 hours ago, wolfomat said:

 

I have the same problem with version 8.

i added a echo with script-tag and then called console.log('hook called'), but nothing happend.

but there won't be a console.log, using var_dump creates an error

In PrestaShop, you cannot directly use console.log inside an action hook because action hooks are executed on the server side in PHP, while console.log is a JavaScript function that runs on the client side (browser). You can use PHP debugging methods inside your action hook function, such as:

error_log(print_r($params, true));  // to log data to the PHP error log.

 

print_r($params); die();  // to output data directly (useful for quick debugging but will stop execution).

 

Link to comment
Share on other sites

11 godzin temu, wolfomat napisał:

 

I have the same problem with version 8.

i added a echo with script-tag and then called console.log('hook called'), but nothing happend.

but there won't be a console.log, using var_dump creates an error

You can use PrestashopLogger for action hooks and then check Logs page in prestashop.

 

Link to comment
Share on other sites

that was a good hint. logs are written, i guess i need to study the docs further, in order to implement a correct functionality. however, the logs has shown, that the hooks are called. thanks !

 

        PrestaShopLogger::addLog('hookActionValidateOrder', 3);

 

was a call -> i saw that log

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