User Tools

Site Tools


How To Create an Order Module

Order modules can interact with orders and support several different behaviors.

  class om_my_order_module {
    public $id = __CLASS__;
    public $name = 'My Order Module';
    public $description = 'Order module that does something with order data';
    public $version = '1.0';
    public $author = 'ACME Corp.';
    public $website = '';
    public function actions() {}
    public function validate($order) {}
    public function update($order) {}
    public function before_process($order) {}
    public function after_process($order) {}
    public function success($order) {}
    function settings() {
      return array(
          'key' => 'status',
          'default_value' => '1',
          'title' => 'Status',
          'description' => 'Enables or disables the module.',
          'function' => 'toggle("e/d")',
          'key' => 'priority',
          'default_value' => '0',
          'title' => 'Priority',
          'description' => 'Process this module by the given priority value.',
          'function' => 'int()',
    public function install() {}
    public function uninstall() {}

actions() (Known as Order Action modules in LiteCart 1.x)

The action() method can return a set of action buttons on the orders page that triggers certain methods upon click. Simply select orders from the list and click an action button.

    public function actions() {
      if (empty($this->settings['status'])) return;
      return array(
        'id' => __CLASS__,
        'name' => 'My Actions',
        'description' => 'Click any button to perform an action',
        'actions' => array(
            'id' => 'firstbutton',
            'title' => 'My Button Text',
            'description' => 'Click this button to do something',
            'function' => 'my_fancy_method',
          // Action 2
          // Action 3
          // ...
    public function my_fancy_method($order_ids) {
      foreach($order_ids as $order_id) {
        $order = new ctrl_order($order_id);
        // Custom code to do whatever


The validate method() is called during checkout during validations before the order is processed. An error message returned will prevent the customer from being able to checkout.

    public function validate($order) {
      return array('error' => 'This order is no good');


The before_process() method is called during checkout before saving the order to database.

    public function before_process($order) {
      // Do something ...


The after_process() method is called during checkout after the order is saved to database.

    public function after_process($order) {
      // Do something ...


The update() is an event that is called every time an order is saved.

    public function update($order) {
      // Do something

success() (Known as Order Success modules in LiteCart 1.x)

The success() method can output HTML on the order success page e.g. a sales tracker pixel or a receipt.

    public function success($order) {
      return '<script>...</script>';
how_to_create_an_order_module.txt · Last modified: 2018/02/27 00:42 by