  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: checkout_process.php,v 1.128 2003/05/28 18:00:29 hpdl Exp $ |
| |
| 3 | + | $Id: checkout_process.php 1750 2007-12-21 05:20:28Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
|
|
 |
… |
|
17 | 17 | | $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT)); |
| |
18 | 18 | | tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); |
| |
19 | 19 | | } |
  |
20 | | - | |
| |
21 | | - | if (!tep_session_is_registered('sendto')) { |
| |
22 | | - | tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); |
| |
| 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)); |
|
23 | 24 | | } |
| |
24 | 25 | | |
  |
| 26 | + | // if no shipping method has been selected, redirect the customer to the shipping method selection page |
| |
| 27 | + | if (!tep_session_is_registered('shipping') || !tep_session_is_registered('sendto')) { |
| |
| 28 | + | tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); |
| |
| 29 | + | } |
| |
| 30 | + | |
|
25 | 31 | | if ( (tep_not_null(MODULE_PAYMENT_INSTALLED)) && (!tep_session_is_registered('payment')) ) { |
| |
26 | 32 | | tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); |
| |
27 | 33 | | } |
| |
|
|
 |
… |
|
46 | 52 | | require(DIR_WS_CLASSES . 'order.php'); |
| |
47 | 53 | | $order = new order; |
| |
48 | 54 | | |
  |
| 55 | + | // Stock Check |
| |
| 56 | + | $any_out_of_stock = false; |
| |
| 57 | + | if (STOCK_CHECK == 'true') { |
| |
| 58 | + | for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { |
| |
| 59 | + | if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) { |
| |
| 60 | + | $any_out_of_stock = true; |
| |
| 61 | + | } |
| |
| 62 | + | } |
| |
| 63 | + | // Out of Stock |
| |
| 64 | + | if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($any_out_of_stock == true) ) { |
| |
| 65 | + | tep_redirect(tep_href_link(FILENAME_SHOPPING_CART)); |
| |
| 66 | + | } |
| |
| 67 | + | } |
| |
| 68 | + | |
| |
| 69 | + | $payment_modules->update_status(); |
| |
| 70 | + | |
| |
| 71 | + | if ( ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) { |
| |
| 72 | + | tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL')); |
| |
| 73 | + | } |
| |
| 74 | + | |
|
49 | 75 | | require(DIR_WS_CLASSES . 'order_total.php'); |
| |
50 | 76 | | $order_total_modules = new order_total; |
| |
51 | 77 | | |
| |
|
|
 |
… |
|
66 | 92 | | 'customers_telephone' => $order->customer['telephone'], |
| |
67 | 93 | | 'customers_email_address' => $order->customer['email_address'], |
| |
68 | 94 | | 'customers_address_format_id' => $order->customer['format_id'], |
  |
69 | | - | 'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'], |
| |
| 95 | + | 'delivery_name' => trim($order->delivery['firstname'] . ' ' . $order->delivery['lastname']), |
  |
70 | 96 | | 'delivery_company' => $order->delivery['company'], |
| |
71 | 97 | | 'delivery_street_address' => $order->delivery['street_address'], |
| |
72 | 98 | | 'delivery_suburb' => $order->delivery['suburb'], |