home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 90 / PIWD90.iso / pc / contents / ecommerce / software / osCommerce.exe / oscommerce-2.2ms2 / catalog / checkout_confirmation.php < prev    next >
PHP Script  |  2003-06-11  |  16KB  |  383 lines

  1. <?php
  2. /*
  3.   $Id: checkout_confirmation.php,v 1.139 2003/06/11 17:34:53 hpdl Exp $
  4.  
  5.   osCommerce, Open Source E-Commerce Solutions
  6.   http://www.oscommerce.com
  7.  
  8.   Copyright (c) 2003 osCommerce
  9.  
  10.   Released under the GNU General Public License
  11. */
  12.  
  13.   require('includes/application_top.php');
  14.  
  15. // if the customer is not logged on, redirect them to the login page
  16.   if (!tep_session_is_registered('customer_id')) {
  17.     $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));
  18.     tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  19.   }
  20.  
  21. // if there is nothing in the customers cart, redirect them to the shopping cart page
  22.   if ($cart->count_contents() < 1) {
  23.     tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
  24.   }
  25.  
  26. // avoid hack attempts during the checkout procedure by checking the internal cartID
  27.   if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
  28.     if ($cart->cartID != $cartID) {
  29.       tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  30.     }
  31.   }
  32.  
  33. // if no shipping method has been selected, redirect the customer to the shipping method selection page
  34.   if (!tep_session_is_registered('shipping')) {
  35.     tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  36.   }
  37.  
  38.   if (!tep_session_is_registered('payment')) tep_session_register('payment');
  39.   if (isset($HTTP_POST_VARS['payment'])) $payment = $HTTP_POST_VARS['payment'];
  40.  
  41.   if (!tep_session_is_registered('comments')) tep_session_register('comments');
  42.   if (tep_not_null($HTTP_POST_VARS['comments'])) {
  43.     $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
  44.   }
  45.  
  46. // load the selected payment module
  47.   require(DIR_WS_CLASSES . 'payment.php');
  48.   $payment_modules = new payment($payment);
  49.  
  50.   require(DIR_WS_CLASSES . 'order.php');
  51.   $order = new order;
  52.  
  53.   $payment_modules->update_status();
  54.  
  55.   if ( ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) {
  56.     tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL'));
  57.   }
  58.  
  59.   if (is_array($payment_modules->modules)) {
  60.     $payment_modules->pre_confirmation_check();
  61.   }
  62.  
  63. // load the selected shipping module
  64.   require(DIR_WS_CLASSES . 'shipping.php');
  65.   $shipping_modules = new shipping($shipping);
  66.  
  67.   require(DIR_WS_CLASSES . 'order_total.php');
  68.   $order_total_modules = new order_total;
  69.  
  70. // Stock Check
  71.   $any_out_of_stock = false;
  72.   if (STOCK_CHECK == 'true') {
  73.     for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
  74.       if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {
  75.         $any_out_of_stock = true;
  76.       }
  77.     }
  78.     // Out of Stock
  79.     if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($any_out_of_stock == true) ) {
  80.       tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
  81.     }
  82.   }
  83.  
  84.   require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_CONFIRMATION);
  85.  
  86.   $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  87.   $breadcrumb->add(NAVBAR_TITLE_2);
  88. ?>
  89. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  90. <html <?php echo HTML_PARAMS; ?>>
  91. <head>
  92. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  93. <title><?php echo TITLE; ?></title>
  94. <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
  95. <link rel="stylesheet" type="text/css" href="stylesheet.css">
  96. </head>
  97. <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
  98. <!-- header //-->
  99. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  100. <!-- header_eof //-->
  101.  
  102. <!-- body //-->
  103. <table border="0" width="100%" cellspacing="3" cellpadding="3">
  104.   <tr>
  105.     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
  106. <!-- left_navigation //-->
  107. <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
  108. <!-- left_navigation_eof //-->
  109.     </table></td>
  110. <!-- body_text //-->
  111.     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  112.       <tr>
  113.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  114.           <tr>
  115.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  116.             <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_confirmation.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  117.           </tr>
  118.         </table></td>
  119.       </tr>
  120.       <tr>
  121.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  122.       </tr>
  123.       <tr>
  124.         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
  125.           <tr class="infoBoxContents">
  126. <?php
  127.   if ($sendto != false) {
  128. ?>
  129.             <td width="30%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  130.               <tr>
  131.                 <td class="main"><?php echo '<b>' . HEADING_DELIVERY_ADDRESS . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
  132.               </tr>
  133.               <tr>
  134.                 <td class="main"><?php echo tep_address_format($order->delivery['format_id'], $order->delivery, 1, ' ', '<br>'); ?></td>
  135.               </tr>
  136. <?php
  137.     if ($order->info['shipping_method']) {
  138. ?>
  139.               <tr>
  140.                 <td class="main"><?php echo '<b>' . HEADING_SHIPPING_METHOD . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
  141.               </tr>
  142.               <tr>
  143.                 <td class="main"><?php echo $order->info['shipping_method']; ?></td>
  144.               </tr>
  145. <?php
  146.     }
  147. ?>
  148.             </table></td>
  149. <?php
  150.   }
  151. ?>
  152.             <td width="<?php echo (($sendto != false) ? '70%' : '100%'); ?>" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  153.               <tr>
  154.                 <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  155. <?php
  156.   if (sizeof($order->info['tax_groups']) > 1) {
  157. ?>
  158.                   <tr>
  159.                     <td class="main" colspan="2"><?php echo '<b>' . HEADING_PRODUCTS . '</b> <a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
  160.                     <td class="smallText" align="right"><b><?php echo HEADING_TAX; ?></b></td>
  161.                     <td class="smallText" align="right"><b><?php echo HEADING_TOTAL; ?></b></td>
  162.                   </tr>
  163. <?php
  164.   } else {
  165. ?>
  166.                   <tr>
  167.                     <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>
  168.                   </tr>
  169. <?php
  170.   }
  171.  
  172.   for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
  173.     echo '          <tr>' . "\n" .
  174.          '            <td class="main" align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
  175.          '            <td class="main" valign="top">' . $order->products[$i]['name'];
  176.  
  177.     if (STOCK_CHECK == 'true') {
  178.       echo tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty']);
  179.     }
  180.  
  181.     if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
  182.       for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
  183.         echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
  184.       }
  185.     }
  186.  
  187.     echo '</td>' . "\n";
  188.  
  189.     if (sizeof($order->info['tax_groups']) > 1) echo '            <td class="main" valign="top" align="right">' . tep_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n";
  190.  
  191.     echo '            <td class="main" align="right" valign="top">' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . '</td>' . "\n" .
  192.          '          </tr>' . "\n";
  193.   }
  194. ?>
  195.                 </table></td>
  196.               </tr>
  197.             </table></td>
  198.           </tr>
  199.         </table></td>
  200.       </tr>
  201.       <tr>
  202.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  203.       </tr>
  204.       <tr>
  205.         <td class="main"><b><?php echo HEADING_BILLING_INFORMATION; ?></b></td>
  206.       </tr>
  207.       <tr>
  208.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  209.       </tr>
  210.       <tr>
  211.         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
  212.           <tr class="infoBoxContents">
  213.             <td width="30%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  214.               <tr>
  215.                 <td class="main"><?php echo '<b>' . HEADING_BILLING_ADDRESS . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
  216.               </tr>
  217.               <tr>
  218.                 <td class="main"><?php echo tep_address_format($order->billing['format_id'], $order->billing, 1, ' ', '<br>'); ?></td>
  219.               </tr>
  220.               <tr>
  221.                 <td class="main"><?php echo '<b>' . HEADING_PAYMENT_METHOD . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
  222.               </tr>
  223.               <tr>
  224.                 <td class="main"><?php echo $order->info['payment_method']; ?></td>
  225.               </tr>
  226.             </table></td>
  227.             <td width="70%" valign="top" align="right"><table border="0" cellspacing="0" cellpadding="2">
  228. <?php
  229.   if (MODULE_ORDER_TOTAL_INSTALLED) {
  230.     $order_total_modules->process();
  231.     echo $order_total_modules->output();
  232.   }
  233. ?>
  234.             </table></td>
  235.           </tr>
  236.         </table></td>
  237.       </tr>
  238. <?php
  239.   if (is_array($payment_modules->modules)) {
  240.     if ($confirmation = $payment_modules->confirmation()) {
  241. ?>
  242.       <tr>
  243.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  244.       </tr>
  245.       <tr>
  246.         <td class="main"><b><?php echo HEADING_PAYMENT_INFORMATION; ?></b></td>
  247.       </tr>
  248.       <tr>
  249.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  250.       </tr>
  251.       <tr>
  252.         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
  253.           <tr class="infoBoxContents">
  254.             <td><table border="0" cellspacing="0" cellpadding="2">
  255.               <tr>
  256.                 <td class="main" colspan="4"><?php echo $confirmation['title']; ?></td>
  257.               </tr>
  258. <?php
  259.       for ($i=0, $n=sizeof($confirmation['fields']); $i<$n; $i++) {
  260. ?>
  261.               <tr>
  262.                 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
  263.                 <td class="main"><?php echo $confirmation['fields'][$i]['title']; ?></td>
  264.                 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
  265.                 <td class="main"><?php echo $confirmation['fields'][$i]['field']; ?></td>
  266.               </tr>
  267. <?php
  268.       }
  269. ?>
  270.             </table></td>
  271.           </tr>
  272.         </table></td>
  273.       </tr>
  274. <?php
  275.     }
  276.   }
  277. ?>
  278.       <tr>
  279.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  280.       </tr>
  281. <?php
  282.   if (tep_not_null($order->info['comments'])) {
  283. ?>
  284.       <tr>
  285.         <td class="main"><?php echo '<b>' . HEADING_ORDER_COMMENTS . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
  286.       </tr>
  287.       <tr>
  288.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  289.       </tr>
  290.       <tr>
  291.         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
  292.           <tr class="infoBoxContents">
  293.             <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  294.               <tr>
  295.                 <td class="main"><?php echo nl2br(tep_output_string_protected($order->info['comments'])) . tep_draw_hidden_field('comments', $order->info['comments']); ?></td>
  296.               </tr>
  297.             </table></td>
  298.           </tr>
  299.         </table></td>
  300.       </tr>
  301.       <tr>
  302.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  303.       </tr>
  304. <?php
  305.   }
  306. ?>
  307.       <tr>
  308.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  309.           <tr>
  310.             <td align="right" class="main">
  311. <?php
  312.   if (isset($$payment->form_action_url)) {
  313.     $form_action_url = $$payment->form_action_url;
  314.   } else {
  315.     $form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');
  316.   }
  317.  
  318.   echo tep_draw_form('checkout_confirmation', $form_action_url, 'post');
  319.  
  320.   if (is_array($payment_modules->modules)) {
  321.     echo $payment_modules->process_button();
  322.   }
  323.  
  324.   echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER) . '</form>' . "\n";
  325. ?>
  326.             </td>
  327.           </tr>
  328.         </table></td>
  329.       </tr>
  330.       <tr>
  331.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  332.       </tr>
  333.       <tr>
  334.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  335.           <tr>
  336.             <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  337.               <tr>
  338.                 <td width="50%" align="right"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
  339.                 <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
  340.               </tr>
  341.             </table></td>
  342.             <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
  343.             <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  344.               <tr>
  345.                 <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
  346.                 <td><?php echo tep_image(DIR_WS_IMAGES . 'checkout_bullet.gif'); ?></td>
  347.                 <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
  348.               </tr>
  349.             </table></td>
  350.             <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  351.               <tr>
  352.                 <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
  353.                 <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
  354.               </tr>
  355.             </table></td>
  356.           </tr>
  357.           <tr>
  358.             <td align="center" width="25%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_DELIVERY . '</a>'; ?></td>
  359.             <td align="center" width="25%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_PAYMENT . '</a>'; ?></td>
  360.             <td align="center" width="25%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
  361.             <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_FINISHED; ?></td>
  362.           </tr>
  363.         </table></td>
  364.       </tr>
  365.     </table></td>
  366. <!-- body_text_eof //-->
  367.     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
  368. <!-- right_navigation //-->
  369. <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
  370. <!-- right_navigation_eof //-->
  371.     </table></td>
  372.   </tr>
  373. </table>
  374. <!-- body_eof //-->
  375.  
  376. <!-- footer //-->
  377. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  378. <!-- footer_eof //-->
  379. <br>
  380. </body>
  381. </html>
  382. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
  383.