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?

migrated from stackoverflow.com May 5 '14 at 15:04

This question came from our site for professional and enthusiast programmers.

3

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 its onAfterRoute then only you will be able to get JRequest::getCMD('option') .. – Jobin Jose Jan 24 '15 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy