VirtueMart - 1.1 Developer's Guide

Page of 44
The Shipping API specification
23
myShipping.cfg.php
 (containing all necessary configuration constant definitions)
When activated in the Shop configuration, this payment module will be loaded on the shipping method
selection screen, beside all other activated shipping modules.
The shipping rate, a user has selected during checkout is passed from step to step by the parameter
shipping_rate_id.
This parameter follows a strcit syntax and must be a string build like this:
ShippingClassName|carrier_name|rate_name|totalshippingcosts|rate_id
For our example the shipping rate id for one rate could be:
myShipping|My Carrier|My Rate Name|45.00
The  last  field  (rate_id)  can  be  left  empty.  The  shipping_rate_id  parameter  is  always  passed  as  an
urlencoded string.
4.2.2. The Shipping API specification
The following is a list of all methods that must be implemented by a shipping module's class file.
string list_rates( Array $d )
Lists all available shipping rates.
Tip
The 
array 
$d
 
contains 
the 
values 
for
the  cart  total  weight  (
$d['weight']
)  and
the  ID  for  the  shipping  address  the  user
has  selected  (
$d['ship_to_info_id']
).  The
ship_to_info_id refers to the field user_info_id in the
tables mos_users OR mos_vm_user_info. Check both
for a matching entry!
float get_rate( Array $d )
Returns the amount for the selected shipping rate by analyzing
the parameter shipping_rate_id.
float get_tax_rate( Array $d )
Returns the tax rate for this shipping module (e.g. 0.16).
boolean validate( Array $d )
Validates the value for the parameter 
shipping_rate_id
usually using isset( 
$_SESSION[$shipping_rate_id]
).
Assumes you have set the value in the function list_rates for
each returned shipping rate.
void write_configuration( Array )
Stores all configuration values for this shipping module in the
configuration file.
string show_configuration( void )
Shows the configuration form for this shipping module in the
shipping module form.
boolean
configfile_writeable( void )