I'm using Virtuemart component and I want to make small changes in helper/cart.php file without core hacking. Is it possible to make some override or extension of the class VirtueMartCart defined in helper/cart.php? How to do it?
1 Answer
Following the example in the Joomla documentation, create a system plugin to override the helper class containing the following code:
class plgSystemComVirtuemartOverride extends JPlugin {
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
}
public function onAfterInitialise () {
$app = JFactory::getApplication();
if('com_virtuemart' == JRequest::getCMD('option')) {
// replace FILENAME with the name of the file you want to override
require_once(dirname(__FILE__) . '/classoverrides/FILENAME.php');
}
}
}
Then create the folder classoverrides
in your Joomla root folder, copy the file in question into it and make your edits.
-
1
onAfterInitialise
is not the proper event to add your custom class path itsonAfterRoute
then only you will be able to getJRequest::getCMD('option')
..– JobinJan 24, 2015 at 10:08