Changeset 22796 for branches/version-2_12-dev/data/class/SC_CartSession.php
- Timestamp:
- 2013/05/02 18:11:36 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/SC_CartSession.php
r22707 r22796 28 28 * @version $Id$ 29 29 */ 30 class SC_CartSession 31 { 30 class SC_CartSession { 32 31 /** ユニークIDを指定する. */ 33 32 var $key_tmp; … … 37 36 38 37 /* コンストラクタ */ 39 function __construct($cartKey = 'cart') 40 { 38 function __construct($cartKey = 'cart') { 41 39 if (!isset($_SESSION[$cartKey])) { 42 40 $_SESSION[$cartKey] = array(); … … 46 44 47 45 // 商品購入処理中のロック 48 function saveCurrentCart($key_tmp, $productTypeId) 49 { 46 function saveCurrentCart($key_tmp, $productTypeId) { 50 47 $this->key_tmp = 'savecart_' . $key_tmp; 51 48 // すでに情報がなければ現状のカート情報を記録しておく … … 62 59 63 60 // 商品購入中の変更があったかをチェックする。 64 function getCancelPurchase($productTypeId) 65 { 61 function getCancelPurchase($productTypeId) { 66 62 $ret = isset($this->cartSession[$productTypeId]['cancel_purchase']) 67 63 ? $this->cartSession[$productTypeId]['cancel_purchase'] : ''; … … 71 67 72 68 // 購入処理中に商品に変更がなかったかを判定 73 function checkChangeCart($productTypeId) 74 { 69 function checkChangeCart($productTypeId) { 75 70 $change = false; 76 71 $max = $this->getMax($productTypeId); … … 100 95 101 96 // 次に割り当てるカートのIDを取得する 102 function getNextCartID($productTypeId) 103 { 97 function getNextCartID($productTypeId) { 104 98 $count = array(); 105 99 foreach ($this->cartSession[$productTypeId] as $key => $value) { … … 117 111 * @deprecated SC_CartSession::getCartList() を使用してください 118 112 */ 119 function getProductTotal($id, $productTypeId) 120 { 113 function getProductTotal($id, $productTypeId) { 121 114 $max = $this->getMax($productTypeId); 122 115 for ($i = 0; $i <= $max; $i++) { … … 136 129 137 130 // 値のセット 138 function setProductValue($id, $key, $val, $productTypeId) 139 { 131 function setProductValue($id, $key, $val, $productTypeId) { 140 132 $max = $this->getMax($productTypeId); 141 133 for ($i = 0; $i <= $max; $i++) { … … 149 141 150 142 // カート内商品の最大要素番号を取得する。 151 function getMax($productTypeId) 152 { 143 function getMax($productTypeId) { 153 144 $max = 0; 154 145 if (count($this->cartSession[$productTypeId]) > 0) { … … 165 156 166 157 // カート内商品数量の合計 167 function getTotalQuantity($productTypeId) 168 { 158 function getTotalQuantity($productTypeId) { 169 159 $total = 0; 170 160 $max = $this->getMax($productTypeId); … … 176 166 177 167 // 全商品の合計価格 178 function getAllProductsTotal($productTypeId) 179 { 168 function getAllProductsTotal($productTypeId) { 180 169 // 税込み合計 181 170 $total = 0; … … 201 190 202 191 // 全商品の合計税金 203 function getAllProductsTax($productTypeId) 204 { 192 function getAllProductsTax($productTypeId) { 205 193 // 税合計 206 194 $total = 0; … … 216 204 217 205 // 全商品の合計ポイント 218 function getAllProductsPoint($productTypeId) 219 { 206 function getAllProductsPoint($productTypeId) { 220 207 // ポイント合計 221 208 $total = 0; … … 242 229 243 230 // カートへの商品追加 244 function addProduct($product_class_id, $quantity) 245 { 231 function addProduct($product_class_id, $quantity) { 246 232 $objProduct = new SC_Product_Ex(); 247 233 $arrProduct = $objProduct->getProductsClass($product_class_id); … … 267 253 268 254 // 前頁のURLを記録しておく 269 function setPrevURL($url, $excludePaths = array()) 270 { 255 function setPrevURL($url, $excludePaths = array()) { 271 256 // 前頁として記録しないページを指定する。 272 257 $arrExclude = array( … … 289 274 290 275 // 前頁のURLを取得する 291 function getPrevURL() 292 { 276 function getPrevURL() { 293 277 return isset($_SESSION['prev_url']) ? $_SESSION['prev_url'] : ''; 294 278 } 295 279 296 280 // キーが一致した商品の削除 297 function delProductKey($keyname, $val, $productTypeId) 298 { 281 function delProductKey($keyname, $val, $productTypeId) { 299 282 $max = count($this->cartSession[$productTypeId]); 300 283 for ($i = 0; $i < $max; $i++) { … … 305 288 } 306 289 307 function setValue($key, $val, $productTypeId) 308 { 290 function setValue($key, $val, $productTypeId) { 309 291 $this->cartSession[$productTypeId][$key] = $val; 310 292 } 311 293 312 function getValue($key, $productTypeId) 313 { 294 function getValue($key, $productTypeId) { 314 295 return $this->cartSession[$productTypeId][$key]; 315 296 } … … 319 300 * productsClass項目から、不必要な項目を削除する。 320 301 */ 321 function adjustSessionProductsClass(&$arrProductsClass) 322 { 302 function adjustSessionProductsClass(&$arrProductsClass) { 323 303 $arrNecessaryItems = array( 324 304 'product_id' => true, … … 353 333 * @return array カート内商品一覧の配列 354 334 */ 355 function getCartList($productTypeId) 356 { 335 function getCartList($productTypeId) { 357 336 $objProduct = new SC_Product_Ex(); 358 337 $max = $this->getMax($productTypeId); … … 394 373 * @return array すべてのカートの内容 395 374 */ 396 function getAllCartList() 397 { 375 function getAllCartList() { 398 376 $results = array(); 399 377 $cartKeys = $this->getKeys(); … … 411 389 412 390 /** 391 * @deprected getAllProductClassID を使用して下さい 392 */ 393 function getAllProductID($productTypeId) { 394 trigger_error('正しく動作しないメソッドが呼び出されました。', E_USER_ERROR); 395 } 396 397 /** 413 398 * カート内にある商品規格IDを全て取得する. 414 399 * … … 416 401 * @return array 商品規格ID の配列 417 402 */ 418 function getAllProductClassID($productTypeId) 419 { 403 function getAllProductClassID($productTypeId) { 420 404 $max = $this->getMax($productTypeId); 421 405 $productClassIDs = array(); … … 434 418 * @return void 435 419 */ 436 function delAllProducts($productTypeId) 437 { 420 function delAllProducts($productTypeId) { 438 421 $max = $this->getMax($productTypeId); 439 422 for ($i = 0; $i <= $max; $i++) { … … 443 426 444 427 // 商品の削除 445 function delProduct($cart_no, $productTypeId) 446 { 428 function delProduct($cart_no, $productTypeId) { 447 429 $max = $this->getMax($productTypeId); 448 430 for ($i = 0; $i <= $max; $i++) { … … 454 436 455 437 // 数量の増加 456 function upQuantity($cart_no, $productTypeId) 457 { 438 function upQuantity($cart_no, $productTypeId) { 458 439 $quantity = $this->getQuantity($cart_no, $productTypeId); 459 440 if (strlen($quantity + 1) <= INT_LEN) { … … 463 444 464 445 // 数量の減少 465 function downQuantity($cart_no, $productTypeId) 466 { 446 function downQuantity($cart_no, $productTypeId) { 467 447 $quantity = $this->getQuantity($cart_no, $productTypeId); 468 448 if ($quantity > 1) { … … 478 458 * @return integer 該当商品規格の数量 479 459 */ 480 function getQuantity($cart_no, $productTypeId) 481 { 460 function getQuantity($cart_no, $productTypeId) { 482 461 $max = $this->getMax($productTypeId); 483 462 for ($i = 0; $i <= $max; $i++) { … … 496 475 * @retrun void 497 476 */ 498 function setQuantity($quantity, $cart_no, $productTypeId) 499 { 477 function setQuantity($quantity, $cart_no, $productTypeId) { 500 478 $max = $this->getMax($productTypeId); 501 479 for ($i = 0; $i <= $max; $i++) { … … 513 491 * @return integer 商品規格ID 514 492 */ 515 function getProductClassId($cart_no, $productTypeId) 516 { 493 function getProductClassId($cart_no, $productTypeId) { 517 494 for ($i = 0; $i < count($this->cartSession[$productTypeId]); $i++) { 518 495 if ($this->cartSession[$productTypeId][$i]['cart_no'] == $cart_no) { … … 536 513 * @return string エラーが発生した場合はエラーメッセージ 537 514 */ 538 function checkProducts($productTypeId) 539 { 515 function checkProducts($productTypeId) { 540 516 $objProduct = new SC_Product_Ex(); 541 $objDelivery = new SC_Helper_Delivery_Ex();542 $arrDeliv = $objDelivery->getList($productTypeId);543 517 $tpl_message = ''; 544 518 … … 558 532 * 配送業者のチェック 559 533 */ 534 $arrDeliv = SC_Helper_Purchase_Ex::getDeliv($productTypeId); 560 535 if (SC_Utils_Ex::isBlank($arrDeliv)) { 561 536 $tpl_message .= '※「' . $product['name'] . '」はまだ配送の準備ができておりません。'; … … 592 567 * @return boolean 送料無料の場合 true 593 568 */ 594 function isDelivFree($productTypeId) 595 { 569 function isDelivFree($productTypeId) { 596 570 $objDb = new SC_Helper_DB_Ex(); 597 571 … … 652 626 $results['deliv_fee'] = 0; 653 627 654 $arrInfo = SC_Helper_DB_Ex::sfGetBasisData();655 $results['order_tax_rate'] = $arrInfo['tax'];656 $results['order_tax_rule'] = $arrInfo['tax_rule'];657 658 628 // 商品ごとの送料を加算 659 629 if (OPTION_PRODUCT_DELIV_FEE == 1) { … … 668 638 && !SC_Utils_Ex::isBlank($deliv_pref) 669 639 && !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); 671 641 } 672 642 … … 707 677 * @return array 商品種別IDの配列 708 678 */ 709 function getKeys() 710 { 679 function getKeys() { 711 680 $keys = array_keys($this->cartSession); 712 681 // 数量が 0 の商品種別は削除する … … 726 695 * @return void 727 696 */ 728 function registerKey($key) 729 { 697 function registerKey($key) { 730 698 $_SESSION['cartKey'] = $key; 731 699 } … … 736 704 * @return void 737 705 */ 738 function unsetKey() 739 { 706 function unsetKey() { 740 707 unset($_SESSION['cartKey']); 741 708 } … … 746 713 * @return integer 商品種別ID 747 714 */ 748 function getKey() 749 { 715 function getKey() { 750 716 return $_SESSION['cartKey']; 751 717 } … … 756 722 * @return boolean カートが複数商品種別の場合 true 757 723 */ 758 function isMultiple() 759 { 724 function isMultiple() { 760 725 return count($this->getKeys()) > 1; 761 726 } … … 767 732 * @return boolean 指定の商品種別がカートに含まれる場合 true 768 733 */ 769 function hasProductType($product_type_id) 770 { 734 function hasProductType($product_type_id) { 771 735 return in_array($product_type_id, $this->getKeys()); 772 736 } 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 773 766 }
Note: See TracChangeset
for help on using the changeset viewer.
