Saturday 24 March 2012

How to install vQmod on OpenCart?

What is vQmod?
"vQmod™" (aka Virtual Quick Mod) is an override system designed to avoid having to change core files. The concept is quite simple... Instead of making changes to the core files directly, the changes are created as xml search/replace script files. 

For example instead to change the template's header file catalog/view/theme/default/template/common/header.tpl,

it's much more safer to create script that will do the change.

The main benefit of using vQmod is that you can safely update opencart and you don't need to worry about all HTML/PHP patches and hacks that you have done on it. They are safely stored as xml scripts in /vqmod/xml folder. If there is any difference in the new OpenCart version you just have to set correct searching and replacing string in the xml script and it will work the same as before.


How to install using Autoinstaller - (Didn't work for me)

  1. Download the latest version that has "opencart" in the title from
  2. Using FTP, upload the "vqmod" folder from the zip to the root of your opencart store.
  3. Be sure the vqmod folder and the vqmod/vqcache folders are writable (either 755 or 777).
    • Also be sure index.php and admin/index.php are writable.
      • If not sure which you need, first try 755.
      • If you get errors about permissions, then try 777.
  4. Goto http://www.yoursite.com/vqmod/install
  5. You should get a success message. If not, check permissions above and try again
  6. Load your store homepage and verify it works.
  7. Using FTP, verify that there are new "vq" files in the "vqmod/vqcache" folder.
  8. If yes, then you are ready to start downloading or creating vQmod scripts, otherwise ask for assistance.
Done!


Well NOT DONE. 
This method didn't work for me, I deleted .htaccess file in the vqmod folder, but still wasn't able to access http://www.yoursite.com/vqmod/install. The browser kept saying Internal server error. 




How to install Manually - (worked for me)

Backup your main site / index.php and admin/index.php before continue.
  1. Download the latest version that has "opencart" in the title from
  2. Using FTP, upload the "vqmod" folder from the zip to the root of your opencart store.
  3. Be sure the vqmod folder and the vqmod/vqcache folders are writable (either 755 or 777).
    • Also be sure index.php and admin/index.php are writable.
      • If not sure which you need, first try 755.
      • If you get errors about permissions, then try 777.
  4. Edit your index.php file
  5. FIND:
  6. // Startup
    require_once(DIR_SYSTEM . 'startup.php');
    // Application Classes
    require_once(DIR_SYSTEM . 'library/customer.php');
    require_once(DIR_SYSTEM . 'library/currency.php');
    require_once(DIR_SYSTEM . 'library/tax.php');
    require_once(DIR_SYSTEM . 'library/weight.php');
    require_once(DIR_SYSTEM . 'library/length.php');
    require_once(DIR_SYSTEM . 'library/cart.php');
    require_once(DIR_SYSTEM . 'library/affiliate.php');
  7. REPLACE WITH:
  8. // vQmod
    require_once('./vqmod/vqmod.php');
    $vqmod = new VQMod();
    // VQMODDED Startup
    require_once($vqmod->modCheck(DIR_SYSTEM . 'startup.php'));
    // Application Classes
    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/customer.php'));
    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/currency.php'));
    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/tax.php'));
    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/weight.php'));
    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/length.php'));
    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/cart.php'));
    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/affiliate.php'));
Note the affiliate library file may not exist on older systems. Basically any require_once(DIR_SYSTEM . 'library/xxxxxxxx.php');needs to be changed to use the vqmod->modCheck above in the same format. This also applies to any additional require_once files in the next step
  1. Edit your admin/index.php file
  2. FIND:
  3. // Startup
    require_once(DIR_SYSTEM . 'startup.php');
    // Application Classes
    require_once(DIR_SYSTEM . 'library/currency.php');
    require_once(DIR_SYSTEM . 'library/user.php'));
    require_once(DIR_SYSTEM . 'library/weight.php');
    require_once(DIR_SYSTEM . 'library/length.php');
  4. REPLACE WITH:
  5. // vQmod
    require_once('../vqmod/vqmod.php');
    $vqmod = new VQMod();
    // VQMODDED Startup
    require_once($vqmod->modCheck(DIR_SYSTEM . 'startup.php'));
    // Application Classes
    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/currency.php'));
    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/user.php'));
    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/weight.php'));
    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/length.php'));
  6. Load your store homepage and verify it works.
  7. Using FTP, verify that there are new "vq" files in the "vqmod/vqcache" folder.
  8. If yes, then you are ready to start downloading or creating vQmod scripts.
Done!

This method worked. The only warning to this method is that every time u upgrade your opencart you have to modify manually these 2 index.php files.


The next post I will publish some useful vQMod scripts