This is maybe a suggestion for version 1.x,
we should have the ability to specify customer facing options in the checkout_shipping page, that update the price accordingly.
This could be done via an AJAX request that calls a specific function in the shipping module passing in the options chosen. This function then returns the price and the page is updated automatically.
So, as well as quote() the shipping class would have a function like:
Code: Select all
public function AjaxQuote(){
//Get options
$options = $this->request('options','get');
//get anything else we need
$blah = $this->blah();
$etc = $etc->etc;
$cost = $this->pickANumber();
return json_encode($cost);
}
The original $method_data array returned by the module would need to contain an 'options' field to specify available options.
something like:
Code: Select all
$method_data = array(
'id' => 'ordercost',
'title' => $this->language->get('text_ordercost_title'),
'quote' => $quote_data,
'tax_class_id' => $this->config->get('ordercost_tax_class_id'),
'sort_order' => $this->config->get('ordercost_sort_order'),
'error' => false
'options' => array(
'location'=>array(
'type'=>'select',
'options'=>array(
'UK_MAIN'=> 'UK Mainland',
'IRL_HIGH'=> 'Northern Irland and Scottish Isles')))
);
Which could be rendered by the checkout_shipping.tpl by using a foreach...
Code: Select all
foreach($method['options'] as $key=>$option){
switch($option['type']){
case 'select':
?>
<SELECT name="<?=$key?>">
<?foreach ($option['options'] as $k=>$selectOption){?>
<option value="<?=$k?>"><?=$selectOption?></option>
<?}?>
<?
break;
}
The user could then select options and hit an update button, which submits a javascript function that grabs the form info and uses a HTTP Request to plonk it into the shipping->AjaxQuote() function.
Any of this make sense? Or am I rambling crap on a Monday morning
M