osCommerce前後台訂單無法更新

列印

  這兩天在寫osCommerce購物車,當寫到訂單處理時,發現我前台的歷史訂單,訂單摘要,我的訂單,等等都無法顯示,而後台訂單也都消失沒顯示出來 ,之後就開始我的DEBUG之旅。

  首先我發現後台的訂單序號搜尋,可以查詢到我的訂單,因此我原本是猜想PHP檔案被我改爛掉了,結果之後驗證發現,我的原始碼沒錯,之後我就找向資料庫,發現當我新增一筆資料時,orders_total 他資料並沒有新增,因此我先開啟前台的歷史訂單,開啟account.php檔案,發現卡在以下程式碼:

   $orders_query = tep_db_query("select o.orders_id, o.date_purchased, o.delivery_name, o.delivery_country, o.billing_name, o.billing_country, ot.text as order_total, s.orders_status_name from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_TOTAL . " ot, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$customer_id . "' and o.orders_id = ot.orders_id and ot.class = 'ot_total' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' order by orders_id desc limit 3"); 

  我原本認為是這邊出錯,但之後發現查詢語法沒錯主要是卡在 o.orders_id = ot.orders_id and ot.class這邊,因此我開始去尋找checkout_process.php裡查詢他資料庫新增的情形,

   for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {  
         $sql_data_array = array('orders_id' => $insert_id,
         'title' => $order_totals[$i]['title'],
          'text' => $order_totals[$i]['text'],
         'value' => $order_totals[$i]['value'],
          'class' => $order_totals[$i]['code'], 
          'sort_order' => $order_totals[$i]['sort_order']);
          tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);

  } 

  發現 $order_totals裡面的值是空的,逼不得已我後來去,在無意之中把訂單總計模組全部重啟一次,結果之後新增的訂單就完成了,我想可能是因為網站搬遷的問題,加上我是LINUX和WINDOWS互換造成的結果吧。

最近更新 ( 週四, 09 四月 2009 17:03 )