Online Merchant v2.4 Joli

Apps OSC\Apps\

Introduction

Apps are self-contained packages that add new features and extend existing features without the need to edit core source code files. All files of an App are located in one main directory, with an external public directory for public resources (eg, images, javascript, stylesheets, ..).

Structure

Apps are located in the following directory:

includes/OSC/Apps/VENDOR/APP

Files that need to be publicly accessible are located at:

public/Apps/VENDOR/APP

A JSON structured oscommerce.json metadata file must exist in the top level App directory that describes the App and the modules it makes available. Modules do not need to exist in a specific directory within the package - rather the namespace is defined in the metadata file which the framework uses as a reference to find the location of the module class file.

For security reasons, modules that are not described in the App metadata file will not be loaded by the framework.

Metadata File Example: osCommerce\Core

{
  "title":            "osCommerce Core Modules",
  "app":              "Core",
  "vendor":           "osCommerce",
  "version":          1.0.0,
  "req_core_version": 2.4.0,
  "license":          "MIT",
  "authors": [
    {
      "name":    "osCommerce",
      "company": "osCommerce",
      "email":   "[email protected]",
      "website": "https://www.oscommerce.com"
    }
  ],
  "modules": {
    "Payment": {
      "COD": "Module\\Payment\\COD"
    },
    "Shipping": {
      "Flat":  "Module\\Shipping\\Flat",
      "Zones": "Module\\Shipping\\Zones"
    },
    "Hooks": {
      "Shop/Cart": {
        "AdditionalCheckoutButtons": "Module\\Hooks\\Shop\\Cart\\AdditionalCheckoutButtons"
      }
    }
  },
  "routes": {
    "Admin": "Sites\\Admin\\Pages\\Home",
    "Shop": {
      "new-offers": "Sites\\Shop\\Pages\\NewOffers",
      "account&coupons": "Sites\\Shop\\Pages\\Coupons"
    }
  }
}

Namespaces defined in the modules section are based from the Apps own namespace level - a namespace of Module\Payment\COD has a full namespace class of OSC\OM\Apps\VENDOR\APP\Module\Payment\COD.

Namespaces must also be escaped appropiately according to the JSON specification otherwise the metadata file will not be readable. This means the PHP namespace separator must consist of two backslash characters instead of one.

Metadata Schema

Parameter Description
title The public title of the App.
app The internal name of the App. This must be one word and match the APP directory name of the App.
vendor The vendor / company name of the App. This must be one word and match the VENDOR directory name of the App.
version The version of the App. This must be in X.Y.Z format.
req_core_version The minimum osCommerce Online Merchant version required for the App. This must be in X.y.Z format.
license The license the App is released under. Examples:
  • GPL
  • LGPL
  • MIT
  • proprietary
authors A list of authors containing the following for each author:
  • name
  • company
  • email
  • website
modules A list of modules the App makes available. Each module type has its own specification - please refer to the Modules section for more information.
routes A list of url based routes that load App Page controllers. Each Site has its own specification - please refer to the Routes section for more information.

Modules that are installed and registered in the database are not stored with their full namespace class names, rather with an alias as defined in the metadata file.

For example, the core Cash on Delivery payment module is stored in the MODULE_PAYMENT_INSTALLED configuration parameter as osCommerce\Core\COD. The payment class knows that a payment module is being requested and looks up the COD alias defined in the metadata file to retrieve the class as Module\Payment\COD. The full class name reference and file location would be:

Namespace Class Location
OSC\Apps\osCommerce\Core\Module\Payment\COD includes/OSC/Apps/osCommerce/Core/Module/Payment/COD.php

Modules

Modules that are to be made available to the framework must be defined in the Apps metadata file. Each module type has its own definition specification to be able to load the module class on request simply by referencing an alias.

Each module must implement a module type interface which dictates the functions the module must make available to the framework. Module Type Interfaces are located in the following namespace and directory:

Namespace Directory
OSC\OM\Modules\ includes/OSC/OM/Modules/
Module Types and Interfaces

The following Module Types are available in the core:

Module Types
AdminDashboard
Administration Dashboard modules.
Interface
OSC\OM\Modules\AdminDashboardAbstract
OSC\OM\Modules\AdminDashboardInterface

Metadata JSON

"app": "Core",
"vendor": "osCommerce",
"modules": {
  "AdminDashboard": {
    "NewOrders": "Module\\Admin\\Dashboard\\NewOrders",
    "NewCustomers": "Module\\Admin\\Dashboard\\NewCustomers"
  }
}

Specification

"modules": {
  "AdminDashboard": {
    "ALIAS": "CLASS"
  }
}

Reference

VENDOR \ APP \ ALIAS

osCommerce\Core\NewOrders
osCommerce\Core\NewCustomers
AdminMenu
Administration Menu modules.
Interface
OSC\OM\Modules\AdminMenuInterface

Metadata JSON

"app": "Core",
"vendor": "osCommerce",
"modules": {
  "AdminMenu": {
    "Products": "Module\\Admin\\Menu\\Products",
    "Orders": "Module\\Admin\\Menu\\Orders"
  }
}

Specification

"modules": {
  "AdminMenu": {
    "ALIAS": "CLASS"
  }
}

Reference

VENDOR \ APP \ ALIAS

osCommerce\Core\Products
osCommerce\Core\Orders
Content
Content modules.
Interface
OSC\OM\Modules\ContentInterface

Metadata JSON

"app": "Core",
"vendor": "osCommerce",
"modules": {
  "Content": {
    "login": {
      "Social": "Module\\Content\\SocialLogin"
    }
  }
}

Specification

"modules": {
  "Content": {
    "CONTENT MODULE GROUP": {
      "ALIAS": "CLASS"
    }
  }
}

Reference

CONTENT MODULE GROUP / VENDOR \ APP \ ALIAS

login/osCommerce\Core\Social
Hooks
Hook modules.
Interface
OSC\OM\Modules\HooksInterface

Metadata JSON

"app": "Core",
"vendor": "osCommerce",
"modules": {
  "Hooks": {
    "Shop/Account": {
      "Logout": "Module\\Hooks\\Shop\\Account\Logout"
    }
  }
}

Specification

"modules": {
  "Hooks": {
    "SITE / GROUP": {
      "ACTION": "CLASS"
    }
  }
}

Reference

VENDOR \ APP \ SITE / GROUP \ ACTION

osCommerce\Core\Shop/Account\Logout
Payment
Payment modules.
Interface
OSC\OM\Modules\PaymentInterface

Metadata JSON

"app": "Core",
"vendor": "osCommerce",
"modules": {
  "Payment": {
    "COD": "Module\\Payment\\COD"
  }
}

Specification

"modules": {
  "Payment": {
    "ALIAS": "CLASS"
  }
}

Reference

VENDOR \ APP \ ALIAS

osCommerce\Core\COD
Shipping
Shipping modules.
Interface
OSC\OM\Modules\ShippingInterface

Metadata JSON

"app": "Core",
"vendor": "osCommerce",
"modules": {
  "Shipping": {
    "Flat": "Module\\Shipping\\Flat"
  }
}

Specification

"modules": {
  "Shipping": {
    "ALIAS": "CLASS"
  }
}

Reference

VENDOR \ APP \ ALIAS

osCommerce\Core\Flat

The selected shipping method is added to the reference appending the ALIAS with an underscore and the code of the selected shipping method. For example:

VENDOR \ APP \ ALIAS _ SHIPPING_METHOD

DHL\Shipping\National_Express
OrderTotal
Order Total modules.
Interface
OSC\OM\Modules\OrderTotalInterface

Metadata JSON

"app": "Core",
"vendor": "osCommerce",
"modules": {
  "OrderTotal": {
    "Subtotal": "Module\\OrderTotal\\Subtotal"
  }
}

Specification

"modules": {
  "OrderTotal": {
    "ALIAS": "CLASS"
  }
}

Reference

VENDOR \ APP \ ALIAS

osCommerce\Core\Subtotal
Getting Class Names

The full namespace class name of a module can be retrieved via its alias using Apps::getModuleClass():

use OSC\OM\Apps;

$class = Apps::getModuleClass('osCommerce\Core\COD', 'Payment');

// $class = OSC\Apps\osCommerce\Core\Module\Payment\COD

Parameters

Apps::getModuleClass($module, $type)
Parameter Value
$module The alias of the module to retrieve the class name from.
$type The module interface type.
Getting Modules

A list of available App modules can be retrieved using Apps::getModules():

use OSC\OM\Apps;

$modules = Apps::getModules('Payment');

Parameters

Apps::getModules($type, $filter_vendor_app, $filter)
Parameter Value
$type The module type to retrieve.
$filter_vendor_app If an App is provided, only modules from that App are returned, otherwise all modules from all Apps are returned. This can be limited to VENDOR for all vendor Apps, or VENDOR\APP for a specific App.
$filter Pass a Module Type specific filter to filter the results with.

Routes

Routes allow Apps to load Page controllers via the Sites route resolver method. The Shop Site allows Apps to load Page controllers depending on the url of the page requested, and the Admin Site allows one main Page controller to be loaded to administrate and configure the App on the Administration Dashboard.

"app": "Core",
"vendor": "osCommerce",
"routes": {
  "Admin": "Sites\\Admin\\Pages\\Home",
  "Shop": {
    "new-offers": "Sites\\Shop\\Pages\\NewOffers",
    "account&coupons": "Sites\\Shop\\Pages\\Coupons"
  }
}