User Tools

Site Tools


how_to_create_a_shipping_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_shipping_module [2020/07/09 00:26]
admin [options($items, $subtotal, $tax, $currency_code, $customer)]
how_to_create_a_shipping_module [2020/08/09 03:28] (current)
A User Not Logged in old revision restored (2015/04/19 07:24)
Line 1: Line 1:
-====== How To Create A Shipping Module ======+====== How To Create A shipping Module ======
  
 ===== A Basic Example ===== ===== A Basic Example =====
Line 69: Line 69:
         ),         ),
         array(         array(
-          'key' => 'fee_2',+          'key' => 'fee_1',
           'default_value' => '10',           'default_value' => '10',
-          'title' => 'Fee 2',+          'title' => 'Fee 1',
           'description' => 'This is the fee for option 2',           'description' => 'This is the fee for option 2',
           'function' => 'decimal()',           'function' => 'decimal()',
Line 112: Line 112:
             'name' => 'Option 1',             'name' => 'Option 1',
             'description' => 'This is the description for option 1',             'description' => 'This is the description for option 1',
-            'fields' => '<input type="text" name="foo" value="'. @$this->userdata['foo'] .'" />' . PHP_EOL +            'fields' => '',
-                      . '<input type="text" name="bar" value="'. @$this->userdata['bar'] .'" />',+
             'cost' => $this->settings['fee_1'],             'cost' => $this->settings['fee_1'],
             'tax_class_id' => $this->settings['tax_class_id'],             'tax_class_id' => $this->settings['tax_class_id'],
             'exclude_cheapest' => false,             'exclude_cheapest' => false,
-            'error' => '', 
           ),           ),
         ),         ),
       );       );
-    } 
-</file> 
- 
-==== before_select($postfields) ==== 
- 
-To validate the user input you can return an error in the method before_select(). 
- 
-<file|php> 
-    public function before_select($postfields) { 
-      try { 
-        if ($postfields['foo'] != '1234') throw new Exception('Invalid user input'); 
-      } catch (Exception $e) { 
-        return array('error' => $e->getMessage()); 
-      } 
     }     }
 </file> </file>
Line 191: Line 175:
 ==== settings() ==== ==== settings() ====
  
-This method returns a settings structure with editable parameters. Mandatory parameters are status, icon and priority. The functions supported are listed in func_form.inc.php form_draw_function().+This method returns a settings structure with editable parameters. Mandatory parameters are status, icon and priority.
  
 <file php> <file php>
how_to_create_a_shipping_module.1594247191.txt.gz · Last modified: 2020/07/09 00:26 by admin