2

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 1

4

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
  • 1
    onAfterInitialise is not the proper event to add your custom class path its onAfterRoute then only you will be able to get JRequest::getCMD('option') ..
    – Jobin
    Jan 24, 2015 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.