Ignore:
Timestamp:
2010/10/13 18:03:46 (16 years ago)
Author:
nanasess
bzr:base-revision:
svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_5-dev:18851
bzr:committer:
Kentaro Ohkouchi <[email protected]>
bzr:file-ids:

data/Smarty/templates/default/cart/index.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fcart%2Findex.tpl
data/Smarty/templates/default/list.tpl 15747@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Flist.tpl
data/Smarty/templates/default/shopping/confirm.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fshopping%2Fconfirm.tpl
data/class/SC_CartSession.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2FSC_CartSession.php
data/class/SC_Product.php 18277@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcomu-ver2%2Fdata%2Fclass%2FSC_Product.php
data/class/helper/SC_Helper_DB.php 15176@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fhelper%2FSC_Helper_DB.php
data/class/pages/cart/LC_Page_Cart.php 15179@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fcart%2FLC_Page_Cart.php
data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Cart.php 15367@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Ffrontparts%2Fbloc%2FLC_Page_FrontParts_Bloc_Cart.php
data/class/pages/products/LC_Page_Products_List.php 15154@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fproducts%2FLC_Page_Products_List.php
data/class/pages/shopping/LC_Page_Shopping_Complete.php 15223@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fshopping%2FLC_Page_Shopping_Complete.php
data/class/pages/shopping/LC_Page_Shopping_Confirm.php 15223@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fshopping%2FLC_Page_Shopping_Confirm.php
data/class/util/SC_Utils.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Futil%2FSC_Utils.php
data/install.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Finstall.php
bzr:mapping-version:
v4
bzr:merge:

[email protected]
bzr:repository-uuid:
1e3b908f-19a9-db11-a64c-001125224ba8
bzr:revision-id:
[email protected]
bzr:revno:
2332
bzr:revprop:branch-nick:
branches/version-2_5-dev
bzr:root:
branches/version-2_5-dev
bzr:text-revisions:

data/Smarty/templates/default/cart/index.tpl [email protected]
data/Smarty/templates/default/list.tpl [email protected]
data/Smarty/templates/default/shopping/confirm.tpl [email protected]
data/class/SC_CartSession.php [email protected]
data/class/SC_Product.php [email protected]
data/class/helper/SC_Helper_DB.php [email protected]
data/class/pages/cart/LC_Page_Cart.php [email protected]
data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Cart.php [email protected]
data/class/pages/products/LC_Page_Products_List.php [email protected]
data/class/pages/shopping/LC_Page_Shopping_Complete.php [email protected]
data/class/pages/shopping/LC_Page_Shopping_Confirm.php [email protected]
data/class/util/SC_Utils.php [email protected]
bzr:timestamp:
2010-10-13 18:03:42.963999987 +0900
bzr:user-agent:
bzr2.2.0+bzr-svn1.0.3
svn:original-date:
2010-10-13T09:03:42.964000Z
Message:

商品種別によってカートを分ける(#823)

  • SC_CartSession をリファクタリング
  • 商品情報を SC_CartSession で取得するように変更
  • SC_Helper_DB::sfTotalCart() の実装を SC_CartSession へ移動
  • SC_Product で, 規格分類名を name に格納していたのを classcategory_name へ変更
  • カート関連の処理を修正
Location:
branches/version-2_5-dev/data/class
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/SC_CartSession.php

    r18851 r18852  
    2424/* カートセッション管理クラス */ 
    2525class SC_CartSession { 
    26     var $key_tmp;   // ユニークIDを指定する。 
     26    /** ユニークIDを指定する. */ 
     27    var $key_tmp; 
     28 
     29    /** カートのセッション変数. */ 
     30    var $cartSession; 
    2731 
    2832    /* コンストラクタ */ 
    29     function SC_CartSession() { 
     33    function SC_CartSession($cartKey = "cart") { 
     34        $this->cartSession =& $_SESSION[$cartKey]; 
    3035    } 
    3136 
    3237    // 商品購入処理中のロック 
    33     function saveCurrentCart($key_tmp, $key) { 
     38    function saveCurrentCart($key_tmp, $productTypeId) { 
    3439        $this->key_tmp = "savecart_" . $key_tmp; 
    3540        // すでに情報がなければ現状のカート情報を記録しておく 
    3641        if(count($_SESSION[$this->key_tmp]) == 0) { 
    37             $_SESSION[$this->key_tmp] = $_SESSION[$key]; 
     42            $_SESSION[$this->key_tmp] = $this->cartSession[$productTypeId]; 
    3843        } 
    3944        // 1世代古いコピー情報は、削除しておく 
    4045        foreach($_SESSION as $k => $val) { 
    4146            if($k != $this->key_tmp && preg_match("/^savecart_/", $k)) { 
    42                 unset($_SESSION[$key][$k]); 
    43             } 
    44         } 
    45         $this->registerKey($key); 
     47                unset($this->cartSession[$productTypeId][$k]); 
     48            } 
     49        } 
     50        $this->registerKey($productTypeId); 
    4651    } 
    4752 
    4853    // 商品購入中の変更があったかをチェックする。 
    49     function getCancelPurchase($key) { 
    50         $this->addKey($key); 
    51         $ret = isset($_SESSION[$key]['cancel_purchase']) 
    52             ? $_SESSION[$key]['cancel_purchase'] : ""; 
    53         $_SESSION[$key]['cancel_purchase'] = false; 
     54    function getCancelPurchase($productTypeId) { 
     55        $ret = isset($this->cartSession[$productTypeId]['cancel_purchase']) 
     56            ? $this->cartSession[$productTypeId]['cancel_purchase'] : ""; 
     57        $this->cartSession[$productTypeId]['cancel_purchase'] = false; 
    5458        return $ret; 
    5559    } 
    5660 
    5761    // 購入処理中に商品に変更がなかったかを判定 
    58     function checkChangeCart($key) { 
    59         $this->addKey($key); 
     62    function checkChangeCart($productTypeId) { 
    6063        $change = false; 
    61         $max = $this->getMax(); 
     64        $max = $this->getMax($productTypeId); 
    6265        for($i = 1; $i <= $max; $i++) { 
    63             if ($_SESSION[$key][$i]['quantity'] != $_SESSION[$this->key_tmp][$i]['quantity']) { 
     66            if ($this->cartSession[$productTypeId][$i]['quantity'] 
     67                != $_SESSION[$this->key_tmp][$i]['quantity']) { 
     68 
    6469                $change = true; 
    6570                break; 
    6671            } 
    67             if ($_SESSION[$key][$i]['id'] != $_SESSION[$this->key_tmp][$i]['id']) { 
     72            if ($this->cartSession[$productTypeId][$i]['id'] 
     73                != $_SESSION[$this->key_tmp][$i]['id']) { 
     74 
    6875                $change = true; 
    6976                break; 
     
    7380            // 一時カートのクリア 
    7481            unset($_SESSION[$this->key_tmp]); 
    75             $_SESSION[$key]['cancel_purchase'] = true; 
     82            $this->cartSession[$productTypeId][$key]['cancel_purchase'] = true; 
    7683        } else { 
    77             $_SESSION[$key]['cancel_purchase'] = false; 
    78         } 
    79         return $_SESSION[$key]['cancel_purchase']; 
     84            $this->cartSession[$productTypeId]['cancel_purchase'] = false; 
     85        } 
     86        return $this->cartSession[$productTypeId]['cancel_purchase']; 
    8087    } 
    8188 
    8289    // 次に割り当てるカートのIDを取得する 
    83     function getNextCartID($key) { 
    84         $this->addKey($key); 
    85         foreach($_SESSION[$key] as $k => $val){ 
    86             $arrRet[] = $_SESSION[$key][$k]['cart_no']; 
     90    function getNextCartID($productTypeId) { 
     91        foreach($this->cartSession[$productTypeId] as $key => $val){ 
     92            $arrRet[] = $this->cartSession[$productTypeId][$key]['cart_no']; 
    8793        } 
    8894        return (max($arrRet) + 1); 
     
    95101     * @param integer $id 
    96102     * @return string 商品ごとの合計価格(税込み) 
     103     * @deprecated SC_CartSession::getCartList() を使用してください 
    97104     */ 
    98     function getProductTotal($id, $key) { 
    99         $this->addKey($key); 
    100         $max = $this->getMax(); 
    101         for($i = 0; $i <= $max; $i++) { 
    102             if(isset($_SESSION[$key][$i]['id']) 
    103                && $_SESSION[$key][$i]['id'] == $id) { 
     105    function getProductTotal($id, $productTypeId) { 
     106        $max = $this->getMax($productTypeId); 
     107        for($i = 0; $i <= $max; $i++) { 
     108            if(isset($this->cartSession[$productTypeId][$i]['id']) 
     109               && $this->cartSession[$productTypeId][$i]['id'] == $id) { 
    104110 
    105111                // 税込み合計 
    106                 $price = $_SESSION[$key][$i]['price']; 
    107                 $quantity = $_SESSION[$key][$i]['quantity']; 
     112                $price = $this->cartSession[$productTypeId][$i]['price']; 
     113                $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 
    108114                $pre_tax = SC_Helper_DB_Ex::sfPreTax($price); 
    109115                $total = $pre_tax * $quantity; 
     
    115121 
    116122    // 値のセット 
    117     function setProductValue($id, $k, $val, $key) { 
    118         $this->addKey($key); 
    119         $max = $this->getMax($key); 
    120         for($i = 0; $i <= $max; $i++) { 
    121             if(isset($_SESSION[$key][$i]['id']) 
    122                && $_SESSION[$key][$i]['id'] == $id) { 
    123                 $_SESSION[$key][$i][$k] = $val; 
     123    function setProductValue($id, $key, $val, $productTypeId) { 
     124        $max = $this->getMax($productTypeId); 
     125        for($i = 0; $i <= $max; $i++) { 
     126            if(isset($this->cartSession[$productTypeId][$i]['id']) 
     127               && $this->cartSession[$productTypeId][$i]['id'] == $id) { 
     128                $this->cartSession[$productTypeId][$i][$key] = $val; 
    124129            } 
    125130        } 
     
    127132 
    128133    // カート内商品の最大要素番号を取得する。 
    129     function getMax($key) { 
    130         $this->addKey($key); 
    131         $cnt = 0; 
    132         $pos = 0; 
     134    function getMax($productTypeId) { 
    133135        $max = 0; 
    134         if (count($_SESSION[$key]) > 0){ 
    135             foreach($_SESSION[$key] as $k => $val) { 
    136                 if (is_numeric($k)) { 
    137                     if($max < $k) { 
    138                         $max = $k; 
     136        if (count($this->cartSession[$productTypeId]) > 0){ 
     137            foreach($this->cartSession[$productTypeId] as $key => $val) { 
     138                if (is_numeric($key)) { 
     139                    if($max < $key) { 
     140                        $max = $key; 
    139141                    } 
    140142                } 
     
    145147 
    146148    // カート内商品数の合計 
    147     function getTotalQuantity($key) { 
    148         $this->addKey($key); 
     149    function getTotalQuantity($productTypeId) { 
    149150        $total = 0; 
    150         $max = $this->getMax($key); 
    151         for($i = 0; $i <= $max; $i++) { 
    152             $total+= $_SESSION[$key][$i]['quantity']; 
     151        $max = $this->getMax($productTypeId); 
     152        for($i = 0; $i <= $max; $i++) { 
     153            $total+= $this->cartSession[$productTypeId][$i]['quantity']; 
    153154        } 
    154155        return $total; 
     
    157158 
    158159    // 全商品の合計価格 
    159     function getAllProductsTotal($key) { 
    160         $this->addKey($key); 
     160    function getAllProductsTotal($productTypeId) { 
    161161        // 税込み合計 
    162162        $total = 0; 
    163         $max = $this->getMax($key); 
    164         for($i = 0; $i <= $max; $i++) { 
    165  
    166             if (!isset($_SESSION[$key][$i]['price'])) { 
    167                 $_SESSION[$key][$i]['price'] = ""; 
    168             } 
    169             $price = $_SESSION[$key][$i]['price']; 
    170  
    171             if (!isset($_SESSION[$key][$i]['quantity'])) { 
    172                 $_SESSION[$key][$i]['quantity'] = ""; 
    173             } 
    174             $quantity = $_SESSION[$key][$i]['quantity']; 
     163        $max = $this->getMax($productTypeId); 
     164        for($i = 0; $i <= $max; $i++) { 
     165 
     166            if (!isset($this->cartSession[$productTypeId][$i]['price'])) { 
     167                $this->cartSession[$productTypeId][$i]['price'] = ""; 
     168            } 
     169 
     170            $price = $this->cartSession[$productTypeId][$i]['price']; 
     171 
     172            if (!isset($this->cartSession[$productTypeId][$i]['quantity'])) { 
     173                $this->cartSession[$productTypeId][$i]['quantity'] = ""; 
     174            } 
     175            $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 
    175176 
    176177            $pre_tax = SC_Helper_DB_Ex::sfPreTax($price); 
     
    181182 
    182183    // 全商品の合計税金 
    183     function getAllProductsTax($key) { 
    184         $this->addKey($key); 
     184    function getAllProductsTax($productTypeId) { 
    185185        // 税合計 
    186186        $total = 0; 
    187         $max = $this->getMax($key); 
    188         for($i = 0; $i <= $max; $i++) { 
    189             $price = $_SESSION[$key][$i]['price']; 
    190             $quantity = $_SESSION[$key][$i]['quantity']; 
     187        $max = $this->getMax($productTypeId); 
     188        for($i = 0; $i <= $max; $i++) { 
     189            $price = $this->cartSession[$productTypeId][$i]['price']; 
     190            $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 
    191191            $tax = SC_Helper_DB_Ex::sfTax($price); 
    192192            $total+= ($tax * $quantity); 
     
    196196 
    197197    // 全商品の合計ポイント 
    198     function getAllProductsPoint($key) { 
    199         $this->addKey($key); 
     198    function getAllProductsPoint($productTypeId) { 
    200199        // ポイント合計 
    201200        $total = 0; 
    202201        if (USE_POINT !== false) { 
    203             $max = $this->getMax($key); 
     202            $max = $this->getMax($productTypeId); 
    204203            for($i = 0; $i <= $max; $i++) { 
    205                 $price = $_SESSION[$key][$i]['price']; 
    206                 $quantity = $_SESSION[$key][$i]['quantity']; 
    207  
    208                 if (!isset($_SESSION[$key][$i]['point_rate'])) { 
    209                     $_SESSION[$key][$i]['point_rate'] = ""; 
    210                 } 
    211                 $point_rate = $_SESSION[$key][$i]['point_rate']; 
    212  
    213                 if (!isset($_SESSION[$key][$i]['id'][0])) { 
    214                     $_SESSION[$key][$i]['id'][0] = ""; 
    215                 } 
    216                 $id = $_SESSION[$key][$i]['id'][0]; 
     204                $price = $this->cartSession[$productTypeId][$i]['price']; 
     205                $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 
     206 
     207                if (!isset($this->cartSession[$productTypeId][$i]['point_rate'])) { 
     208                    $this->cartSession[$productTypeId][$i]['point_rate'] = ""; 
     209                } 
     210                $point_rate = $this->cartSession[$productTypeId][$i]['point_rate']; 
     211 
     212                if (!isset($this->cartSession[$productTypeId][$i]['id'][0])) { 
     213                    $this->cartSession[$productTypeId][$i]['id'][0] = ""; 
     214                } 
     215                $id = $this->cartSession[$productTypeId][$i]['id'][0]; 
    217216                $point = SC_Utils_Ex::sfPrePoint($price, $point_rate, POINT_RULE, $id); 
    218217                $total+= ($point * $quantity); 
     
    223222 
    224223    // カートへの商品追加 
    225     function addProduct($id, $quantity, $key) { 
    226         $this->addKey($key); 
     224    function addProduct($id, $quantity, $productTypeId) { 
    227225        $find = false; 
    228         $max = $this->getMax($key); 
    229         for($i = 0; $i <= $max; $i++) { 
    230  
    231             if($_SESSION[$key][$i]['id'] == $id) { 
    232                 $val = $_SESSION[$key][$i]['quantity'] + $quantity; 
     226        $max = $this->getMax($productTypeId); 
     227        for($i = 0; $i <= $max; $i++) { 
     228 
     229            if($this->cartSession[$productTypeId][$i]['id'] == $id) { 
     230                $val = $this->cartSession[$productTypeId][$i]['quantity'] + $quantity; 
    233231                if(strlen($val) <= INT_LEN) { 
    234                     $_SESSION[$key][$i]['quantity']+= $quantity; 
     232                    $this->cartSession[$productTypeId][$i]['quantity'] += $quantity; 
    235233                } 
    236234                $find = true; 
     
    238236        } 
    239237        if(!$find) { 
    240             $_SESSION[$key][$max+1]['id'] = $id; 
    241             $_SESSION[$key][$max+1]['quantity'] = $quantity; 
    242             $_SESSION[$key][$max+1]['cart_no'] = $this->getNextCartID($key); 
     238            $this->cartSession[$productTypeId][$max+1]['id'] = $id; 
     239            $this->cartSession[$productTypeId][$max+1]['quantity'] = $quantity; 
     240            $this->cartSession[$productTypeId][$max+1]['cart_no'] = $this->getNextCartID($productTypeId); 
    243241        } 
    244242    } 
    245243 
    246244    // 前頁のURLを記録しておく 
    247     function setPrevURL($url, $key) { 
    248         $this->addKey($key); 
     245    function setPrevURL($url) { 
    249246        // 前頁として記録しないページを指定する。 
    250247        $arrExclude = array( 
     
    254251        // ページチェックを行う。 
    255252        foreach($arrExclude as $val) { 
    256             if(ereg($val, $url)) { 
     253            if(preg_match("/" . preg_quote($val) . "/", $url)) { 
    257254                $exclude = true; 
    258255                break; 
     
    261258        // 除外ページでない場合は、前頁として記録する。 
    262259        if(!$exclude) { 
    263             $_SESSION[$key]['prev_url'] = $url; 
     260            $_SESSION['prev_url'] = $url; 
    264261        } 
    265262    } 
    266263 
    267264    // 前頁のURLを取得する 
    268     function getPrevURL($key) { 
    269         $this->addKey($key); 
    270         return isset($_SESSION[$key]['prev_url']) 
    271             ? $_SESSION[$key]['prev_url'] : ""; 
     265    function getPrevURL() { 
     266        return isset($_SESSION['prev_url']) ? $_SESSION['prev_url'] : ""; 
    272267    } 
    273268 
    274269    // キーが一致した商品の削除 
    275     function delProductKey($keyname, $val, $key) { 
    276         $this->addKey($key); 
    277         $max = count($_SESSION[$key]); 
     270    function delProductKey($keyname, $val, $productTypeId) { 
     271        $max = count($this->cartSession[$productTypeId]); 
    278272        for($i = 0; $i < $max; $i++) { 
    279             if($_SESSION[$key][$i][$keyname] == $val) { 
    280                 unset($_SESSION[$key][$i]); 
    281             } 
    282         } 
    283     } 
    284  
    285     function setValue($k, $val, $key) { 
    286         $this->addKey($key); 
    287         $_SESSION[$key][$k] = $val; 
    288     } 
    289  
    290     function getValue($k, $key) { 
    291         $this->addKey($key); 
    292         return $_SESSION[$key][$k]; 
    293     } 
    294  
    295     function getCartList($key) { 
    296         $this->addKey($key); 
    297         $max = $this->getMax($key); 
     273            if($this->cartSession[$productTypeId][$i][$keyname] == $val) { 
     274                unset($this->cartSession[$productTypeId][$i]); 
     275            } 
     276        } 
     277    } 
     278 
     279    function setValue($key, $val, $productTypeId) { 
     280        $this->cartSession[$productTypeId][$key] = $val; 
     281    } 
     282 
     283    function getValue($key, $productTypeId) { 
     284        return $this->cartSession[$productTypeId][$key]; 
     285    } 
     286 
     287    function getCartList($productTypeId) { 
     288        $objProduct = new SC_Product(); 
     289        $max = $this->getMax($productTypeId); 
    298290        $arrRet = array(); 
    299291        for($i = 0; $i <= $max; $i++) { 
    300             if(isset($_SESSION[$key][$i]['cart_no']) 
    301                && $_SESSION[$key][$i]['cart_no'] != "") { 
    302                 $arrRet[] = $_SESSION[$key][$i]; 
     292            if(isset($this->cartSession[$productTypeId][$i]['cart_no']) 
     293               && $this->cartSession[$productTypeId][$i]['cart_no'] != "") { 
     294 
     295                if (SC_Utils_Ex::isBlank($this->cartSession[$productTypeId][$i]['productsClass'])) { 
     296                    $this->cartSession[$productTypeId][$i]['productsClass'] =& 
     297                            $objProduct->getDetailAndProductsClass( 
     298                                    $this->cartSession[$productTypeId][$i]['id']); 
     299                } 
     300 
     301                $price = $this->cartSession[$productTypeId][$i]['productsClass']['price02']; 
     302                $this->cartSession[$productTypeId][$i]['price'] = $price; 
     303 
     304                $this->cartSession[$productTypeId][$i]['point_rate'] = 
     305                        $this->cartSession[$productTypeId][$i]['productsClass']['point_rate']; 
     306 
     307 
     308                $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 
     309                $pre_tax = SC_Helper_DB_Ex::sfPreTax($price); 
     310                $total = $pre_tax * $quantity; 
     311 
     312                $this->cartSession[$productTypeId][$i]['total_pretax'] = $total; 
     313 
     314                $arrRet[] =& $this->cartSession[$productTypeId][$i]; 
    303315            } 
    304316        } 
     
    307319 
    308320    // カート内にある商品IDを全て取得する 
    309     function getAllProductID($key) { 
    310         $this->addKey($key); 
    311         $max = $this->getMax($key); 
    312         for($i = 0; $i <= $max; $i++) { 
    313             if($_SESSION[$key][$i]['cart_no'] != "") { 
    314                 $arrRet[] = $_SESSION[$key][$i]['id'][0]; 
     321    function getAllProductID($productTypeId) { 
     322        $max = $this->getMax($productTypeId); 
     323        for($i = 0; $i <= $max; $i++) { 
     324            if($this->cartSession[$productTypeId][$i]['cart_no'] != "") { 
     325                $arrRet[] = $this->cartSession[$productTypeId][$i]['id'][0]; 
    315326            } 
    316327        } 
     
    318329    } 
    319330 
    320     function delAllProducts($key) { 
    321         $this->addKey($key); 
    322         $max = $this->getMax($key); 
    323         for($i = 0; $i <= $max; $i++) { 
    324             unset($_SESSION[$key][$i]); 
     331    function delAllProducts($productTypeId) { 
     332        $max = $this->getMax($productTypeId); 
     333        for($i = 0; $i <= $max; $i++) { 
     334            unset($this->cartSession[$productTypeId][$i]); 
    325335        } 
    326336    } 
    327337 
    328338    // 商品の削除 
    329     function delProduct($cart_no, $key) { 
    330         $this->addKey($key); 
    331         $max = $this->getMax($key); 
    332         for($i = 0; $i <= $max; $i++) { 
    333             if($_SESSION[$key][$i]['cart_no'] == $cart_no) { 
    334                 unset($_SESSION[$key][$i]); 
     339    function delProduct($cart_no, $productTypeId) { 
     340        $max = $this->getMax($productTypeId); 
     341        for($i = 0; $i <= $max; $i++) { 
     342            if($this->cartSession[$productTypeId][$i]['cart_no'] == $cart_no) { 
     343                unset($this->cartSession[$productTypeId][$i]); 
    335344            } 
    336345        } 
     
    338347 
    339348    // 数量の増加 
    340     function upQuantity($cart_no, $key) { 
    341         $this->addKey($key); 
    342         $max = $this->getMax(); 
    343         for($i = 0; $i <= $max; $i++) { 
    344             if($_SESSION[$key][$i]['cart_no'] == $cart_no) { 
    345                 if(strlen($_SESSION[$key][$i]['quantity'] + 1) <= INT_LEN) { 
    346                     $_SESSION[$key][$i]['quantity']++; 
    347                 } 
    348             } 
     349    function upQuantity($cart_no, $productTypeId) { 
     350        $quantity = $this->getQuantity($cart_no, $productTypeId); 
     351        if (strlen($quantity + 1) <= INT_LEN) { 
     352            $this->setQuantity($quantity + 1, $cart_no, $productTypeId); 
    349353        } 
    350354    } 
    351355 
    352356    // 数量の減少 
    353     function downQuantity($cart_no, $key) { 
    354         $this->addKey($key); 
    355         $max = $this->getMax(); 
    356         for($i = 0; $i <= $max; $i++) { 
    357             if($_SESSION[$key][$i]['cart_no'] == $cart_no) { 
    358                 if($_SESSION[$key][$i]['quantity'] > 1) { 
    359                     $_SESSION[$key][$i]['quantity']--; 
    360                 } 
    361             } 
    362         } 
    363     } 
    364  
    365     function addKey($key) { 
    366         if (!in_array($this->keys, $key)) { 
    367             $this->keys[] = $key; 
    368         } 
     357    function downQuantity($cart_no, $productTypeId) { 
     358        $quantity = $this->getQuantity($cart_no, $productTypeId); 
     359        if ($quantity > 1) { 
     360            $this->setQuantity($quantity - 1, $cart_no, $productTypeId); 
     361        } 
     362    } 
     363 
     364    function getQuantity($cart_no, $productTypeId) { 
     365        $max = $this->getMax($productTypeId); 
     366        for ($i = 0; $i <= $max; $i++) { 
     367            if ($this->cartSession[$productTypeId][$i]['cart_no'] == $cart_no) { 
     368                return $this->cartSession[$productTypeId][$i]['quantity']; 
     369            } 
     370        } 
     371    } 
     372 
     373    function setQuantity($quantity, $cart_no, $productTypeId) { 
     374        $max = $this->getMax($productTypeId); 
     375        for ($i = 0; $i <= $max; $i++) { 
     376            if ($this->cartSession[$productTypeId][$i]['cart_no'] == $cart_no) { 
     377                $this->cartSession[$productTypeId][$i]['quantity'] = $quantity; 
     378            } 
     379        } 
     380    } 
     381 
     382    function getProductClassId($cart_no, $productTypeId) { 
     383        for ($i = 0; $i <= $max; $i++) { 
     384            if ($this->cartSession[$productTypeId][$i]['cart_no'] == $cart_no) { 
     385                return $this->cartSession[$productTypeId][$i]['id']; 
     386            } 
     387        } 
     388    } 
     389 
     390    /** 
     391     * カート内の商品の妥当性をチェックする. 
     392     * 
     393     * エラーが発生した場合は, 商品をカート内から削除又は数量を調整し, 
     394     * エラーメッセージを返す. 
     395     * 
     396     * 1. 削除/非表示商品のチェック 
     397     * 2. 商品購入制限数のチェック 
     398     * 3. 在庫数チェック 
     399     * 
     400     * @param string $key 商品種別ID 
     401     * @return string エラーが発生した場合はエラーメッセージ 
     402     */ 
     403    function checkProducts($productTypeId) { 
     404        $objProduct = new SC_Product(); 
     405        $tpl_message = ""; 
     406 
     407        // カート内の情報を取得 
     408        $items = $this->getCartList($productTypeId); 
     409        foreach (array_keys($items) as $key) { 
     410            $item =& $items[$key]; 
     411            $product =& $item['productsClass']; 
     412            /* 
     413             * 表示/非表示商品のチェック 
     414             */ 
     415            if (SC_Utils_Ex::isBlank($product)) { 
     416                $this->delProduct($item['cart_no'], $productTypeId); 
     417                $tpl_message .= "※ 現時点で販売していない商品が含まれておりました。該当商品をカートから削除しました。\n"; 
     418            } 
     419 
     420            /* 
     421             * 商品購入制限数, 在庫数のチェック 
     422             */ 
     423            $limit = $objProduct->getBuyLimit($product); 
     424            if (!is_null($limit) && $item['quantity'] > $limit) { 
     425                if ($limit > 0) { 
     426                    $this->setProductValue($item['id'], 'quantity', $limit, $productTypeId); 
     427                    $tpl_message .= "※「" . $product['name'] . "」は販売制限(または在庫が不足)しております。一度に数量{$limit}以上の購入はできません。\n"; 
     428                } else { 
     429                    $this->delProduct($item['cart_no'], $productTypeId); 
     430                    $tpl_message .= "※「" . $product['name'] . "」は売り切れました。\n"; 
     431                    continue; 
     432                } 
     433            } 
     434        } 
     435        return $tpl_message; 
    369436    } 
    370437 
    371438    function getKeys() { 
    372         return $this->keys; 
     439        return array_keys($this->cartSession); 
    373440    } 
    374441 
  • branches/version-2_5-dev/data/class/SC_Product.php

    r18833 r18852  
    188188                $stock_find_class = ($productsClass['stock_unlimited'] || $productsClass['stock'] > 0); 
    189189 
    190                 $classCategories[$productsClass1][$productsClass2]['name'] = $productsClass['name2'] . ($stock_find_class ? '' : ' (品切れ中)'); 
     190                $classCategories[$productsClass1][$productsClass2]['name'] = $productsClass['classcategory_name2'] . ($stock_find_class ? '' : ' (品切れ中)'); 
    191191 
    192192                $classCategories[$productsClass1][$productsClass2]['stock_find'] = $stock_find_class; 
     
    197197 
    198198                if (!in_array($classcat_id1, $classCats1)) { 
    199                     $classCats1[$productsClass1] = $productsClass['name1'] 
     199                    $classCats1[$productsClass1] = $productsClass['classcategory_name1'] 
    200200                        . ($productsClass2 == 0 && !$stock_find_class ? ' (品切れ中)' : ''); 
    201201                } 
     
    258258            T2.classcategory_id, 
    259259            T2.level, 
    260             T3.name, 
     260            T3.name AS classcategory_name, 
    261261            T4.name AS class_name, 
    262262            T4.class_id 
     
    290290                T1.parent_class_combination_id, 
    291291                T1.level, 
    292                 T2.name, 
     292                T2.name AS classcategory_name, 
    293293                T3.name AS class_name, 
    294294                T3.class_id 
     
    325325            $val['class_id' . $val['level']] = $val['class_id']; 
    326326            $val['class_name' . $val['level']] = $val['class_name']; 
    327             $val['name' . $val['level']] = $val['name']; 
     327            $val['classcategory_name' . $val['level']] = $val['classcategory_name']; 
    328328            $val['classcategory_id' . $val['level']] = $val['classcategory_id']; 
    329329            $arrProductsClass[] = $val; 
     
    421421        } 
    422422        return $productsClass; 
     423    } 
     424 
     425    /** 
     426     * 商品詳細の結果から, 購入制限数を取得する. 
     427     * 
     428     * getDetailAndProductsClass() の結果から, 購入制限数を取得する. 
     429     * 
     430     * @param array $p 商品詳細の検索結果の配列 
     431     * @return integer 商品詳細の結果から求めた購入制限数. 
     432     * @see getDetailAndProductsClass() 
     433     */ 
     434    function getBuyLimit($p) { 
     435        $limit = null; 
     436        if ($p['stock_unlimited'] != '1' && is_numeric($p['sale_limit'])) { 
     437            $limit = min($p['sale_limit'], $p['stock']); 
     438        } elseif (is_numeric($p['sale_limit'])) { 
     439            $limit = $p['sale_limit']; 
     440        } elseif ($p['stock_unlimited'] != '1') { 
     441            $limit = $p['stock']; 
     442        } 
     443        return $limit; 
    423444    } 
    424445 
  • branches/version-2_5-dev/data/class/helper/SC_Helper_DB.php

    r18851 r18852  
    244244     * @param null $dummy1 互換性確保用(決済モジュール互換のため) 
    245245     * @return LC_Page 集計処理後のページクラスインスタンス 
     246     * @deprecated SC_CartSession クラスを使用して下さい 
    246247     */ 
    247248    function sfTotalCart(&$objPage, $objCartSess, $dummy1 = null, $key = "") { 
     
    19131914     * @return  bool        0:実商品のみ 1:ダウンロード販売と実商品混在 2:全てダウンロード販売 
    19141915     */ 
    1915     function chkCartDown($objCartSess) { 
     1916    function chkCartDown(&$objCartSess, $cartKey = 1) { 
    19161917        $objQuery =& SC_Query::getSingletonInstance(); 
    19171918        $down = false; 
  • branches/version-2_5-dev/data/class/pages/cart/LC_Page_Cart.php

    r18833 r18852  
    6969     */ 
    7070    function process() { 
    71         global $objCampaignSess; 
    7271 
    7372        $objView = new SC_SiteView(false); 
     
    7978        $objDb = new SC_Helper_DB_Ex(); 
    8079        $objProduct = new SC_Product(); 
    81         // 商品購入中にカート内容が変更された。 
    82         if($objCartSess->getCancelPurchase()) { 
    83             $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。"; 
     80 
     81        $i = 0; 
     82        $this->cartKeys = $objCartSess->getKeys(); 
     83        foreach ($this->cartKeys as $key) { 
     84            // 商品購入中にカート内容が変更された。 
     85            if($objCartSess->getCancelPurchase($key)) { 
     86                $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。"; 
     87            } 
     88 
     89            // カートの商品規格を取得 
     90            $cartItems = $objCartSess->getCartList($key); 
     91            foreach (array_keys($cartItems) as $itemKey) { 
     92                $cartItem =& $cartItems[$itemKey]; 
     93                if (!SC_Utils_Ex::isBlank($cartItem)) { 
     94                    $this->cartItems[$key][$i] =& $cartItem; 
     95                    $i++; 
     96                } 
     97            } 
    8498        } 
    8599 
     
    88102        switch($_POST['mode']) { 
    89103        case 'up': 
    90             $objCartSess->upQuantity($_POST['cart_no']); 
     104            $objCartSess->upQuantity($_POST['cart_no'], $_POST['cartKey']); 
    91105            $this->reload(); // PRG pattern 
    92106            break; 
    93107        case 'down': 
    94             $objCartSess->downQuantity($_POST['cart_no']); 
     108            $objCartSess->downQuantity($_POST['cart_no'], $_POST['cartKey']); 
    95109            $this->reload(); // PRG pattern 
    96110            break; 
    97111        case 'delete': 
    98             $objCartSess->delProduct($_POST['cart_no']); 
     112            $objCartSess->delProduct($_POST['cart_no'], $_POST['cartKey']); 
    99113            $this->reload(); // PRG pattern 
    100114            break; 
    101115        case 'confirm': 
    102116            // カート内情報の取得 
    103             $cartKey = $_POST['cartKey']; // TODO 
    104             $arrRet = $objCartSess->getCartList($cartKey); 
    105             $max = count($arrRet); 
    106             $cnt = 0; 
    107             for ($i = 0; $i < $max; $i++) { 
    108                 // 商品規格情報の取得 
    109                 $this->arrData = $objProduct->getProductsClass($arrRet[$i]['id']); 
    110                 // DBに存在する商品 
    111                 if($this->arrData != "") { 
    112                     $cnt++; 
    113                 } 
    114             } 
     117            $cartKey = $_POST['cartKey']; 
     118            $cartList = $objCartSess->getCartList($cartKey); 
    115119            // カート商品が1件以上存在する場合 
    116             if($cnt > 0) { 
     120            if(count($cartList) > 0) { 
    117121                // 正常に登録されたことを記録しておく 
    118122                $objSiteSess->setRegistFlag(); 
     
    141145        // 基本情報の取得 
    142146        $this->arrInfo = $objSiteInfo->data; 
    143  
    144         $this->cartKeys = $objCartSess->getKeys(); 
    145147        foreach ($this->cartKeys as $key) { 
    146148            // カート集計処理 
    147             $objDb->sfTotalCart($this, $objCartSess, $key); 
    148             $this->arrData = $objDb->sfTotalConfirm($this->arrData, $this, $objCartSess, null, $objCustomer, $key); 
     149            $this->tpl_message = $objCartSess->checkProducts($key); 
     150            $this->tpl_total_pretax[$key] = $objCartSess->getAllProductsTotal($key); 
     151            $this->tpl_total_tax[$key] = $objCartSess->getAllProductsTax($key); 
     152            // ポイント合計 
     153            $this->tpl_total_point[$key] = $objCartSess->getAllProductsPoint($key); 
     154 
     155            $this->arrData = $objDb->sfTotalConfirm($this->cartItems[$key], $this, $objCartSess, null, $objCustomer, $key); 
    149156            // 送料無料までの金額を計算 
    150157            $this->tpl_deliv_free[$key] = $this->arrInfo['free_rule'] - $this->tpl_total_pretax[$key]; 
    151  
    152  
    153158        } 
    154159 
     
    159164            $this->tpl_name = $objCustomer->getValue('name01'); 
    160165        } 
    161  
    162166 
    163167        // 前頁のURLを取得 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Cart.php

    r18701 r18852  
    5858        $objSiteInfo = new SC_SiteInfo; 
    5959 
    60         if (count($_SESSION[$objCart->key]) > 0){ 
     60        $cartKeys = $objCart->getKeys(); 
     61        foreach ($cartKeys as $cartKey) { 
     62 
    6163            // カート情報を取得 
    62             $arrCartList = $objCart->getCartList(); 
     64            $arrCartList = $objCart->getCartList($cartKey); 
    6365 
    6466            // カート内の商品ID一覧を取得 
    65             $arrAllProductID = $objCart->getAllProductID(); 
     67            $arrAllProductID = $objCart->getAllProductID($cartKey); 
    6668            // 商品が1つ以上入っている場合には商品名称を取得 
    67             if (count($arrAllProductID) > 0){ 
    68                 $objQuery = new SC_Query(); 
    69                 $arrVal = array(); 
    70                 $sql = ""; 
    71                 $sql = "SELECT name FROM dtb_products WHERE product_id IN ( ?"; 
    72                 $arrVal = array($arrAllProductID[0]); 
    73                 for($i = 1 ; $i < count($arrAllProductID) ; $i++){ 
    74                     $sql.= " ,? "; 
    75                     array_push($arrVal, $arrAllProductID[$i]); 
    76                 } 
    77                 $sql.= " )"; 
     69            if (count($arrCartList) > 0){ 
    7870 
    79                 $arrProduct_name = $objQuery->getAll($sql, $arrVal); 
    80  
    81                 foreach($arrProduct_name as $key => $val){ 
     71                foreach($arrCartList['productsClass'] as $key => $val){ 
    8272                    $arrCartList[$key]['product_name'] = $val['name']; 
    8373                } 
     
    8676            $arrInfo = $objSiteInfo->data; 
    8777            // 購入金額合計 
    88             $ProductsTotal = $objCart->getAllProductsTotal(); 
     78            $ProductsTotal = $objCart->getAllProductsTotal($cartKey); 
    8979 
    9080            // 合計数量 
    91             $TotalQuantity = $objCart->getTotalQuantity(); 
     81            $TotalQuantity = $objCart->getTotalQuantity($cartKey); 
    9282 
    9383            // 送料無料までの金額 
  • branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_List.php

    r18833 r18852  
    158158                $objProduct = new SC_Product(); 
    159159                $product_class_id = $this->arrForm['product_class_id']; 
     160                $product_type = $this->arrForm['product_type']; 
    160161                $objCartSess = new SC_CartSession(); 
    161                 $objCartSess->addProduct($product_class_id, $this->arrForm['quantity']); 
     162                $objCartSess->addProduct($product_class_id, $this->arrForm['quantity'], $product_type); 
    162163                $this->sendRedirect($this->getLocation(URL_CART_TOP)); 
    163164                exit; 
  • branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_Complete.php

    r18851 r18852  
    525525        $objDb = new SC_Helper_DB_Ex(); 
    526526        // カート内情報の取得 
    527         $arrCart = $objCartSess->getCartList(); 
     527        $this->cartKey = $_SESSION['cartKey']; 
     528        $arrCart = $objCartSess->getCartList($this->cartKey); 
    528529        $max = count($arrCart); 
    529530 
  • branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_Confirm.php

    r18833 r18852  
    8585        // カート集計処理 
    8686        $this->cartKey = $_SESSION['cartKey']; 
    87         $objDb->sfTotalCart($this, $objCartSess, $this->cartKey); 
     87        $cartItems = $objCartSess->getCartList($this->cartKey); 
     88        $i = 0; 
     89        foreach (array_keys($cartItems) as $itemKey) { 
     90            $cartItem =& $cartItems[$itemKey]; 
     91            if (!SC_Utils_Ex::isBlank($cartItem)) { 
     92                $this->cartItems[$i] =& $cartItem; 
     93                $i++; 
     94            } 
     95        } 
     96        $this->tpl_message = $objCartSess->checkProducts($this->cartKey); 
     97        $this->tpl_total_pretax[$this->cartKey] = $objCartSess->getAllProductsTotal($this->cartKey); 
     98        $this->tpl_total_tax[$this->cartKey] = $objCartSess->getAllProductsTax($this->cartKey); 
     99        // ポイント合計 
     100        $this->tpl_total_point[$this->cartKey] = $objCartSess->getAllProductsPoint($this->cartKey); 
     101 
    88102        if (strlen($this->tpl_message) >= 1) { 
    89103            SC_Utils_Ex::sfDispSiteError(SOLD_OUT, '', true); 
    90104        } 
     105 
     106        // TODO リファクタリング 
    91107        // 一時受注テーブルの読込 
    92         $arrData = $objDb->sfGetOrderTemp($uniqid); 
     108        $tmpData = $objDb->sfGetOrderTemp($uniqid); 
     109 
    93110        // カート集計を元に最終計算 
    94         $arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, null, $objCustomer); 
     111        $arrData = $objDb->sfTotalConfirm($this->cartItems, $this, $objCartSess, null, $objCustomer, $this->cartKey); 
     112        $arrData = array_merge($tmpData, $arrData); 
    95113        // キャンペーンからの遷移で送料が無料だった場合の処理 
    96114        if($objCampaignSess->getIsCampaign()) { 
     
    137155 
    138156            // 集計結果を受注一時テーブルに反映 
     157            unset($arrData[0]); // TODO 
     158            unset($arrData[1]); 
    139159            $objDb->sfRegistTempOrder($uniqid, $arrData); 
    140160            // 正常に登録されたことを記録しておく 
  • branches/version-2_5-dev/data/class/util/SC_Utils.php

    r18820 r18852  
    313313        // ユーザユニークIDの取得 
    314314        $uniqid = $objSiteSess->getUniqId(); 
    315         // 購入ボタンを押した時のカート内容がコピーされていない場合のみコピーする。 
    316         $objCartSess->saveCurrentCart($uniqid); 
    317         // POSTのユニークIDとセッションのユニークIDを比較(ユニークIDがPOSTされていない場合はスルー) 
    318         $ret = $objSiteSess->checkUniqId(); 
    319         if($ret != true) { 
    320             // エラーページの表示 
    321             SC_Utils_Ex::sfDispSiteError(CANCEL_PURCHASE, $objSiteSess); 
    322         } 
    323  
    324         // カート内が空でないか || 購入ボタンを押してから変化がないか 
    325         $quantity = $objCartSess->getTotalQuantity(); 
    326         $ret = $objCartSess->checkChangeCart(); 
    327         if($ret == true || !($quantity > 0)) { 
    328             // カート情報表示に強制移動する 
    329             // FIXME false を返して, Page クラスで遷移させるべき... 
    330             if (defined("MOBILE_SITE")) { 
    331                 header("Location: ". MOBILE_URL_CART_TOP 
    332                        . "?" . session_name() . "=" . session_id()); 
    333             } else { 
    334                 header("Location: ".URL_CART_TOP); 
    335             } 
    336             exit; 
     315 
     316        $cartkeys = $objCartSess->getKeys(); 
     317 
     318        foreach ($cartKeys as $cartKey) { 
     319            // 購入ボタンを押した時のカート内容がコピーされていない場合のみコピーする。 
     320            $objCartSess->saveCurrentCart($uniqid, $cartKey); 
     321            // POSTのユニークIDとセッションのユニークIDを比較(ユニークIDがPOSTされていない場合はスルー) 
     322            $ret = $objSiteSess->checkUniqId(); 
     323            if($ret != true) { 
     324                // エラーページの表示 
     325                SC_Utils_Ex::sfDispSiteError(CANCEL_PURCHASE, $objSiteSess); 
     326            } 
     327 
     328            // カート内が空でないか || 購入ボタンを押してから変化がないか 
     329            $quantity = $objCartSess->getTotalQuantity($cartKey); 
     330            $ret = $objCartSess->checkChangeCart($cartKey); 
     331            if($ret == true || !($quantity > 0)) { 
     332                // カート情報表示に強制移動する 
     333                // FIXME false を返して, Page クラスで遷移させるべき... 
     334                if (defined("MOBILE_SITE")) { 
     335                    header("Location: ". MOBILE_URL_CART_TOP 
     336                           . "?" . session_name() . "=" . session_id()); 
     337                } else { 
     338                    header("Location: ".URL_CART_TOP); 
     339                } 
     340                exit; 
     341            } 
    337342        } 
    338343        return $uniqid; 
Note: See TracChangeset for help on using the changeset viewer.