Hiya slabadoo,
Been busy - but here's the first half of the solution for you .... I'm working on v1.3.7 btw
/includes/modules/shipping/flat.php holds the functions that relate to that shipping module
to add the rb information - make this change to flat.php - look for //+BLUEFISH
...
// class methods
function quote($method = '') {
global $order;
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
'btype' => array('RES' => 'Residential', //+BLUEFISH
'BUS' => 'Business'), //+BLUEFISH
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
'cost' => MODULE_SHIPPING_FLAT_COST)));
...
Now to make the rbs appear on the shipping screen you have to change file :
/includes/templates/<yourtemplate>/templates/tpl_checkout_shipping_default.php
this page takes all the shipping module information we just set up and displays it
modification required to display the new radio buttons
....
<?php echo zen_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked, 'id="ship-'.$quotes[$i]['id'] . '-' . $quotes[$i]['methods'][$j]['id'].'"'); ?>
<label for="ship-<?php echo $quotes[$i]['id'] . '-' . $quotes[$i]['methods'][$j]['id']; ?>" class="checkboxLabel" ><?php echo $quotes[$i]['methods'][$j]['title']; ?></label>
<!--</div>-->
<br class="clearBoth" />
<?php
//+BLUEFISH output rbs if it has been set for current shipping method
if (isset($quotes[$i]['btype']))
{
// set default option to be selected
if (! isset($_SESSION['shipping'][$quotes[$i]['id'] . '_' .'btype'])){
$_SESSION['shipping'][$quotes[$i]['id'] . '_' .'btype'] = $quotes[$i]['id'] . '_' . 'RES';
}
echo "<b>What type of purchase is this?</b>"; // define this in your language file ....
foreach($quotes[$i]['btype'] as $btypeKey => $btypeValue )
{
$checked = (($quotes[$i]['id'] . '_' . $btypeKey == $_SESSION['shipping'][$quotes[$i]['id'] . '_' .'btype']) ? true : false);
echo '<br>' . zen_draw_radio_field($quotes[$i]['id'] . '_' . $btypeKey, $checked, $checked) . ' ' . $btypeValue;
}
}
// +BLUEFISH end output rbs
$radio_buttons++;
}
}
?>
....
Now you need to pick up the value of the selected option and save this to your database - I don't have enough time to finish this now .. but you'll need to look at the value of
$POST['shipping'][$quotes[$i]['id'] . '_' .'btype']
which basically means for flat rate - if they select RES then
$POST['shipping']['flat_btype'] = 'RES'
you'll have to do this in file
/includes/languages/modules/pages/checkout_shipping/header_php.php
probably somewhere around here ....
...
// process the selected shipping method
if ( isset($_POST['action']) && ($_POST['action'] == 'process') ) {
if (zen_not_null($_POST['comments'])) {
$_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
...
And then when the order is saved and confirmed you'll have to post this information to the database.
You can either hack this into file
includes/modules/checkout_process.php
this is the code that commits the order to the database
...
// load the before_process function from the payment modules
$payment_modules->before_process();
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_PAYMENT_MODULES_BEFOREPROCESS');
// create the order record
$insert_id = $order->create($order_totals, 2);
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE');
$payment_modules->after_order_create($insert_id);
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_PAYMENT_MODULES_AFTER_ORDER_CREATE');
// store the product info to the order
$order->create_add_products($insert_id);
$_SESSION['order_number_created'] = $insert_id;
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE_ADD_PRODUCTS');
//send email notifications
$order->send_order_email($insert_id, 2);
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL');
...
Or you can use the Zen Cart event listener system to listen for an order being saved - event
'NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE_ADD_PRODUCTS' (see above)
if i get time i'll carry on with this unless someone else feels like finishing this off!