Ignore:
Timestamp:
2011/02/03 18:40:05 (13 years ago)
Author:
yomoro
Message:

#986 リファクタリング

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Cart.php

    r20007 r20076  
    6565        $objCart = new SC_CartSession(); 
    6666        $objSiteInfo = new SC_SiteInfo; 
    67  
    68         $cartKeys = $objCart->getKeys(); 
    69         foreach ($cartKeys as $cartKey) { 
    70  
    71             // カート情報を取得 
    72             $arrCartList = $objCart->getCartList($cartKey); 
    73  
    74             // カート内の商品ID一覧を取得 
    75             $arrAllProductID = $objCart->getAllProductID($cartKey); 
    76             // 商品が1つ以上入っている場合には商品名称を取得 
    77             if (count($arrCartList) > 0){ 
    78  
    79                 foreach($arrCartList['productsClass'] as $key => $val){ 
    80                     $arrCartList[$key]['product_name'] = $val['name']; 
    81                 } 
    82             } 
    83             // 購入金額合計 
    84             $ProductsTotal += $objCart->getAllProductsTotal($cartKey); 
    85             // 合計数量 
    86             $TotalQuantity += $objCart->getTotalQuantity($cartKey); 
    87  
    88         } 
    89  
    90         // 店舗情報の取得 
    91         $arrInfo = $objSiteInfo->data; 
    92  
    93         // 送料無料までの金額 
    94         $arrCartList[0]['ProductsTotal'] = $ProductsTotal; 
    95         $arrCartList[0]['TotalQuantity'] = $TotalQuantity; 
    96  
    97         $deliv_free = $arrInfo['free_rule'] - $ProductsTotal; 
    98         $arrCartList[0]['free_rule'] = $arrInfo['free_rule']; 
    99         $arrCartList[0]['deliv_free'] = $deliv_free; 
    100  
    10167        $this->isMultiple = $objCart->isMultiple(); 
    102         $this->arrCartList = $arrCartList; 
     68        $this->arrCartList = $this->lfGetCartData($objCart, $objSiteInfo); 
    10369    } 
    10470 
     
    11177        parent::destroy(); 
    11278    } 
     79 
     80    /** 
     81     * カートの情報を取得する 
     82     * 
     83     * @param SC_CartSession $objCart カートセッション管理クラス 
     84     * @param SC_SiteInfo $objSiteInfo サイト情報クラス 
     85     * @return array $arrCartList カートデータ配列 
     86     */ 
     87    function lfGetCartData($objCart, $objSiteInfo) { 
     88        $arrCartKeys = $objCart->getKeys(); 
     89        foreach ($arrCartKeys as $cart_key) { 
     90            // カート情報を取得 
     91            $arrCartList = $objCart->getCartList($cart_key); 
     92            // カート内の商品ID一覧を取得 
     93            $arrAllProductID = $objCart->getAllProductID($cart_key); 
     94            // 商品が1つ以上入っている場合には商品名称を取得 
     95            if (count($arrCartList) > 0){ 
     96                 
     97                foreach($arrCartList['productsClass'] as $key => $val){ 
     98                    $arrCartList[$key]['product_name'] = $val['name']; 
     99                } 
     100            } 
     101            // 購入金額合計 
     102            $products_total += $objCart->getAllProductsTotal($cart_key); 
     103            // 合計数量 
     104            $total_quantity += $objCart->getTotalQuantity($cart_key); 
     105        } 
     106         
     107        // 店舗情報の取得 
     108        $arrInfo = $objSiteInfo->data; 
     109         
     110        // 送料無料までの金額 
     111        $arrCartList[0]['ProductsTotal'] = $products_total; 
     112        $arrCartList[0]['TotalQuantity'] = $total_quantity; 
     113         
     114        $deliv_free = $arrInfo['free_rule'] - $products_total; 
     115        $arrCartList[0]['free_rule'] = $arrInfo['free_rule']; 
     116        $arrCartList[0]['deliv_free'] = $deliv_free; 
     117         
     118        return $arrCartList; 
     119         
     120    } 
     121 
    113122} 
    114123?> 
Note: See TracChangeset for help on using the changeset viewer.