Ignore:
Timestamp:
2013/05/02 18:11:36 (13 years ago)
Author:
h_yoshimoto
Message:

#2236 2.12.3リリース以降の2.12-devへのコミット差し戻し

File:
1 edited

Legend:

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

    r22707 r22796  
    2828 * @version $Id$ 
    2929 */ 
    30 class SC_CartSession  
    31 { 
     30class SC_CartSession { 
    3231    /** ユニークIDを指定する. */ 
    3332    var $key_tmp; 
     
    3736 
    3837    /* コンストラクタ */ 
    39     function __construct($cartKey = 'cart') 
    40     { 
     38    function __construct($cartKey = 'cart') { 
    4139        if (!isset($_SESSION[$cartKey])) { 
    4240            $_SESSION[$cartKey] = array(); 
     
    4644 
    4745    // 商品購入処理中のロック 
    48     function saveCurrentCart($key_tmp, $productTypeId) 
    49     { 
     46    function saveCurrentCart($key_tmp, $productTypeId) { 
    5047        $this->key_tmp = 'savecart_' . $key_tmp; 
    5148        // すでに情報がなければ現状のカート情報を記録しておく 
     
    6259 
    6360    // 商品購入中の変更があったかをチェックする。 
    64     function getCancelPurchase($productTypeId) 
    65     { 
     61    function getCancelPurchase($productTypeId) { 
    6662        $ret = isset($this->cartSession[$productTypeId]['cancel_purchase']) 
    6763            ? $this->cartSession[$productTypeId]['cancel_purchase'] : ''; 
     
    7167 
    7268    // 購入処理中に商品に変更がなかったかを判定 
    73     function checkChangeCart($productTypeId) 
    74     { 
     69    function checkChangeCart($productTypeId) { 
    7570        $change = false; 
    7671        $max = $this->getMax($productTypeId); 
     
    10095 
    10196    // 次に割り当てるカートのIDを取得する 
    102     function getNextCartID($productTypeId) 
    103     { 
     97    function getNextCartID($productTypeId) { 
    10498        $count = array(); 
    10599        foreach ($this->cartSession[$productTypeId] as $key => $value) { 
     
    117111     * @deprecated SC_CartSession::getCartList() を使用してください 
    118112     */ 
    119     function getProductTotal($id, $productTypeId) 
    120     { 
     113    function getProductTotal($id, $productTypeId) { 
    121114        $max = $this->getMax($productTypeId); 
    122115        for ($i = 0; $i <= $max; $i++) { 
     
    136129 
    137130    // 値のセット 
    138     function setProductValue($id, $key, $val, $productTypeId) 
    139     { 
     131    function setProductValue($id, $key, $val, $productTypeId) { 
    140132        $max = $this->getMax($productTypeId); 
    141133        for ($i = 0; $i <= $max; $i++) { 
     
    149141 
    150142    // カート内商品の最大要素番号を取得する。 
    151     function getMax($productTypeId) 
    152     { 
     143    function getMax($productTypeId) { 
    153144        $max = 0; 
    154145        if (count($this->cartSession[$productTypeId]) > 0) { 
     
    165156 
    166157    // カート内商品数量の合計 
    167     function getTotalQuantity($productTypeId) 
    168     { 
     158    function getTotalQuantity($productTypeId) { 
    169159        $total = 0; 
    170160        $max = $this->getMax($productTypeId); 
     
    176166 
    177167    // 全商品の合計価格 
    178     function getAllProductsTotal($productTypeId) 
    179     { 
     168    function getAllProductsTotal($productTypeId) { 
    180169        // 税込み合計 
    181170        $total = 0; 
     
    201190 
    202191    // 全商品の合計税金 
    203     function getAllProductsTax($productTypeId) 
    204     { 
     192    function getAllProductsTax($productTypeId) { 
    205193        // 税合計 
    206194        $total = 0; 
     
    216204 
    217205    // 全商品の合計ポイント 
    218     function getAllProductsPoint($productTypeId) 
    219     { 
     206    function getAllProductsPoint($productTypeId) { 
    220207        // ポイント合計 
    221208        $total = 0; 
     
    242229 
    243230    // カートへの商品追加 
    244     function addProduct($product_class_id, $quantity) 
    245     { 
     231    function addProduct($product_class_id, $quantity) { 
    246232        $objProduct = new SC_Product_Ex(); 
    247233        $arrProduct = $objProduct->getProductsClass($product_class_id); 
     
    267253 
    268254    // 前頁のURLを記録しておく 
    269     function setPrevURL($url, $excludePaths = array()) 
    270     { 
     255    function setPrevURL($url, $excludePaths = array()) { 
    271256        // 前頁として記録しないページを指定する。 
    272257        $arrExclude = array( 
     
    289274 
    290275    // 前頁のURLを取得する 
    291     function getPrevURL() 
    292     { 
     276    function getPrevURL() { 
    293277        return isset($_SESSION['prev_url']) ? $_SESSION['prev_url'] : ''; 
    294278    } 
    295279 
    296280    // キーが一致した商品の削除 
    297     function delProductKey($keyname, $val, $productTypeId) 
    298     { 
     281    function delProductKey($keyname, $val, $productTypeId) { 
    299282        $max = count($this->cartSession[$productTypeId]); 
    300283        for ($i = 0; $i < $max; $i++) { 
     
    305288    } 
    306289 
    307     function setValue($key, $val, $productTypeId) 
    308     { 
     290    function setValue($key, $val, $productTypeId) { 
    309291        $this->cartSession[$productTypeId][$key] = $val; 
    310292    } 
    311293 
    312     function getValue($key, $productTypeId) 
    313     { 
     294    function getValue($key, $productTypeId) { 
    314295        return $this->cartSession[$productTypeId][$key]; 
    315296    } 
     
    319300     * productsClass項目から、不必要な項目を削除する。 
    320301     */ 
    321     function adjustSessionProductsClass(&$arrProductsClass) 
    322     { 
     302    function adjustSessionProductsClass(&$arrProductsClass) { 
    323303        $arrNecessaryItems = array( 
    324304            'product_id'          => true, 
     
    353333     * @return array カート内商品一覧の配列 
    354334     */ 
    355     function getCartList($productTypeId) 
    356     { 
     335    function getCartList($productTypeId) { 
    357336        $objProduct = new SC_Product_Ex(); 
    358337        $max = $this->getMax($productTypeId); 
     
    394373     * @return array すべてのカートの内容 
    395374     */ 
    396     function getAllCartList() 
    397     { 
     375    function getAllCartList() { 
    398376        $results = array(); 
    399377        $cartKeys = $this->getKeys(); 
     
    411389 
    412390    /** 
     391     * @deprected getAllProductClassID を使用して下さい 
     392     */ 
     393    function getAllProductID($productTypeId) { 
     394        trigger_error('正しく動作しないメソッドが呼び出されました。', E_USER_ERROR); 
     395    } 
     396 
     397    /** 
    413398     * カート内にある商品規格IDを全て取得する. 
    414399     * 
     
    416401     * @return array 商品規格ID の配列 
    417402     */ 
    418     function getAllProductClassID($productTypeId) 
    419     { 
     403    function getAllProductClassID($productTypeId) { 
    420404        $max = $this->getMax($productTypeId); 
    421405        $productClassIDs = array(); 
     
    434418     * @return void 
    435419     */ 
    436     function delAllProducts($productTypeId) 
    437     { 
     420    function delAllProducts($productTypeId) { 
    438421        $max = $this->getMax($productTypeId); 
    439422        for ($i = 0; $i <= $max; $i++) { 
     
    443426 
    444427    // 商品の削除 
    445     function delProduct($cart_no, $productTypeId) 
    446     { 
     428    function delProduct($cart_no, $productTypeId) { 
    447429        $max = $this->getMax($productTypeId); 
    448430        for ($i = 0; $i <= $max; $i++) { 
     
    454436 
    455437    // 数量の増加 
    456     function upQuantity($cart_no, $productTypeId) 
    457     { 
     438    function upQuantity($cart_no, $productTypeId) { 
    458439        $quantity = $this->getQuantity($cart_no, $productTypeId); 
    459440        if (strlen($quantity + 1) <= INT_LEN) { 
     
    463444 
    464445    // 数量の減少 
    465     function downQuantity($cart_no, $productTypeId) 
    466     { 
     446    function downQuantity($cart_no, $productTypeId) { 
    467447        $quantity = $this->getQuantity($cart_no, $productTypeId); 
    468448        if ($quantity > 1) { 
     
    478458     * @return integer 該当商品規格の数量 
    479459     */ 
    480     function getQuantity($cart_no, $productTypeId) 
    481     { 
     460    function getQuantity($cart_no, $productTypeId) { 
    482461        $max = $this->getMax($productTypeId); 
    483462        for ($i = 0; $i <= $max; $i++) { 
     
    496475     * @retrun void 
    497476     */ 
    498     function setQuantity($quantity, $cart_no, $productTypeId) 
    499     { 
     477    function setQuantity($quantity, $cart_no, $productTypeId) { 
    500478        $max = $this->getMax($productTypeId); 
    501479        for ($i = 0; $i <= $max; $i++) { 
     
    513491     * @return integer 商品規格ID 
    514492     */ 
    515     function getProductClassId($cart_no, $productTypeId) 
    516     { 
     493    function getProductClassId($cart_no, $productTypeId) { 
    517494        for ($i = 0; $i < count($this->cartSession[$productTypeId]); $i++) { 
    518495            if ($this->cartSession[$productTypeId][$i]['cart_no'] == $cart_no) { 
     
    536513     * @return string エラーが発生した場合はエラーメッセージ 
    537514     */ 
    538     function checkProducts($productTypeId) 
    539     { 
     515    function checkProducts($productTypeId) { 
    540516        $objProduct = new SC_Product_Ex(); 
    541         $objDelivery = new SC_Helper_Delivery_Ex(); 
    542         $arrDeliv = $objDelivery->getList($productTypeId); 
    543517        $tpl_message = ''; 
    544518 
     
    558532                 * 配送業者のチェック 
    559533                 */ 
     534                $arrDeliv = SC_Helper_Purchase_Ex::getDeliv($productTypeId); 
    560535                if (SC_Utils_Ex::isBlank($arrDeliv)) { 
    561536                    $tpl_message .= '※「' . $product['name'] . '」はまだ配送の準備ができておりません。'; 
     
    592567     * @return boolean 送料無料の場合 true 
    593568     */ 
    594     function isDelivFree($productTypeId) 
    595     { 
     569    function isDelivFree($productTypeId) { 
    596570        $objDb = new SC_Helper_DB_Ex(); 
    597571 
     
    652626        $results['deliv_fee'] = 0; 
    653627 
    654         $arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); 
    655         $results['order_tax_rate'] = $arrInfo['tax']; 
    656         $results['order_tax_rule'] = $arrInfo['tax_rule']; 
    657  
    658628        // 商品ごとの送料を加算 
    659629        if (OPTION_PRODUCT_DELIV_FEE == 1) { 
     
    668638            && !SC_Utils_Ex::isBlank($deliv_pref) 
    669639            && !SC_Utils_Ex::isBlank($deliv_id)) { 
    670             $results['deliv_fee'] += SC_Helper_Delivery_Ex::getDelivFee($deliv_pref, $deliv_id); 
     640            $results['deliv_fee'] += $this->sfGetDelivFee($deliv_pref, $deliv_id); 
    671641        } 
    672642 
     
    707677     * @return array 商品種別IDの配列 
    708678     */ 
    709     function getKeys() 
    710     { 
     679    function getKeys() { 
    711680        $keys = array_keys($this->cartSession); 
    712681        // 数量が 0 の商品種別は削除する 
     
    726695     * @return void 
    727696     */ 
    728     function registerKey($key) 
    729     { 
     697    function registerKey($key) { 
    730698        $_SESSION['cartKey'] = $key; 
    731699    } 
     
    736704     * @return void 
    737705     */ 
    738     function unsetKey() 
    739     { 
     706    function unsetKey() { 
    740707        unset($_SESSION['cartKey']); 
    741708    } 
     
    746713     * @return integer 商品種別ID 
    747714     */ 
    748     function getKey() 
    749     { 
     715    function getKey() { 
    750716        return $_SESSION['cartKey']; 
    751717    } 
     
    756722     * @return boolean カートが複数商品種別の場合 true 
    757723     */ 
    758     function isMultiple() 
    759     { 
     724    function isMultiple() { 
    760725        return count($this->getKeys()) > 1; 
    761726    } 
     
    767732     * @return boolean 指定の商品種別がカートに含まれる場合 true 
    768733     */ 
    769     function hasProductType($product_type_id) 
    770     { 
     734    function hasProductType($product_type_id) { 
    771735        return in_array($product_type_id, $this->getKeys()); 
    772736    } 
     737 
     738    /** 
     739     * 都道府県から配送料金を取得する. 
     740     * 
     741     * @param integer|array $pref_id 都道府県ID 又は都道府県IDの配列 
     742     * @param integer $deliv_id 配送業者ID 
     743     * @return string 指定の都道府県, 配送業者の配送料金 
     744     */ 
     745    function sfGetDelivFee($pref_id, $deliv_id = 0) { 
     746        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     747        if (!is_array($pref_id)) { 
     748            $pref_id = array($pref_id); 
     749        } 
     750        $sql = <<< __EOS__ 
     751            SELECT T1.fee AS fee 
     752            FROM dtb_delivfee T1 
     753                JOIN dtb_deliv T2 
     754                    ON T1.deliv_id = T2.deliv_id 
     755            WHERE T1.pref = ? 
     756                AND T1.deliv_id = ? 
     757                AND T2.del_flg = 0 
     758__EOS__; 
     759        $result = 0; 
     760        foreach ($pref_id as $pref) { 
     761            $result += $objQuery->getOne($sql, array($pref, $deliv_id)); 
     762        } 
     763        return $result; 
     764    } 
     765 
    773766} 
Note: See TracChangeset for help on using the changeset viewer.