Changeset 22567 for branches/version-2_12-dev/data/class/SC_CartSession.php
- Timestamp:
- 2013/02/18 19:09:54 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/SC_CartSession.php
r22554 r22567 28 28 * @version $Id$ 29 29 */ 30 class SC_CartSession { 30 class SC_CartSession 31 { 31 32 /** ユニークIDを指定する. */ 32 33 var $key_tmp; … … 36 37 37 38 /* コンストラクタ */ 38 function __construct($cartKey = 'cart') { 39 function __construct($cartKey = 'cart') 40 { 39 41 if (!isset($_SESSION[$cartKey])) { 40 42 $_SESSION[$cartKey] = array(); … … 44 46 45 47 // 商品購入処理中のロック 46 function saveCurrentCart($key_tmp, $productTypeId) { 48 function saveCurrentCart($key_tmp, $productTypeId) 49 { 47 50 $this->key_tmp = 'savecart_' . $key_tmp; 48 51 // すでに情報がなければ現状のカート情報を記録しておく … … 59 62 60 63 // 商品購入中の変更があったかをチェックする。 61 function getCancelPurchase($productTypeId) { 64 function getCancelPurchase($productTypeId) 65 { 62 66 $ret = isset($this->cartSession[$productTypeId]['cancel_purchase']) 63 67 ? $this->cartSession[$productTypeId]['cancel_purchase'] : ''; … … 67 71 68 72 // 購入処理中に商品に変更がなかったかを判定 69 function checkChangeCart($productTypeId) { 73 function checkChangeCart($productTypeId) 74 { 70 75 $change = false; 71 76 $max = $this->getMax($productTypeId); … … 95 100 96 101 // 次に割り当てるカートのIDを取得する 97 function getNextCartID($productTypeId) { 102 function getNextCartID($productTypeId) 103 { 98 104 $count = array(); 99 105 foreach ($this->cartSession[$productTypeId] as $key => $value) { … … 111 117 * @deprecated SC_CartSession::getCartList() を使用してください 112 118 */ 113 function getProductTotal($id, $productTypeId) { 119 function getProductTotal($id, $productTypeId) 120 { 114 121 $max = $this->getMax($productTypeId); 115 122 for ($i = 0; $i <= $max; $i++) { … … 129 136 130 137 // 値のセット 131 function setProductValue($id, $key, $val, $productTypeId) { 138 function setProductValue($id, $key, $val, $productTypeId) 139 { 132 140 $max = $this->getMax($productTypeId); 133 141 for ($i = 0; $i <= $max; $i++) { … … 141 149 142 150 // カート内商品の最大要素番号を取得する。 143 function getMax($productTypeId) { 151 function getMax($productTypeId) 152 { 144 153 $max = 0; 145 154 if (count($this->cartSession[$productTypeId]) > 0) { … … 156 165 157 166 // カート内商品数量の合計 158 function getTotalQuantity($productTypeId) { 167 function getTotalQuantity($productTypeId) 168 { 159 169 $total = 0; 160 170 $max = $this->getMax($productTypeId); … … 166 176 167 177 // 全商品の合計価格 168 function getAllProductsTotal($productTypeId) { 178 function getAllProductsTotal($productTypeId) 179 { 169 180 // 税込み合計 170 181 $total = 0; … … 190 201 191 202 // 全商品の合計税金 192 function getAllProductsTax($productTypeId) { 203 function getAllProductsTax($productTypeId) 204 { 193 205 // 税合計 194 206 $total = 0; … … 204 216 205 217 // 全商品の合計ポイント 206 function getAllProductsPoint($productTypeId) { 218 function getAllProductsPoint($productTypeId) 219 { 207 220 // ポイント合計 208 221 $total = 0; … … 229 242 230 243 // カートへの商品追加 231 function addProduct($product_class_id, $quantity) { 244 function addProduct($product_class_id, $quantity) 245 { 232 246 $objProduct = new SC_Product_Ex(); 233 247 $arrProduct = $objProduct->getProductsClass($product_class_id); … … 253 267 254 268 // 前頁のURLを記録しておく 255 function setPrevURL($url, $excludePaths = array()) { 269 function setPrevURL($url, $excludePaths = array()) 270 { 256 271 // 前頁として記録しないページを指定する。 257 272 $arrExclude = array( … … 274 289 275 290 // 前頁のURLを取得する 276 function getPrevURL() { 291 function getPrevURL() 292 { 277 293 return isset($_SESSION['prev_url']) ? $_SESSION['prev_url'] : ''; 278 294 } 279 295 280 296 // キーが一致した商品の削除 281 function delProductKey($keyname, $val, $productTypeId) { 297 function delProductKey($keyname, $val, $productTypeId) 298 { 282 299 $max = count($this->cartSession[$productTypeId]); 283 300 for ($i = 0; $i < $max; $i++) { … … 288 305 } 289 306 290 function setValue($key, $val, $productTypeId) { 307 function setValue($key, $val, $productTypeId) 308 { 291 309 $this->cartSession[$productTypeId][$key] = $val; 292 310 } 293 311 294 function getValue($key, $productTypeId) { 312 function getValue($key, $productTypeId) 313 { 295 314 return $this->cartSession[$productTypeId][$key]; 296 315 } … … 300 319 * productsClass項目から、不必要な項目を削除する。 301 320 */ 302 function adjustSessionProductsClass(&$arrProductsClass) { 321 function adjustSessionProductsClass(&$arrProductsClass) 322 { 303 323 $arrNecessaryItems = array( 304 324 'product_id' => true, … … 333 353 * @return array カート内商品一覧の配列 334 354 */ 335 function getCartList($productTypeId) { 355 function getCartList($productTypeId) 356 { 336 357 $objProduct = new SC_Product_Ex(); 337 358 $max = $this->getMax($productTypeId); … … 373 394 * @return array すべてのカートの内容 374 395 */ 375 function getAllCartList() { 396 function getAllCartList() 397 { 376 398 $results = array(); 377 399 $cartKeys = $this->getKeys(); … … 394 416 * @return array 商品規格ID の配列 395 417 */ 396 function getAllProductClassID($productTypeId) { 418 function getAllProductClassID($productTypeId) 419 { 397 420 $max = $this->getMax($productTypeId); 398 421 $productClassIDs = array(); … … 411 434 * @return void 412 435 */ 413 function delAllProducts($productTypeId) { 436 function delAllProducts($productTypeId) 437 { 414 438 $max = $this->getMax($productTypeId); 415 439 for ($i = 0; $i <= $max; $i++) { … … 419 443 420 444 // 商品の削除 421 function delProduct($cart_no, $productTypeId) { 445 function delProduct($cart_no, $productTypeId) 446 { 422 447 $max = $this->getMax($productTypeId); 423 448 for ($i = 0; $i <= $max; $i++) { … … 429 454 430 455 // 数量の増加 431 function upQuantity($cart_no, $productTypeId) { 456 function upQuantity($cart_no, $productTypeId) 457 { 432 458 $quantity = $this->getQuantity($cart_no, $productTypeId); 433 459 if (strlen($quantity + 1) <= INT_LEN) { … … 437 463 438 464 // 数量の減少 439 function downQuantity($cart_no, $productTypeId) { 465 function downQuantity($cart_no, $productTypeId) 466 { 440 467 $quantity = $this->getQuantity($cart_no, $productTypeId); 441 468 if ($quantity > 1) { … … 451 478 * @return integer 該当商品規格の数量 452 479 */ 453 function getQuantity($cart_no, $productTypeId) { 480 function getQuantity($cart_no, $productTypeId) 481 { 454 482 $max = $this->getMax($productTypeId); 455 483 for ($i = 0; $i <= $max; $i++) { … … 468 496 * @retrun void 469 497 */ 470 function setQuantity($quantity, $cart_no, $productTypeId) { 498 function setQuantity($quantity, $cart_no, $productTypeId) 499 { 471 500 $max = $this->getMax($productTypeId); 472 501 for ($i = 0; $i <= $max; $i++) { … … 484 513 * @return integer 商品規格ID 485 514 */ 486 function getProductClassId($cart_no, $productTypeId) { 515 function getProductClassId($cart_no, $productTypeId) 516 { 487 517 for ($i = 0; $i < count($this->cartSession[$productTypeId]); $i++) { 488 518 if ($this->cartSession[$productTypeId][$i]['cart_no'] == $cart_no) { … … 506 536 * @return string エラーが発生した場合はエラーメッセージ 507 537 */ 508 function checkProducts($productTypeId) { 538 function checkProducts($productTypeId) 539 { 509 540 $objProduct = new SC_Product_Ex(); 510 541 $objDelivery = new SC_Helper_Delivery_Ex(); … … 561 592 * @return boolean 送料無料の場合 true 562 593 */ 563 function isDelivFree($productTypeId) { 594 function isDelivFree($productTypeId) 595 { 564 596 $objDb = new SC_Helper_DB_Ex(); 565 597 … … 675 707 * @return array 商品種別IDの配列 676 708 */ 677 function getKeys() { 709 function getKeys() 710 { 678 711 $keys = array_keys($this->cartSession); 679 712 // 数量が 0 の商品種別は削除する … … 693 726 * @return void 694 727 */ 695 function registerKey($key) { 728 function registerKey($key) 729 { 696 730 $_SESSION['cartKey'] = $key; 697 731 } … … 702 736 * @return void 703 737 */ 704 function unsetKey() { 738 function unsetKey() 739 { 705 740 unset($_SESSION['cartKey']); 706 741 } … … 711 746 * @return integer 商品種別ID 712 747 */ 713 function getKey() { 748 function getKey() 749 { 714 750 return $_SESSION['cartKey']; 715 751 } … … 720 756 * @return boolean カートが複数商品種別の場合 true 721 757 */ 722 function isMultiple() { 758 function isMultiple() 759 { 723 760 return count($this->getKeys()) > 1; 724 761 } … … 730 767 * @return boolean 指定の商品種別がカートに含まれる場合 true 731 768 */ 732 function hasProductType($product_type_id) { 769 function hasProductType($product_type_id) 770 { 733 771 return in_array($product_type_id, $this->getKeys()); 734 772 }
Note: See TracChangeset
for help on using the changeset viewer.