[Svn-src-all:1249] [version-2_5-dev 20138] リファクタリング #981

kimoto admin @ mail.ec-cube.net
2011年 2月 11日 (金) 18:56:57 JST


Subversion committed to /home/svn/open 20138
http://svn.ec-cube.net/open_trac/changeset/20138
┌────────────────────────────┐
│更新者 :  kimoto                                       │
│更新日時:  2011-02-11 18:56:57 +0900 (金, 11  2月 2011)│
└────────────────────────────┘

Log:
--------------------------------------------------------
リファクタリング #981


Changed:                      [U:修正,A:追加,D:削除]
--------------------------------------------------------
U   branches/version-2_5-dev/data/class/pages/mypage/LC_Page_Mypage_Order.php

変更: branches/version-2_5-dev/data/class/pages/mypage/LC_Page_Mypage_Order.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/mypage/LC_Page_Mypage_Order.php	2011-02-11 09:09:38 UTC (rev 20137)
+++ branches/version-2_5-dev/data/class/pages/mypage/LC_Page_Mypage_Order.php	2011-02-11 09:56:57 UTC (rev 20138)
@@ -63,23 +63,16 @@
      */
     function action() {
         $objCustomer = new SC_Customer();
-        $objCartSess = new SC_CartSession();
 
         //受注詳細データの取得
-        $arrDisp = $this->lfGetOrderDetail($_POST['order_id']);
+        $arrOrderDetail = $this->lfGetOrderDetail($_POST['order_id']);
 
         //ログインしていない、またはDBに情報が無い場合
-        if (!$objCustomer->isLoginSuccess(true) or count($arrDisp) == 0){
+        if (!$objCustomer->isLoginSuccess(true) || empty($arrOrderDetail)){
             SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
         }
 
-        for($num = 0; $num < count($arrDisp); $num++) {
-            $product_class_id = $arrDisp[$num]['product_class_id'];
-            $quantity = $arrDisp[$num]['quantity'];
-            $product_type_id = $arrDisp[$num]['product_type_id'];
-
-            $objCartSess->addProduct($product_class_id, $quantity, $product_type_id);
-        }
+        $this->lfAddCartProducts($arrOrderDetail);
         SC_Response_Ex::sendRedirect(CART_URLPATH);
     }
 
@@ -94,19 +87,34 @@
 
     // 受注詳細データの取得
     function lfGetOrderDetail($order_id) {
-        $objQuery = new SC_Query();
-        $objCustomer = new SC_Customer();
+        $objQuery       = SC_Query::getSingletonInstance();
+
+        $objCustomer    = new SC_Customer();
         //customer_idを検証
-        $customer_id = $objCustomer->getValue("customer_id");
-        $order_count = $objQuery->count("dtb_order", "order_id = ? and customer_id = ?", array($order_id, $customer_id));
+        $customer_id    = $objCustomer->getValue("customer_id");
+        $order_count    = $objQuery->count("dtb_order", "order_id = ? and customer_id = ?", array($order_id, $customer_id));
         if ($order_count != 1) return array();
-        $col = "product_class_id, quantity, product_type_id";
-        $table = "dtb_order_detail LEFT JOIN dtb_products_class USING(product_class_id)";
-        $where = "order_id = ?";
+
+        $col    = "product_class_id, quantity, product_type_id";
+        $table  = "dtb_order_detail LEFT JOIN dtb_products_class USING(product_class_id)";
+        $where  = "order_id = ?";
         $objQuery->setOrder("product_class_id");
-        $arrRet = $objQuery->select($col, $table, $where, array($order_id));
-        return $arrRet;
+        $arrOrderDetail = $objQuery->select($col, $table, $where, array($order_id));
+        return $arrOrderDetail;
     }
 
+    // 商品をカートに追加
+    function lfAddCartProducts($arrOrderDetail) {
+
+        $objCartSess = new SC_CartSession();
+        foreach($arrOrderDetail as $order_row) {
+
+            $objCartSess->addProduct($order_row['product_class_id'],
+                                     $order_row['quantity'],
+                                     $order_row['product_type_id']);
+        }
+    }
+
+
 }
 ?>




Svn-src-all メーリングリストの案内