Jump to content

Hook to change Cart (enabling/disabling ecotax)


Juan C.
 Share

Recommended Posts

Hi everyone:

I need to change product data when they are being added to the cart. I need set ecotax to zero when some data (client, zone, group of client, etc) changes.

In older version of Prestashop I solved this with overriding of Cart class. But I don't want to override classes I want to do it with hooks.

I defined a hook:

 

public function hookactionCartUpdateQuantityBefore(array $params)
{
  $params["product"]->ecotax = 0;
  return $params;
}

This hook runs but data in the cart doesn't change.

If I try with $params["cart"]->_products[0]["ecotax"] = 0; I get 500 server error because _products in cart class is protected.

Can anybody help me?

Thanks!

Share this post


Link to post
Share on other sites

2 hours ago, centaurus1 said:

If I try with $params["cart"]->_products[0]["ecotax"] = 0; I get 500 server error because _products in cart class is protected.

That sounds like a permission issue.

Share this post


Link to post
Share on other sites

Hi

A protected method or protected property of a PHP class is not accesible by others. It is not a permission issue. It is a feature of object oriented programming.

But thanks anyway for your time.

  • Like 1

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