Changeset 17443


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

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

Location:
branches/comu-ver2/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/comu-ver2/data/Smarty/templates/default/cart/index.tpl

    r17435 r17443  
    5050    </p> 
    5151 
    52    <!--{if $tpl_message != ""}--> 
     52   <!--{if strlen($tpl_error) != 0}--> 
     53    <p class="attention"><!--{$tpl_error|escape}--></p> 
     54   <!--{/if}--> 
     55    
     56   <!--{if strlen($tpl_message) != 0}--> 
    5357    <p class="attention"><!--{$tpl_message|escape}--></p> 
    5458   <!--{/if}--> 
     
    6872       </tr> 
    6973      <!--{section name=cnt loop=$arrProductsClass}--> 
    70        <tr> 
     74       <tr style="<!--{if $arrProductsClass[cnt].error}-->background-color: <!--{$smarty.const.ERR_COLOR}--><!--{/if}-->"> 
    7175         <td><a href="<!--{$smarty.server.PHP_SELF|escape}-->" onclick="fnChangeAction('<!--{$smarty.server.PHP_SELF|escape}-->'); fnModeSubmit('delete', 'cart_no', '<!--{$arrProductsClass[cnt].cart_no}-->'); return false;">削除</a> 
    7276         </td> 
     
    102106     <tr> 
    103107       <th colspan="5" class="resulttd">小計</th> 
    104        <td class="pricetd"><!--{$tpl_total_pretax|number_format}--></td> 
     108       <td class="pricetd"><!--{$tpl_total_pretax|number_format}--></td> 
    105109    </tr> 
    106110    <tr> 
     
    123127  <p class="mini">※商品写真は参考用写真です。ご注文のカラーと異なる写真が表示されている場合でも、商品番号に記載されているカラー表示で間違いございませんのでご安心ください。</p> 
    124128  <div class="tblareabtn"> 
     129    <!--{if strlen($tpl_error) == 0}--> 
     130      <p>上記内容でよろしければ「購入手続きへ」ボタンをクリックしてください。</p> 
     131    <!--{/if}--> 
     132 
    125133    <p> 
    126       <img src="<!--{$TPL_DIR}-->img/cart/text.gif" width="390" height="30" alt="上記内容でよろしければ「レジへ行く」ボタンをクリックしてください。" /> 
    127     </p> 
    128  
    129    <!--{if $tpl_prev_url != ""}--> 
    130      <p> 
    131        <a href="<!--{$tpl_prev_url}-->" onmouseover="chgImg('<!--{$TPL_DIR}-->img/cart/b_pageback_on.gif','back');" onmouseout="chgImg('<!--{$TPL_DIR}-->img/cart/b_pageback.gif','back');"> 
    132          <img src="<!--{$TPL_DIR}-->img/cart/b_pageback.gif" width="150" height="30" alt="買い物を続ける" name="back" id="back" /> 
    133        </a>&nbsp;&nbsp; 
    134    <!--{/if}--> 
    135        <input type="image" onmouseover="chgImgImageSubmit('<!--{$TPL_DIR}-->img/cart/b_buystep_on.gif',this)" onmouseout="chgImgImageSubmit('<!--{$TPL_DIR}-->img/cart/b_buystep.gif',this)" src="<!--{$TPL_DIR}-->img/cart/b_buystep.gif" class="box150"  alt="購入手続きへ" name="confirm" /> 
     134      <!--{if $tpl_prev_url != ""}--> 
     135        <a href="<!--{$tpl_prev_url}-->" onmouseover="chgImg('<!--{$TPL_DIR}-->img/cart/b_pageback_on.gif','back');" onmouseout="chgImg('<!--{$TPL_DIR}-->img/cart/b_pageback.gif','back');"> 
     136          <img src="<!--{$TPL_DIR}-->img/cart/b_pageback.gif" width="150" height="30" alt="買い物を続ける" name="back" id="back" /> 
     137          </a>&nbsp;&nbsp; 
     138      <!--{/if}--> 
     139      <!--{if strlen($tpl_error) == 0}--> 
     140        <input type="image" onmouseover="chgImgImageSubmit('<!--{$TPL_DIR}-->img/cart/b_buystep_on.gif',this)" onmouseout="chgImgImageSubmit('<!--{$TPL_DIR}-->img/cart/b_buystep.gif',this)" src="<!--{$TPL_DIR}-->img/cart/b_buystep.gif" class="box150"  alt="購入手続きへ" name="confirm" /> 
     141      <!--{/if}--> 
    136142     </p> 
    137143  </div> 
  • 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.