Jump to content



Latest News: (loading..)

- - - - -

New Checkout proceedure - not finnished


  • Please log in to reply
1 reply to this topic

#1   mumme

mumme
  • Validating
  • 121 posts
  • Real Name:magnus andersson
  • Gender:Male
  • Location:Stockholm | sweden

Posted 20 July 2005 - 07:23 PM

Checkout Proceedure

This is my idea on how the chekout_process should be:

shopping_cart ---> loggin
If we use the standard loggin page, you can use if want to work with accounts or with PWA or guestaccount

loggin ---->checkout_shipping.php
the shopping_cart.php is a combination between checkout_shipping.php and checkout_payment.php

From the combine chekout_shipping/payment you will be abel to press confirm order, and then be linked to checkout_confirmation.php

See picture on my version of chekout_shipping:
If picture not working, try this link.
[img]http://www.elhandel.se/image/chekout_new.gif[/img]

HELP NEEDED!!
Im not so clever on PHP so some help should be appreciated to work out some bugs and clean up the code!

I think this can be a great contr. if someone can help me!
I will post my checkout_shipping here. The code is realy messy, because im good on "cut-and-paste" but not so good on programing! ;)

Please help me with this! =)
You can always contact me here, with a PM or an e-mail to:
magnus.andersson@elhandel.se

#2   mumme

mumme
  • Validating
  • 121 posts
  • Real Name:magnus andersson
  • Gender:Male
  • Location:Stockholm | sweden

Posted 20 July 2005 - 07:43 PM

[code]
<?php
/*
 $Id: checkout_shipping.php,v 1.16 2003/06/09 23:03:53 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');
 require('includes/classes/http_client.php');
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_ALTERNATIVE);
class productListBox extends tableBox {
   function productListBox($contents) {
     $this->table_parameters = '';
     $this->tableBox($contents, true);
   }
 }


// if the customer is not logged on, redirect them to the login page
 if (!tep_session_is_registered('customer_id')) {
   $navigation->set_snapshot();
   tep_redirect(tep_href_link(FILENAME_LOGGIN, '', 'SSL'));
 }

// if there is nothing in the customers cart, redirect them to the shopping cart page
 if ($cart->count_contents() < 1) {
   tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
 }

// if no shipping destination address was selected, use the customers own address as default
 if (!tep_session_is_registered('sendto')) {
   tep_session_register('sendto');
   $sendto = $customer_default_address_id;
 } else {
// verify the selected shipping address
   $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$sendto . "'");
   $check_address = tep_db_fetch_array($check_address_query);

   if ($check_address['total'] != '1') {
     $sendto = $customer_default_address_id;
     if (tep_session_is_registered('shipping')) tep_session_unregister('shipping');
   }
 }
// if no billing destination address was selected, use the customers own address as default
 if (!tep_session_is_registered('billto')) {
   tep_session_register('billto');
   $billto = $customer_default_address_id;
 } else {
// verify the selected billing address
   $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$billto . "'");
   $check_address = tep_db_fetch_array($check_address_query);

   if ($check_address['total'] != '1') {
     $billto = $customer_default_address_id;
     if (tep_session_is_registered('payment')) tep_session_unregister('payment');
   }
 }

//Här testar vi att lägga in lite payment info
// Stock Check
 if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
   $products = $cart->get_products();
   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
     if (tep_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
       tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
       break;
     }
   }
 }
 require(DIR_WS_CLASSES . 'order.php');
 $order = new order;
 $total_weight = $cart->show_weight();
 $total_count = $cart->count_contents();
 require(DIR_WS_CLASSES . 'order_total.php');
 $order_total_modules = new order_total;


 

// register a random ID in the session to check throughout the checkout procedure
// against alterations in the shopping cart contents
 if (!tep_session_is_registered('cartID')) tep_session_register('cartID');
 $cartID = $cart->cartID;

// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
 if ($order->content_type == 'virtual') {
   if (!tep_session_is_registered('shipping')) tep_session_register('shipping');
   $shipping = false;
   $sendto = false;
   tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
 }

 $total_weight = $cart->show_weight();
 $total_count = $cart->count_contents();

// load all enabled shipping modules
 require(DIR_WS_CLASSES . 'shipping.php');
 $shipping_modules = new shipping;

 if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) {
   $pass = false;

   switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
     case 'national':
       if ($order->delivery['country_id'] == STORE_COUNTRY) {
         $pass = true;
       }
       break;
     case 'international':
       if ($order->delivery['country_id'] != STORE_COUNTRY) {
         $pass = true;
       }
       break;
     case 'both':
       $pass = true;
       break;
   }

   $free_shipping = false;
   if ( ($pass == true) && ($order->info['total'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
     $free_shipping = true;

     include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_shipping.php');
   }
 } else {
   $free_shipping = false;
 }

// process the selected shipping method
 if ( isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') ) {
   if (!tep_session_is_registered('comments')) tep_session_register('comments');
   if (tep_not_null($HTTP_POST_VARS['comments'])) {
     $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
   }

   if (!tep_session_is_registered('shipping')) tep_session_register('shipping');

   if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) {
     if ( (isset($HTTP_POST_VARS['shipping'])) && (strpos($HTTP_POST_VARS['shipping'], '_')) ) {
       $shipping = $HTTP_POST_VARS['shipping'];

       list($module, $method) = explode('_', $shipping);
       if ( is_object($$module) || ($shipping == 'free_free') ) {
         if ($shipping == 'free_free') {
           $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
           $quote[0]['methods'][0]['cost'] = '0';
         } else {
           $quote = $shipping_modules->quote($method, $module);
         }
         if (isset($quote['error'])) {
           tep_session_unregister('shipping');
         } else {
           if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
             $shipping = array('id' => $shipping,
                               'title' => (($free_shipping == true) ?  $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
                               'cost' => $quote[0]['methods'][0]['cost']);

             tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
           }
         }
       } else {
         tep_session_unregister('shipping');
       }
     }
   } else {
     $shipping = false;
               
     tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
   }    
 }

// get all available shipping quotes
 $quotes = $shipping_modules->quote();

// if no shipping method has been selected, automatically select the cheapest method.
// if the modules status was changed when none were available, to save on implementing
// a javascript force-selection method, also automatically select the cheapest shipping
// method if more than one module is now enabled
 if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest();

 
 // load all enabled payment modules
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment;

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_SHIPPING);
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PAYMENT);
 $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
 $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript"><!--
var selected;

function selectRowEffect(object, buttonselect) {
 if (!selected) {
   if (document.getElementById) {
     selected = document.getElementById('defaultSelected');
   } else {
     selected = document.all['defaultSelected'];
   }
 }

 if (selected) selected.className = 'moduleRow';
 object.className = 'moduleRowSelected';
 selected = object;

// one button is not an array
 if (document.checkout_address.shipping[0]) {
   document.checkout_address.shipping[buttonselect].checked=true;
 } else {
   document.checkout_address.shipping.checked=true;
 }
}

function rowOverEffect(object) {
 if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
 if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}
//--></script>
<?php echo $payment_modules->javascript_validation(); ?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><?php echo tep_draw_form('checkout_address', tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL')) . tep_draw_hidden_field('action', 'process'); ?>
        <table border="0" width="100%" cellspacing="0" cellpadding="0">
       <tr>
         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr>
               <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
               <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_delivery.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
             </tr>
           </table></td>
       </tr>
       <tr>
         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
       </tr>
       
 <?php
//if (isset($HTTP_GET_VARS['payment_error']) && is_object(${$HTTP_GET_VARS['payment_error']}) && ($error = ${$HTTP_GET_VARS['payment_error']}->get_error())) {
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><b><?php echo tep_output_string_protected($error['title']); ?></b></td>
         </tr>
       </table></td>
     </tr>
 
 
 
 <tr>
         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">

         <tr class="infoBoxContents">
           <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

             <tr>
               <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
                 <tr>
                   <td class="main" colspan="3"><?php echo '<b>' . HEADING_PRODUCTS . '</b> <a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
                 </tr>

     <tr>
       <td>
<?php
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART);

   $info_box_contents = array();
   $info_box_contents[0][] = array('params' => 'class="productListing-heading"',
                                   'text' => TABLE_HEADING_PRODUCTS);

   $info_box_contents[0][] = array('align' => 'center',
                                   'params' => 'class="productListing-heading"',
                                   'text' => TABLE_HEADING_QUANTITY);

   $info_box_contents[0][] = array('align' => 'right',
                                   'params' => 'class="productListing-heading"',
                                   'text' => TABLE_HEADING_TOTAL);

   $any_out_of_stock = 0;
   $products = $cart->get_products();
   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
// Push all attributes information in an array
     if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
       while (list($option, $value) = each($products[$i]['attributes'])) {
         echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
                                     from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                     where pa.products_id = '" . $products[$i]['id'] . "'
                                      and pa.options_id = '" . $option . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" . $value . "'
                                      and pa.options_values_id = poval.products_options_values_id
                                      and popt.language_id = '" . $languages_id . "'
                                      and poval.language_id = '" . $languages_id . "'");
         $attributes_values = tep_db_fetch_array($attributes);

         $products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];
         $products[$i][$option]['options_values_id'] = $value;
         $products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name'];
         $products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];
         $products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];
       }
     }
   }

   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
     if (($i/2) == floor($i/2)) {
       $info_box_contents[] = array('params' => 'class="productListing-even"');
     } else {
       $info_box_contents[] = array('params' => 'class="productListing-odd"');
     }

     $cur_row = sizeof($info_box_contents) - 1;

    $products_name = '<table border="0" cellspacing="2" cellpadding="2">' .
                      '  <tr>' .
                      '    <td class="productListing-data" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' .
                      '    <td class="productListing-data" valign="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>' . $products[$i]['name'] . '</b></a>';

     if (STOCK_CHECK == 'true') {
       $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
       if (tep_not_null($stock_check)) {
         $any_out_of_stock = 1;

         $products_name .= $stock_check;
       }
     }

     if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
       reset($products[$i]['attributes']);
       while (list($option, $value) = each($products[$i]['attributes'])) {
         $products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';
       }
     }

     $products_name .= '    </td>' .
                       '  </tr>' .
                       '</table>';

     $info_box_contents[$cur_row][] = array('params' => 'class="productListing-data" valign="center"',
                                            'text' => $products_name);

     $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="center"',
                                            'text' => tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4" disabled="true"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']));

     $info_box_contents[$cur_row][] = array('align' => 'right',
                                            'params' => 'class="productListing-data" valign="center"',
                                            'text' => '<b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b>');
   }

   new productListBox($info_box_contents);
?>

       <tr>
                <td width="100%"  class="infoBoxContents" align="right"><b><font class="infoBoxContents"><?php echo TITLE_TOTAL; ?></font> <? echo  $currencies->format($cart->show_total());?></b></td>

           </table></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
       </tr>
        <tr>
         <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td class="main"><b><?php //echo TABLE_HEADING_SHIPPING_ADDRESS; ?><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></b></td>
             </tr>
           </table></td>
       </tr>
       <tr>
         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
             <tr class="infoBoxContents">
               <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
                   <tr>
                     <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                     <td class="main" width="50%" valign="top"><b><?php echo TABLE_HEADING_SHIPPING_ADDRESS; ?></b><br><?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br>'); ?> <br> <?php echo TEXT_CHOOSE_SHIPPING_DESTINATION1 . '<br><br><a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL') . '">' . tep_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>'; ?></td>
                     <td align="right" width="50%" valign="top"><table border="0" cellspacing="0" cellpadding="2">
                         <tr>
                           <td class="main" align="center" valign="top"><?php echo //'<b>' . TITLE_SHIPPING_ADDRESS . '</b><br>' . tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?></td>
                           <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                           <td class="main" width="50%" valign="top"><b><?php echo TABLE_HEADING_BILLING_POST_ADDRESS; ?></b><br><?php echo tep_address_label($customer_id, $billto, true, ' ', '<br>'); ?> <br> <?php echo TEXT_CHOOSE_SHIPPING_DESTINATION1 . '<br><br><a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL') . '">' . tep_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>'; ?></td>
                           
     
      <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                         </tr>
                       </table></td>
                   </tr>
                 </table></td>
             </tr>
           </table></td>
       </tr>
       <tr>
         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
       </tr>
       <?php
 if (tep_count_shipping_modules() > 0) {
?>
       <tr>
         <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td class="main"><b><?php echo TABLE_HEADING_SHIPPING_METHOD; ?></b></td>
             </tr>
           </table></td>
       </tr>
       <tr>
         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
             <tr class="infoBoxContents">
               <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
                   <?php
   if (sizeof($quotes) > 1 && sizeof($quotes[0]) > 1) {
?>
                   <tr>
                     <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                     <td class="main" width="50%" valign="top"><?php echo TEXT_CHOOSE_SHIPPING_METHOD; ?></td>
                     <td class="main" width="50%" valign="top" align="right"><?php echo '<b>' . TITLE_PLEASE_SELECT . '</b><br>' . tep_image(DIR_WS_IMAGES . 'arrow_east_south.gif'); ?></td>
                     <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                   </tr>
                   <?php
   } elseif ($free_shipping == false) {
?>
                   <tr>
                     <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                     <td class="main" width="100%" colspan="2"><?php echo TEXT_ENTER_SHIPPING_INFORMATION; ?></td>
                     <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                   </tr>
                   <?php
   }

   if ($free_shipping == true) {
?>
                   <tr>
                     <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                     <td colspan="2" width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                         <tr>
                           <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                           <td class="main" colspan="3"><b><?php echo FREE_SHIPPING_TITLE; ?></b>&nbsp;<?php echo $quotes[$i]['icon']; ?></td>
                           <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                         </tr>
                         <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, 0)">
                           <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                           <td class="main" width="100%"><?php echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) . tep_draw_hidden_field('shipping', 'free_free'); ?></td>
                           <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                         </tr>
                       </table></td>
                     <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                   </tr>
                   <?php
   } else {
     $radio_buttons = 0;
     for ($i=0, $n=sizeof($quotes); $i<$n; $i++) {
?>
                   <tr>
                     <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                     <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                         <tr>
                           <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                           <td class="main" colspan="3"><b><?php echo $quotes[$i]['module']; ?></b>&nbsp;
                             <?php if (isset($quotes[$i]['icon']) && tep_not_null($quotes[$i]['icon'])) { echo $quotes[$i]['icon']; } ?>
                           </td>
                           <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                         </tr>
                         <?php
       if (isset($quotes[$i]['error'])) {
?>
                         <tr>
                           <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                           <td class="main" colspan="3"><?php echo $quotes[$i]['error']; ?></td>
                           <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                         </tr>
                         <?php
       } else {
         for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {
// set the radio button to be checked if it is the method chosen
           $checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id']) ? true : false);

           if ( ($checked == true) || ($n == 1 && $n2 == 1) ) {
             echo '                  <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
           } else {
             echo '                  <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
           }
?>
                         <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                         <td class="main" width="75%"><?php echo $quotes[$i]['methods'][$j]['title']; ?></td>
                         <?php
           if ( ($n > 1) || ($n2 > 1) ) {
?>
                         <td class="main"><?php echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))); ?></td>
                         <td class="main" align="right"><?php echo tep_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked); ?></td>
                         <?php
           } else {
?>
                         <td class="main" align="right" colspan="2"><?php echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])) . tep_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']); ?></td>
                         <?php
           }
?>
                         <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                         </tr>
                         <?php
           $radio_buttons++;
         }
       }
?>
                       </table></td>
                     <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                   </tr>
                   <?php
     }
   }
?>
                 </table></td>
             </tr>
           </table></td>
       </tr>
       <tr>
         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
       </tr>
       <?php
 }
?>
        <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><b><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></b></td>
         </tr>
       </table></td>
     </tr>
  <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
 $selection = $payment_modules->selection();

 if (sizeof($selection) > 1) {
?>
             <tr>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td class="main" width="50%" valign="top"><?php echo TEXT_SELECT_PAYMENT_METHOD; ?></td>
               <td class="main" width="50%" valign="top" align="right"><b><?php echo TITLE_PLEASE_SELECT; ?></b><br><?php echo tep_image(DIR_WS_IMAGES . 'arrow_east_south.gif'); ?></td>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
<?php
 } else {
?>
             <tr>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td class="main" width="100%" colspan="2"><?php echo TEXT_ENTER_PAYMENT_INFORMATION; ?></td>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
<?php
 }

 $radio_buttons = 0;
 for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
?>
             <tr>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
   if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {
     echo '                  <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
   } else {
     echo '                  <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
   }
?>
                   <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                   <td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>
                   <td class="main" align="right">
<?php
   if (sizeof($selection) > 1) {
     echo tep_draw_radio_field('payment', $selection[$i]['id']);
   } else {
     echo tep_draw_hidden_field('payment', $selection[$i]['id']);
   }
?>
                   </td>
                   <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                 </tr>
<?php
   if (isset($selection[$i]['error'])) {
?>
                 <tr>
                   <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                   <td class="main" colspan="4"><?php echo $selection[$i]['error']; ?></td>
                   <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                 </tr>
<?php
   } elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {
?>
                 <tr>
                   <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                   <td colspan="4"><table border="0" cellspacing="0" cellpadding="2">
<?php
     for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
?>
                     <tr>
                       <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                       <td class="main"><?php echo $selection[$i]['fields'][$j]['title']; ?></td>
                       <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                       <td class="main"><?php echo $selection[$i]['fields'][$j]['field']; ?></td>
                       <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                     </tr>
<?php
     }
?>
                   </table></td>
                   <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                 </tr>
<?php
   }
?>
               </table></td>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
<?php
   $radi