Jump to content

Code Hooks in Plugins Question


Tom S.

Recommended Posts

Posted

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.

Posted

// your code

return parent::clear();

Or the opposite, if you need to manipulate the data.. 

$return = parent::clear();

// your code

return $return;

Posted

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)

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...