Issues, Issues with OSCommerce, checkout, and orders.

Hi,

I have posted numerous times in the OSC forums, with no help. Tons of views, just no HELP. My store has been down for 3 days now, and I am no closer to a solution then when I started. Yes, I am green to this, I DON’T know what I am doing, but I am TRYING to learn. Currently, I though everything was working Ok. I did several “test” purchases, everything seemed to work. I didn’t see any orders in my admin panel, but I expected that because it wasn’t a “real” order. When I launched my store, people were able to checkout, but the orders did not store to (or even hit) my database. I called my hosting company, nope database is fine. Called my virtual terminal company, nope, terminal behaved correctly. So, it’s a coding issue, and probably in my orders.php file. WHAT the error is, I have NO CLUE. I did take out the coding for the tables (for this post, not in the actual php file) because the file was just too big to fit, but it gives you the part where the error more than likely is.

Here is my code (That came pre-installed with OSC):

[php]<?php
/*
$Id$

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

Copyright © 2010 osCommerce

Released under the GNU General Public License
*/

require(‘includes/application_top.php’);

require(DIR_WS_CLASSES . ‘currencies.php’);
$currencies = new currencies();

$orders_statuses = array();
$orders_status_array = array();
$orders_status_query = tep_db_query(“select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '” . (int)$languages_id . “’”);
while ($orders_status = tep_db_fetch_array($orders_status_query)) {
$orders_statuses[] = array(‘id’ => $orders_status[‘orders_status_id’],‘text’ => $orders_status[‘orders_status_name’]);
$orders_status_array[$orders_status[‘orders_status_id’]] = $orders_status[‘orders_status_name’];
}

$action = (isset($HTTP_GET_VARS[‘action’]) ? $HTTP_GET_VARS[‘action’] : ‘’);

if (tep_not_null($action))
switch ($action){
case ‘update_order’:
$oID = tep_db_prepare_input($HTTP_GET_VARS[‘oID’]);
$status = tep_db_prepare_input($HTTP_POST_VARS[‘status’]);
$comments = tep_db_prepare_input($HTTP_POST_VARS[‘comments’]);}

    $order_updated = false;
    $check_status_query = tep_db_query("select customers_name, customers_email_address, orders_status, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
    $check_status = tep_db_fetch_array($check_status_query);

    if ( ($check_status['orders_status'] != $status) || tep_not_null($comments)) 
      tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . tep_db_input($status) . "', last_modified = now() where orders_id = '" . (int)$oID . "'");

      $customer_notified = '0';
      if (isset($HTTP_POST_VARS['notify']) && ($HTTP_POST_VARS['notify'] == 'on')) 
        $notify_comments = '';
        if (isset($HTTP_POST_VARS['notify_comments']) && ($HTTP_POST_VARS['notify_comments'] == 'on')) {
          $notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $comments) . "\n\n";
        }

        $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]);

        tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

        $customer_notified = '1';
      

      tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int)$oID . "', '" . tep_db_input($status) . "', now(), '" . tep_db_input($customer_notified) . "', '" . tep_db_input($comments)  . "')");

      $order_updated = true;
    

    if ($order_updated == true) {
     $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
    } else {
      $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');
    }

    tep_redirect(tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action')) . 'action=>edit'));
        break;
  case 'deleteconfirm':
    $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);

    tep_remove_order($oID, $HTTP_POST_VARS['restock']);

    tep_redirect(tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action'))));
    break;

if (($action == ‘edit’) && isset($HTTP_GET_VARS[‘oID’])) {
$oID = tep_db_prepare_input($HTTP_GET_VARS[‘oID’]);

$orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
$order_exists = true;
if (!tep_db_num_rows($orders_query)) {
  $order_exists = false;
  $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error');
}

}

include(DIR_WS_CLASSES . ‘order.php’);

require(DIR_WS_INCLUDES . ‘template_top.php’);
?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php if (($action == 'edit') && ($order_exists == true)) { $order = new order($oID);} ?> <?php require(DIR_WS_INCLUDES . 'template_bottom.php'); require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service