User Tools

Site Tools


how_to_create_a_customer_module

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
how_to_create_a_customer_module [2020/05/20 22:06]
admin [Get Address]
how_to_create_a_customer_module [2020/05/20 22:07] (current)
admin
Line 38: Line 38:
       );       );
     }     }
 +    ​
 +    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 in the given priority order.'​),​
 +          '​function'​ => '​int()',​
 +        ),
 +      );
 +    }
 +    ​
 +    public function install() {}
 +    ​
 +    public function uninstall() {}
 +  }
 +
 +</​file>​
 +
 +===== Validate Customer Details =====
 +
 +Use a customer module to validate customer details:
 +
 +<file php ~/​includes/​modules/​customer/​cm_validate.inc.php>​
 +<?php
 +
 +  class cm_validate {
 +    public $id = __CLASS__;
 +    public $name = '​Validate Something';​
 +    public $description = '';​
 +    public $author = 'ACME Corp.';​
 +    public $version = '​1.0';​
 +    public $website = '​http://​www.acme.com';​
 +    public $priority = 0;
 +    ​
 +    public function validate($data) {
 +    ​
 +      if (empty($this->​settings['​status'​])) return;
 +      ​
 +    // Validate some data and return an error
 +      if ($something == '​bad'​) {
 +        return array('​error'​ => '​Something is just not good enough'​);​
 +      }
 +    } 
     ​     ​
     function settings() {     function settings() {
how_to_create_a_customer_module.txt ยท Last modified: 2020/05/20 22:07 by admin