Ignore:
Timestamp:
2008/07/21 07:19:11 (18 years ago)
Author:
Seasoft
Message:

(商品規格毎のみでなく)商品毎に販売制限のチェックを行うように修正。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/comu-ver2/data/class/helper/SC_Helper_DB.php

    r17442 r17443  
    299299 
    300300        // カート内情報の取得 
    301         $arrCart = $objCartSess->getCartList(); 
    302         $max = count($arrCart); 
     301        $arrQuantityInfo_by_product = array(); 
    303302        $cnt = 0; 
    304  
    305         for ($i = 0; $i < $max; $i++) { 
     303        foreach ($objCartSess->getCartList() as $arrCart) { 
    306304            // 商品規格情報の取得 
    307             $arrData = $this->sfGetProductsClass($arrCart[$i]['id']); 
     305            $arrData = $this->sfGetProductsClass($arrCart['id']); 
    308306            $limit = ""; 
    309307            // DBに存在する商品 
     
    312310                // 購入制限数を求める。 
    313311                if ($arrData['stock_unlimited'] != '1' && $arrData['sale_unlimited'] != '1') { 
    314                     if($arrData['sale_limit'] < $arrData['stock']) { 
    315                         $limit = $arrData['sale_limit']; 
    316                     } else { 
    317                         $limit = $arrData['stock']; 
    318                     } 
     312                    $limit = min($arrData['sale_limit'], $arrData['stock']); 
     313                } elseif ($arrData['sale_unlimited'] != '1') { 
     314                    $limit = $arrData['sale_limit']; 
     315                } elseif ($arrData['stock_unlimited'] != '1') { 
     316                    $limit = $arrData['stock']; 
     317                } 
     318 
     319                if($limit != "" && $limit < $arrCart['quantity']) { 
     320                    // カート内商品数を制限に合わせる 
     321                    $objCartSess->setProductValue($arrCart['id'], 'quantity', $limit); 
     322                    $quantity = $limit; 
     323                    $objPage->tpl_message = "※「" . $arrData['name'] . "」は販売制限(または在庫が不足)しております、一度にこれ以上の購入はできません。\n"; 
    319324                } else { 
    320                     if ($arrData['sale_unlimited'] != '1') { 
    321                         $limit = $arrData['sale_limit']; 
    322                     } 
    323                     if ($arrData['stock_unlimited'] != '1') { 
    324                         $limit = $arrData['stock']; 
    325                     } 
     325                    $quantity = $arrCart['quantity']; 
    326326                } 
    327  
    328                 if($limit != "" && $limit < $arrCart[$i]['quantity']) { 
    329                     // カート内商品数を制限に合わせる 
    330                     $objCartSess->setProductValue($arrCart[$i]['id'], 'quantity', $limit); 
    331                     $quantity = $limit; 
    332                     $objPage->tpl_message = "※「" . $arrData['name'] . "」は販売制限しております、一度にこれ以上の購入はできません。"; 
    333                 } else { 
    334                     $quantity = $arrCart[$i]['quantity']; 
    335                 } 
    336  
     327                 
     328                // (商品規格単位でなく)商品単位での評価のための準備 
     329                $product_id = $arrCart['id'][0]; 
     330                $arrQuantityInfo_by_product[$product_id]['product_id'] = $product_id; 
     331                $arrQuantityInfo_by_product[$product_id]['quantity'] += $quantity; 
     332                $arrQuantityInfo_by_product[$product_id]['sale_unlimited'] = $arrData['sale_unlimited']; 
     333                $arrQuantityInfo_by_product[$product_id]['sale_limit'] = $arrData['sale_limit']; 
     334                 
    337335                $objPage->arrProductsClass[$cnt] = $arrData; 
    338336                $objPage->arrProductsClass[$cnt]['quantity'] = $quantity; 
    339                 $objPage->arrProductsClass[$cnt]['cart_no'] = $arrCart[$i]['cart_no']; 
     337                $objPage->arrProductsClass[$cnt]['cart_no'] = $arrCart['cart_no']; 
    340338                $objPage->arrProductsClass[$cnt]['class_name1'] = 
    341339                    isset($arrClassName[$arrData['class_id1']]) 
     
    365363                // 価格の登録 
    366364                if ($arrData['price02'] != "") { 
    367                     $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price02']); 
     365                    $objCartSess->setProductValue($arrCart['id'], 'price', $arrData['price02']); 
    368366                    $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price02']; 
    369367                } else { 
    370                     $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price01']); 
     368                    $objCartSess->setProductValue($arrCart['id'], 'price', $arrData['price01']); 
    371369                    $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price01']; 
    372370                } 
    373371                // ポイント付与率の登録 
    374         if (USE_POINT !== false) { 
    375                 $objCartSess->setProductValue($arrCart[$i]['id'], 'point_rate', $arrData['point_rate']); 
    376         } 
     372                if (USE_POINT !== false) { 
     373                    $objCartSess->setProductValue($arrCart['id'], 'point_rate', $arrData['point_rate']); 
     374                } 
    377375                // 商品ごとの合計金額 
    378                 $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrInfo, $arrCart[$i]['id']); 
     376                $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrInfo, $arrCart['id']); 
    379377                // 送料の合計を計算する 
    380                 $objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart[$i]['quantity']); 
     378                $objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart['quantity']); 
    381379                $cnt++; 
    382380            } else { 
    383381                // DBに商品が見つからない場合はカート商品の削除 
    384                 $objCartSess->delProductKey('id', $arrCart[$i]['id']); 
    385             } 
    386         } 
    387  
     382                $objCartSess->delProductKey('id', $arrCart['id']); 
     383            } 
     384        } 
     385         
     386        foreach ($arrQuantityInfo_by_product as $QuantityInfo) { 
     387            if($QuantityInfo['sale_unlimited'] != '1' && $QuantityInfo['sale_limit'] != '' && $QuantityInfo['sale_limit'] < $QuantityInfo['quantity']) { 
     388                // カート内商品数を制限に合わせる 
     389                $objPage->tpl_error = "※「" . $arrData['name'] . "」は個数「{$QuantityInfo['sale_limit']}」以下に販売制限しております。一度にこれ以上の購入はできません。\n"; 
     390                foreach (array_keys($objPage->arrProductsClass) as $key) { 
     391                    $ProductsClass =& $objPage->arrProductsClass[$key]; 
     392                    $ProductsClass['error'] = true; 
     393                } 
     394            } 
     395        } 
     396         
    388397        // 全商品合計金額(税込み) 
    389398        $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal($arrInfo); 
Note: See TracChangeset for help on using the changeset viewer.