Juan C. Posted March 26, 2021 Posted March 26, 2021 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 More sharing options...
Nickz Posted March 26, 2021 Posted March 26, 2021 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 More sharing options...
Juan C. Posted March 26, 2021 Posted March 26, 2021 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. 1 Share this post Link to post Share on other sites More sharing options...
Juan C. Posted March 29, 2021 Posted March 29, 2021 Anyone else? Share this post Link to post Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now