User Tools

Site Tools


how_to_create_an_order_action_module

How To Create An Order Action Module

Note: Order Action modules are part of the Order Modules in LiteCart 2.0+. See How To Convert An Order Action Module To Order Module.

Order action modules gives you the option to perform different actions on selected orders inside the administration panel. In the list of orders at Admin → Orders you will find installed order action modules at the bottom.

Here goes an example of an order action module.

<?php
  
  class oa_hello_world {
    public $id = __CLASS__;
    public $name = 'Hello World';
    public $description = '';
    public $version = '1.0';
    public $author = 'ACME Inc.';
    public $website = 'http://www.acme.com';
    
    function options() {
      if (empty($this->settings['status'])) return;
      
      return array(
        'id' => $this->id,
        'name' => $this->name,
        'options' => array(
          array(
            'id' => 'foobar',
            'title' => 'Hello World',
            'function' => 'helloworld',
            'target' => '_self',
          ),
        ),
      );
    }
    
    public function helloworld($order_ids) {
      echo 'Hello World';
      
      print_r($order_ids);
      
      exit;
    }
    
    function settings() {
      return array(
        array(
          'key' => 'status',
          'default_value' => '1',
          'title' => language::translate(__CLASS__.':title_status', 'Status'),
          'description' => language::translate(__CLASS__.':description_status', 'Enables or disables the module.'),
          'function' => 'toggle("e/d")',
        ),
        array(
          'key' => 'priority',
          'default_value' => '0',
          'title' => language::translate(__CLASS__.':title_priority', 'Priority'),
          'description' => language::translate(__CLASS__.':description_priority', 'Process this module by the given priority value.'),
          'function' => 'int()',
        ),
      );
    }
    
    public function install() {}
    
    public function uninstall() {}
  }
  
?>

The first parameter sent to your function contains an array of selected order ids. It is up to you what you are going to do to them.

how_to_create_an_order_action_module.txt · Last modified: 2017/04/27 00:23 by admin