Methodology of Extensions

From osCommerce Wiki
Jump to navigation Jump to search

Note: This manual is for osCommerce v4.

Basic Provisions:

1. All extensions must be placed in separate folder.

2. The class file name must be the same as the folder name.

3. Templates must be placed in folder 'views'.

*** Widgets ***

if you want to use widgets in extensions

1. Add method getWidgets with $type parameter and describe widgets in array


return [


               'name' => 'CustomerLoyalty\ShoppingCart', 'title' => 'Customer Loyalty Info Box', 'description' => '', 'type' => 'cart',



in this case ShoppingCart (in subfolder \ShoppingCart) is widget ( ShoppingCart.php) can be used in customizing Themes

2. to show additional settings for widget use method showSettings


   public static function showSettings($settings){

       return self::begin()->render('settings.tpl', ['settings' => $settings]);


*** Bootstrap ***

if you want to use personal controllers

1) Create class in file named Bootstrap.php and place in root directory of your extension

use yii\base\Application;

use yii\base\BootstrapInterface;

class Bootstrap implements BootstrapInterface {

   public function bootstrap($app) {

       \Yii::setAlias('@your-extension-alias', dirname(__FILE__));

       if ($app instanceof \yii\web\Application) {

           if ($app->id == 'app-frontend') {

               $app->controllerMap = array_merge($app->controllerMap, [

                   'frontend-controller' => ['class' => 'common\extensions\your-extension\frontend\controllers\your-controller'],


           } elseif ($app->id == 'app-backend') {

               $app->controllerMap = array_merge($app->controllerMap, [

                   'backend-controller' => ['class' => 'common\extensions\your-extension\backend\controllers\your-controller'],






2) enable your extension and try run index action https://yoursite/frontend-controller

*** Admin menu ***

if you want to use menu in extensions

1. Add method getAdminMenu

*** Hooks ***

if you want to use hooks in extensions


In addition a list of available values page_name and page_area:

'customers/customeredit', ''

'customers/customeredit', 'personal-block'

'customers/customeredit', 'left-column'

'customers/customeredit', 'right-column'

'categories/brandedit', ''

'categories/brandedit', 'tab-navs'

'categories/brandedit', 'tab-content'

'categories/brandedit', 'main-tab'

'categories/brandedit', 'desc-tab'

'categories/brandedit', 'seo-tab'

'categories/productedit', ''

'categories/productedit', 'details-left-column'

'categories/productedit', 'details-right-column'

'categories/categoryedit', ''

'categories/categoryedit', 'tab-navs'

'categories/categoryedit', 'tab-content'

'categories/categoryedit', 'main-tab'

'categories/categoryedit', 'desc-tab'

'categories/categoryedit', 'seo-tab'

'orders/process-order', ''

'orders/process-order', 'totals-block'

'orders/process-order', 'btn-bar-top'

'orders/process-order', 'btn-bar-bottom'

*** Extension installer ***

1) extends \common\classes\modules\ModuleExtensions

2) install (example)

   public function install($platform_id){

       parent::install($platform_id);// install in liek other modules

       // install extention envirenment

       $migration = new \common\classes\Migration;

       $migration->addTranslation(['admin/main'], [

           //add keys




2) ckeck extension enabled - use \common\helpers\Acl::checkExtensionAllowed($extName, 'allowed')

   public static function allowed() {

       return self::enabled();