Tom S. Posted March 14, 2019 Share Posted March 14, 2019 Hello, As I understand it, I can extend a class using code hooks in plugins. So, if I wanted to modify a method for the cart class I could do this inside of my plugin: class cart extends _HOOK_CLASS_ { protected function clear() { // some code } } Am I right in thinking I will completely override the clear() method with that? My question is how can I add some extra functionality to the clear() method without completely overriding it? Say, for example, I wanted to add an extra line to that method making a change to a table in the database (but keep the rest of the functionality the same). How could I do that? I read that just copying the entire method into my hook is against the terms. Thanks. Link to comment Share on other sites More sharing options...
Aiwa Posted March 14, 2019 Share Posted March 14, 2019 // your code return parent::clear(); Or the opposite, if you need to manipulate the data.. $return = parent::clear(); // your code return $return; Link to comment Share on other sites More sharing options...
Daniel F Posted March 14, 2019 Share Posted March 14, 2019 Depending on what you want to accomplish you'll need to run your code before or after you call parent::clear(); ( which will then execute the original clear method) Link to comment Share on other sites More sharing options...
Tom S. Posted March 14, 2019 Author Share Posted March 14, 2019 Awesome! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.