Ignore:
Timestamp:
2009/09/01 15:04:37 (15 years ago)
Author:
Seasoft
Message:
  • #540(LC_Page_Shopping_Confirm#process 「カート内の商品の売り切れチェック」が動作していない)を改修。
  • #544(サンプルデータで在庫制限が異常動作)を改修。
  • #534(dtb_products.sale_unlimited は不要)を改善。
File:
1 edited

Legend:

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

    r18273 r18275  
    264264        // 商品規格取得 
    265265        $objQuery = new SC_Query(); 
    266         $col = "product_id, deliv_fee, name, product_code, main_list_image, main_image, price01, price02, point_rate, product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited, sale_limit, sale_unlimited"; 
     266        $col = "product_id, deliv_fee, name, product_code, main_list_image, main_image, price01, price02, point_rate, product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited, sale_limit"; 
    267267        $table = "vw_product_class AS prdcls"; 
    268268        $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ? AND status = 1"; 
     
    309309            // 商品規格情報の取得 
    310310            $arrData = $this->sfGetProductsClass($arrCart['id']); 
    311             $limit = ""; 
     311            $limit = null; 
    312312            // DBに存在する商品 
    313313            if (count($arrData) > 0) { 
    314314 
    315315                // 購入制限数を求める。 
    316                 if ($arrData['stock_unlimited'] != '1' && $arrData['sale_unlimited'] != '1') { 
     316                if ($arrData['stock_unlimited'] != '1' && SC_Utils_Ex::sfIsInt($arrData['sale_limit'])) { 
    317317                    $limit = min($arrData['sale_limit'], $arrData['stock']); 
    318                 } elseif ($arrData['sale_unlimited'] != '1') { 
     318                } elseif (SC_Utils_Ex::sfIsInt($arrData['sale_limit'])) { 
    319319                    $limit = $arrData['sale_limit']; 
    320320                } elseif ($arrData['stock_unlimited'] != '1') { 
     
    322322                } 
    323323 
    324                 if ($limit != "" && $limit < $arrCart['quantity']) { 
    325                     // カート内商品数を制限に合わせる 
    326                     $objCartSess->setProductValue($arrCart['id'], 'quantity', $limit); 
    327                     $quantity = $limit; 
    328                     $objPage->tpl_message .= "※「" . $arrData['name'] . "」は販売制限(または在庫が不足)しております。一度に数量{$limit}以上の購入はできません。\n"; 
     324                if (!is_null($limit) && $arrCart['quantity'] > $limit) { 
     325                    if ($limit > 0) { 
     326                        // カート内商品数を制限に合わせる 
     327                        $objCartSess->setProductValue($arrCart['id'], 'quantity', $limit); 
     328                        $quantity = $limit; 
     329                        $objPage->tpl_message .= "※「" . $arrData['name'] . "」は販売制限(または在庫が不足)しております。一度に数量{$limit}以上の購入はできません。\n"; 
     330                    } else { 
     331                        // 売り切れ商品をカートから削除する 
     332                        $objCartSess->delProduct($arrCart['cart_no']); 
     333                        $objPage->tpl_message .= "※「" . $arrData['name'] . "」は売り切れました。\n"; 
     334                        break; 
     335                    } 
    329336                } else { 
    330337                    $quantity = $arrCart['quantity']; 
     
    334341                $product_id = $arrCart['id'][0]; 
    335342                $arrQuantityInfo_by_product[$product_id]['quantity'] += $quantity; 
    336                 $arrQuantityInfo_by_product[$product_id]['sale_unlimited'] = $arrData['sale_unlimited']; 
    337343                $arrQuantityInfo_by_product[$product_id]['sale_limit'] = $arrData['sale_limit']; 
    338344                $arrQuantityInfo_by_product[$product_id]['name'] = $arrData['name']; 
     
    384390                $cnt++; 
    385391            } else { // DBに商品が見つからない場合、 
    386                 $objPage->tpl_message .= "※現時点で販売していない商品が含まれておりました。該当商品をカートから削除しました。\n"; 
     392                $objPage->tpl_message .= "※ 現時点で販売していない商品が含まれておりました。該当商品をカートから削除しました。\n"; 
    387393                // カート商品の削除 
    388                 $objCartSess->delProductKey('id', $arrCart['id']); 
     394                $objCartSess->delProduct($arrCart['cart_no']); 
    389395            } 
    390396        } 
    391397         
    392398        foreach ($arrQuantityInfo_by_product as $product_id => $quantityInfo) { 
    393             if ($quantityInfo['sale_unlimited'] != '1' && $quantityInfo['sale_limit'] != '' && $quantityInfo['sale_limit'] < $quantityInfo['quantity']) { 
     399            if (SC_Utils_Ex::sfIsInt($quantityInfo['sale_limit']) && $quantityInfo['quantity'] > $quantityInfo['sale_limit']) { 
    394400                $objPage->tpl_error = "※「{$quantityInfo['name']}」は数量「{$quantityInfo['sale_limit']}」以下に販売制限しております。一度にこれ以上の購入はできません。\n"; 
    395401                // 販売制限に引っかかった商品をマークする 
Note: See TracChangeset for help on using the changeset viewer.