Changeset 18852 for branches/version-2_5-dev/data/class/SC_CartSession.php
- Timestamp:
- 2010/10/13 18:03:46 (13 years ago)
- bzr:base-revision:
- svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_5-dev:18851
- bzr:committer:
- Kentaro Ohkouchi <ohkouchi@loop-az.jp>
- bzr:file-ids:
data/Smarty/templates/default/cart/index.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fcart%2Findex.tpl
data/Smarty/templates/default/list.tpl 15747@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Flist.tpl
data/Smarty/templates/default/shopping/confirm.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fshopping%2Fconfirm.tpl
data/class/SC_CartSession.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2FSC_CartSession.php
data/class/SC_Product.php 18277@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcomu-ver2%2Fdata%2Fclass%2FSC_Product.php
data/class/helper/SC_Helper_DB.php 15176@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fhelper%2FSC_Helper_DB.php
data/class/pages/cart/LC_Page_Cart.php 15179@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fcart%2FLC_Page_Cart.php
data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Cart.php 15367@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Ffrontparts%2Fbloc%2FLC_Page_FrontParts_Bloc_Cart.php
data/class/pages/products/LC_Page_Products_List.php 15154@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fproducts%2FLC_Page_Products_List.php
data/class/pages/shopping/LC_Page_Shopping_Complete.php 15223@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fshopping%2FLC_Page_Shopping_Complete.php
data/class/pages/shopping/LC_Page_Shopping_Confirm.php 15223@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fshopping%2FLC_Page_Shopping_Confirm.php
data/class/util/SC_Utils.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Futil%2FSC_Utils.php
data/install.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Finstall.php- bzr:mapping-version:
- v4
- bzr:merge:
ohkouchi@loop-az.jp-20101013090124-oqet9229jtkdpn09- bzr:repository-uuid:
- 1e3b908f-19a9-db11-a64c-001125224ba8
- bzr:revision-id:
- ohkouchi@loop-az.jp-20101013090342-ipwymntv4wfnpwcf
- bzr:revno:
- 2332
- bzr:revprop:branch-nick:
- branches/version-2_5-dev
- bzr:root:
- branches/version-2_5-dev
- bzr:text-revisions:
data/Smarty/templates/default/cart/index.tpl ohkouchi@loop-az.jp-20101013090124-oqet9229jtkdpn09
data/Smarty/templates/default/list.tpl ohkouchi@loop-az.jp-20101013090124-oqet9229jtkdpn09
data/Smarty/templates/default/shopping/confirm.tpl ohkouchi@loop-az.jp-20101013090124-oqet9229jtkdpn09
data/class/SC_CartSession.php ohkouchi@loop-az.jp-20101013090124-oqet9229jtkdpn09
data/class/SC_Product.php ohkouchi@loop-az.jp-20101013084914-tqtme0o2qlpunxyz
data/class/helper/SC_Helper_DB.php ohkouchi@loop-az.jp-20101013090124-oqet9229jtkdpn09
data/class/pages/cart/LC_Page_Cart.php ohkouchi@loop-az.jp-20101013090124-oqet9229jtkdpn09
data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Cart.php ohkouchi@loop-az.jp-20101013084914-tqtme0o2qlpunxyz
data/class/pages/products/LC_Page_Products_List.php ohkouchi@loop-az.jp-20101013084914-tqtme0o2qlpunxyz
data/class/pages/shopping/LC_Page_Shopping_Complete.php ohkouchi@loop-az.jp-20101013090124-oqet9229jtkdpn09
data/class/pages/shopping/LC_Page_Shopping_Confirm.php ohkouchi@loop-az.jp-20101013090124-oqet9229jtkdpn09
data/class/util/SC_Utils.php ohkouchi@loop-az.jp-20101013084914-tqtme0o2qlpunxyz- bzr:timestamp:
- 2010-10-13 18:03:42.963999987 +0900
- bzr:user-agent:
- bzr2.2.0+bzr-svn1.0.3
- svn:original-date:
- 2010-10-13T09:03:42.964000Z
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/SC_CartSession.php
r18851 r18852 24 24 /* カートセッション管理クラス */ 25 25 class SC_CartSession { 26 var $key_tmp; // ユニークIDを指定する。 26 /** ユニークIDを指定する. */ 27 var $key_tmp; 28 29 /** カートのセッション変数. */ 30 var $cartSession; 27 31 28 32 /* コンストラクタ */ 29 function SC_CartSession() { 33 function SC_CartSession($cartKey = "cart") { 34 $this->cartSession =& $_SESSION[$cartKey]; 30 35 } 31 36 32 37 // 商品購入処理中のロック 33 function saveCurrentCart($key_tmp, $ key) {38 function saveCurrentCart($key_tmp, $productTypeId) { 34 39 $this->key_tmp = "savecart_" . $key_tmp; 35 40 // すでに情報がなければ現状のカート情報を記録しておく 36 41 if(count($_SESSION[$this->key_tmp]) == 0) { 37 $_SESSION[$this->key_tmp] = $ _SESSION[$key];42 $_SESSION[$this->key_tmp] = $this->cartSession[$productTypeId]; 38 43 } 39 44 // 1世代古いコピー情報は、削除しておく 40 45 foreach($_SESSION as $k => $val) { 41 46 if($k != $this->key_tmp && preg_match("/^savecart_/", $k)) { 42 unset($ _SESSION[$key][$k]);43 } 44 } 45 $this->registerKey($ key);47 unset($this->cartSession[$productTypeId][$k]); 48 } 49 } 50 $this->registerKey($productTypeId); 46 51 } 47 52 48 53 // 商品購入中の変更があったかをチェックする。 49 function getCancelPurchase($key) { 50 $this->addKey($key); 51 $ret = isset($_SESSION[$key]['cancel_purchase']) 52 ? $_SESSION[$key]['cancel_purchase'] : ""; 53 $_SESSION[$key]['cancel_purchase'] = false; 54 function getCancelPurchase($productTypeId) { 55 $ret = isset($this->cartSession[$productTypeId]['cancel_purchase']) 56 ? $this->cartSession[$productTypeId]['cancel_purchase'] : ""; 57 $this->cartSession[$productTypeId]['cancel_purchase'] = false; 54 58 return $ret; 55 59 } 56 60 57 61 // 購入処理中に商品に変更がなかったかを判定 58 function checkChangeCart($key) { 59 $this->addKey($key); 62 function checkChangeCart($productTypeId) { 60 63 $change = false; 61 $max = $this->getMax( );64 $max = $this->getMax($productTypeId); 62 65 for($i = 1; $i <= $max; $i++) { 63 if ($_SESSION[$key][$i]['quantity'] != $_SESSION[$this->key_tmp][$i]['quantity']) { 66 if ($this->cartSession[$productTypeId][$i]['quantity'] 67 != $_SESSION[$this->key_tmp][$i]['quantity']) { 68 64 69 $change = true; 65 70 break; 66 71 } 67 if ($_SESSION[$key][$i]['id'] != $_SESSION[$this->key_tmp][$i]['id']) { 72 if ($this->cartSession[$productTypeId][$i]['id'] 73 != $_SESSION[$this->key_tmp][$i]['id']) { 74 68 75 $change = true; 69 76 break; … … 73 80 // 一時カートのクリア 74 81 unset($_SESSION[$this->key_tmp]); 75 $ _SESSION[$key]['cancel_purchase'] = true;82 $this->cartSession[$productTypeId][$key]['cancel_purchase'] = true; 76 83 } else { 77 $ _SESSION[$key]['cancel_purchase'] = false;78 } 79 return $ _SESSION[$key]['cancel_purchase'];84 $this->cartSession[$productTypeId]['cancel_purchase'] = false; 85 } 86 return $this->cartSession[$productTypeId]['cancel_purchase']; 80 87 } 81 88 82 89 // 次に割り当てるカートのIDを取得する 83 function getNextCartID($key) { 84 $this->addKey($key); 85 foreach($_SESSION[$key] as $k => $val){ 86 $arrRet[] = $_SESSION[$key][$k]['cart_no']; 90 function getNextCartID($productTypeId) { 91 foreach($this->cartSession[$productTypeId] as $key => $val){ 92 $arrRet[] = $this->cartSession[$productTypeId][$key]['cart_no']; 87 93 } 88 94 return (max($arrRet) + 1); … … 95 101 * @param integer $id 96 102 * @return string 商品ごとの合計価格(税込み) 103 * @deprecated SC_CartSession::getCartList() を使用してください 97 104 */ 98 function getProductTotal($id, $key) { 99 $this->addKey($key); 100 $max = $this->getMax(); 101 for($i = 0; $i <= $max; $i++) { 102 if(isset($_SESSION[$key][$i]['id']) 103 && $_SESSION[$key][$i]['id'] == $id) { 105 function getProductTotal($id, $productTypeId) { 106 $max = $this->getMax($productTypeId); 107 for($i = 0; $i <= $max; $i++) { 108 if(isset($this->cartSession[$productTypeId][$i]['id']) 109 && $this->cartSession[$productTypeId][$i]['id'] == $id) { 104 110 105 111 // 税込み合計 106 $price = $ _SESSION[$key][$i]['price'];107 $quantity = $ _SESSION[$key][$i]['quantity'];112 $price = $this->cartSession[$productTypeId][$i]['price']; 113 $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 108 114 $pre_tax = SC_Helper_DB_Ex::sfPreTax($price); 109 115 $total = $pre_tax * $quantity; … … 115 121 116 122 // 値のセット 117 function setProductValue($id, $k, $val, $key) { 118 $this->addKey($key); 119 $max = $this->getMax($key); 120 for($i = 0; $i <= $max; $i++) { 121 if(isset($_SESSION[$key][$i]['id']) 122 && $_SESSION[$key][$i]['id'] == $id) { 123 $_SESSION[$key][$i][$k] = $val; 123 function setProductValue($id, $key, $val, $productTypeId) { 124 $max = $this->getMax($productTypeId); 125 for($i = 0; $i <= $max; $i++) { 126 if(isset($this->cartSession[$productTypeId][$i]['id']) 127 && $this->cartSession[$productTypeId][$i]['id'] == $id) { 128 $this->cartSession[$productTypeId][$i][$key] = $val; 124 129 } 125 130 } … … 127 132 128 133 // カート内商品の最大要素番号を取得する。 129 function getMax($key) { 130 $this->addKey($key); 131 $cnt = 0; 132 $pos = 0; 134 function getMax($productTypeId) { 133 135 $max = 0; 134 if (count($ _SESSION[$key]) > 0){135 foreach($ _SESSION[$key] as $k=> $val) {136 if (is_numeric($k )) {137 if($max < $k ) {138 $max = $k ;136 if (count($this->cartSession[$productTypeId]) > 0){ 137 foreach($this->cartSession[$productTypeId] as $key => $val) { 138 if (is_numeric($key)) { 139 if($max < $key) { 140 $max = $key; 139 141 } 140 142 } … … 145 147 146 148 // カート内商品数の合計 147 function getTotalQuantity($key) { 148 $this->addKey($key); 149 function getTotalQuantity($productTypeId) { 149 150 $total = 0; 150 $max = $this->getMax($ key);151 for($i = 0; $i <= $max; $i++) { 152 $total+= $ _SESSION[$key][$i]['quantity'];151 $max = $this->getMax($productTypeId); 152 for($i = 0; $i <= $max; $i++) { 153 $total+= $this->cartSession[$productTypeId][$i]['quantity']; 153 154 } 154 155 return $total; … … 157 158 158 159 // 全商品の合計価格 159 function getAllProductsTotal($key) { 160 $this->addKey($key); 160 function getAllProductsTotal($productTypeId) { 161 161 // 税込み合計 162 162 $total = 0; 163 $max = $this->getMax($key); 164 for($i = 0; $i <= $max; $i++) { 165 166 if (!isset($_SESSION[$key][$i]['price'])) { 167 $_SESSION[$key][$i]['price'] = ""; 168 } 169 $price = $_SESSION[$key][$i]['price']; 170 171 if (!isset($_SESSION[$key][$i]['quantity'])) { 172 $_SESSION[$key][$i]['quantity'] = ""; 173 } 174 $quantity = $_SESSION[$key][$i]['quantity']; 163 $max = $this->getMax($productTypeId); 164 for($i = 0; $i <= $max; $i++) { 165 166 if (!isset($this->cartSession[$productTypeId][$i]['price'])) { 167 $this->cartSession[$productTypeId][$i]['price'] = ""; 168 } 169 170 $price = $this->cartSession[$productTypeId][$i]['price']; 171 172 if (!isset($this->cartSession[$productTypeId][$i]['quantity'])) { 173 $this->cartSession[$productTypeId][$i]['quantity'] = ""; 174 } 175 $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 175 176 176 177 $pre_tax = SC_Helper_DB_Ex::sfPreTax($price); … … 181 182 182 183 // 全商品の合計税金 183 function getAllProductsTax($key) { 184 $this->addKey($key); 184 function getAllProductsTax($productTypeId) { 185 185 // 税合計 186 186 $total = 0; 187 $max = $this->getMax($ key);188 for($i = 0; $i <= $max; $i++) { 189 $price = $ _SESSION[$key][$i]['price'];190 $quantity = $ _SESSION[$key][$i]['quantity'];187 $max = $this->getMax($productTypeId); 188 for($i = 0; $i <= $max; $i++) { 189 $price = $this->cartSession[$productTypeId][$i]['price']; 190 $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 191 191 $tax = SC_Helper_DB_Ex::sfTax($price); 192 192 $total+= ($tax * $quantity); … … 196 196 197 197 // 全商品の合計ポイント 198 function getAllProductsPoint($key) { 199 $this->addKey($key); 198 function getAllProductsPoint($productTypeId) { 200 199 // ポイント合計 201 200 $total = 0; 202 201 if (USE_POINT !== false) { 203 $max = $this->getMax($ key);202 $max = $this->getMax($productTypeId); 204 203 for($i = 0; $i <= $max; $i++) { 205 $price = $ _SESSION[$key][$i]['price'];206 $quantity = $ _SESSION[$key][$i]['quantity'];207 208 if (!isset($ _SESSION[$key][$i]['point_rate'])) {209 $ _SESSION[$key][$i]['point_rate'] = "";210 } 211 $point_rate = $ _SESSION[$key][$i]['point_rate'];212 213 if (!isset($ _SESSION[$key][$i]['id'][0])) {214 $ _SESSION[$key][$i]['id'][0] = "";215 } 216 $id = $ _SESSION[$key][$i]['id'][0];204 $price = $this->cartSession[$productTypeId][$i]['price']; 205 $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 206 207 if (!isset($this->cartSession[$productTypeId][$i]['point_rate'])) { 208 $this->cartSession[$productTypeId][$i]['point_rate'] = ""; 209 } 210 $point_rate = $this->cartSession[$productTypeId][$i]['point_rate']; 211 212 if (!isset($this->cartSession[$productTypeId][$i]['id'][0])) { 213 $this->cartSession[$productTypeId][$i]['id'][0] = ""; 214 } 215 $id = $this->cartSession[$productTypeId][$i]['id'][0]; 217 216 $point = SC_Utils_Ex::sfPrePoint($price, $point_rate, POINT_RULE, $id); 218 217 $total+= ($point * $quantity); … … 223 222 224 223 // カートへの商品追加 225 function addProduct($id, $quantity, $key) { 226 $this->addKey($key); 224 function addProduct($id, $quantity, $productTypeId) { 227 225 $find = false; 228 $max = $this->getMax($ key);229 for($i = 0; $i <= $max; $i++) { 230 231 if($ _SESSION[$key][$i]['id'] == $id) {232 $val = $ _SESSION[$key][$i]['quantity'] + $quantity;226 $max = $this->getMax($productTypeId); 227 for($i = 0; $i <= $max; $i++) { 228 229 if($this->cartSession[$productTypeId][$i]['id'] == $id) { 230 $val = $this->cartSession[$productTypeId][$i]['quantity'] + $quantity; 233 231 if(strlen($val) <= INT_LEN) { 234 $ _SESSION[$key][$i]['quantity']+= $quantity;232 $this->cartSession[$productTypeId][$i]['quantity'] += $quantity; 235 233 } 236 234 $find = true; … … 238 236 } 239 237 if(!$find) { 240 $ _SESSION[$key][$max+1]['id'] = $id;241 $ _SESSION[$key][$max+1]['quantity'] = $quantity;242 $ _SESSION[$key][$max+1]['cart_no'] = $this->getNextCartID($key);238 $this->cartSession[$productTypeId][$max+1]['id'] = $id; 239 $this->cartSession[$productTypeId][$max+1]['quantity'] = $quantity; 240 $this->cartSession[$productTypeId][$max+1]['cart_no'] = $this->getNextCartID($productTypeId); 243 241 } 244 242 } 245 243 246 244 // 前頁のURLを記録しておく 247 function setPrevURL($url, $key) { 248 $this->addKey($key); 245 function setPrevURL($url) { 249 246 // 前頁として記録しないページを指定する。 250 247 $arrExclude = array( … … 254 251 // ページチェックを行う。 255 252 foreach($arrExclude as $val) { 256 if( ereg($val, $url)) {253 if(preg_match("/" . preg_quote($val) . "/", $url)) { 257 254 $exclude = true; 258 255 break; … … 261 258 // 除外ページでない場合は、前頁として記録する。 262 259 if(!$exclude) { 263 $_SESSION[ $key]['prev_url'] = $url;260 $_SESSION['prev_url'] = $url; 264 261 } 265 262 } 266 263 267 264 // 前頁のURLを取得する 268 function getPrevURL($key) { 269 $this->addKey($key); 270 return isset($_SESSION[$key]['prev_url']) 271 ? $_SESSION[$key]['prev_url'] : ""; 265 function getPrevURL() { 266 return isset($_SESSION['prev_url']) ? $_SESSION['prev_url'] : ""; 272 267 } 273 268 274 269 // キーが一致した商品の削除 275 function delProductKey($keyname, $val, $key) { 276 $this->addKey($key); 277 $max = count($_SESSION[$key]); 270 function delProductKey($keyname, $val, $productTypeId) { 271 $max = count($this->cartSession[$productTypeId]); 278 272 for($i = 0; $i < $max; $i++) { 279 if($_SESSION[$key][$i][$keyname] == $val) { 280 unset($_SESSION[$key][$i]); 281 } 282 } 283 } 284 285 function setValue($k, $val, $key) { 286 $this->addKey($key); 287 $_SESSION[$key][$k] = $val; 288 } 289 290 function getValue($k, $key) { 291 $this->addKey($key); 292 return $_SESSION[$key][$k]; 293 } 294 295 function getCartList($key) { 296 $this->addKey($key); 297 $max = $this->getMax($key); 273 if($this->cartSession[$productTypeId][$i][$keyname] == $val) { 274 unset($this->cartSession[$productTypeId][$i]); 275 } 276 } 277 } 278 279 function setValue($key, $val, $productTypeId) { 280 $this->cartSession[$productTypeId][$key] = $val; 281 } 282 283 function getValue($key, $productTypeId) { 284 return $this->cartSession[$productTypeId][$key]; 285 } 286 287 function getCartList($productTypeId) { 288 $objProduct = new SC_Product(); 289 $max = $this->getMax($productTypeId); 298 290 $arrRet = array(); 299 291 for($i = 0; $i <= $max; $i++) { 300 if(isset($_SESSION[$key][$i]['cart_no']) 301 && $_SESSION[$key][$i]['cart_no'] != "") { 302 $arrRet[] = $_SESSION[$key][$i]; 292 if(isset($this->cartSession[$productTypeId][$i]['cart_no']) 293 && $this->cartSession[$productTypeId][$i]['cart_no'] != "") { 294 295 if (SC_Utils_Ex::isBlank($this->cartSession[$productTypeId][$i]['productsClass'])) { 296 $this->cartSession[$productTypeId][$i]['productsClass'] =& 297 $objProduct->getDetailAndProductsClass( 298 $this->cartSession[$productTypeId][$i]['id']); 299 } 300 301 $price = $this->cartSession[$productTypeId][$i]['productsClass']['price02']; 302 $this->cartSession[$productTypeId][$i]['price'] = $price; 303 304 $this->cartSession[$productTypeId][$i]['point_rate'] = 305 $this->cartSession[$productTypeId][$i]['productsClass']['point_rate']; 306 307 308 $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 309 $pre_tax = SC_Helper_DB_Ex::sfPreTax($price); 310 $total = $pre_tax * $quantity; 311 312 $this->cartSession[$productTypeId][$i]['total_pretax'] = $total; 313 314 $arrRet[] =& $this->cartSession[$productTypeId][$i]; 303 315 } 304 316 } … … 307 319 308 320 // カート内にある商品IDを全て取得する 309 function getAllProductID($key) { 310 $this->addKey($key); 311 $max = $this->getMax($key); 312 for($i = 0; $i <= $max; $i++) { 313 if($_SESSION[$key][$i]['cart_no'] != "") { 314 $arrRet[] = $_SESSION[$key][$i]['id'][0]; 321 function getAllProductID($productTypeId) { 322 $max = $this->getMax($productTypeId); 323 for($i = 0; $i <= $max; $i++) { 324 if($this->cartSession[$productTypeId][$i]['cart_no'] != "") { 325 $arrRet[] = $this->cartSession[$productTypeId][$i]['id'][0]; 315 326 } 316 327 } … … 318 329 } 319 330 320 function delAllProducts($key) { 321 $this->addKey($key); 322 $max = $this->getMax($key); 323 for($i = 0; $i <= $max; $i++) { 324 unset($_SESSION[$key][$i]); 331 function delAllProducts($productTypeId) { 332 $max = $this->getMax($productTypeId); 333 for($i = 0; $i <= $max; $i++) { 334 unset($this->cartSession[$productTypeId][$i]); 325 335 } 326 336 } 327 337 328 338 // 商品の削除 329 function delProduct($cart_no, $key) { 330 $this->addKey($key); 331 $max = $this->getMax($key); 332 for($i = 0; $i <= $max; $i++) { 333 if($_SESSION[$key][$i]['cart_no'] == $cart_no) { 334 unset($_SESSION[$key][$i]); 339 function delProduct($cart_no, $productTypeId) { 340 $max = $this->getMax($productTypeId); 341 for($i = 0; $i <= $max; $i++) { 342 if($this->cartSession[$productTypeId][$i]['cart_no'] == $cart_no) { 343 unset($this->cartSession[$productTypeId][$i]); 335 344 } 336 345 } … … 338 347 339 348 // 数量の増加 340 function upQuantity($cart_no, $key) { 341 $this->addKey($key); 342 $max = $this->getMax(); 343 for($i = 0; $i <= $max; $i++) { 344 if($_SESSION[$key][$i]['cart_no'] == $cart_no) { 345 if(strlen($_SESSION[$key][$i]['quantity'] + 1) <= INT_LEN) { 346 $_SESSION[$key][$i]['quantity']++; 347 } 348 } 349 function upQuantity($cart_no, $productTypeId) { 350 $quantity = $this->getQuantity($cart_no, $productTypeId); 351 if (strlen($quantity + 1) <= INT_LEN) { 352 $this->setQuantity($quantity + 1, $cart_no, $productTypeId); 349 353 } 350 354 } 351 355 352 356 // 数量の減少 353 function downQuantity($cart_no, $key) { 354 $this->addKey($key); 355 $max = $this->getMax(); 356 for($i = 0; $i <= $max; $i++) { 357 if($_SESSION[$key][$i]['cart_no'] == $cart_no) { 358 if($_SESSION[$key][$i]['quantity'] > 1) { 359 $_SESSION[$key][$i]['quantity']--; 360 } 361 } 362 } 363 } 364 365 function addKey($key) { 366 if (!in_array($this->keys, $key)) { 367 $this->keys[] = $key; 368 } 357 function downQuantity($cart_no, $productTypeId) { 358 $quantity = $this->getQuantity($cart_no, $productTypeId); 359 if ($quantity > 1) { 360 $this->setQuantity($quantity - 1, $cart_no, $productTypeId); 361 } 362 } 363 364 function getQuantity($cart_no, $productTypeId) { 365 $max = $this->getMax($productTypeId); 366 for ($i = 0; $i <= $max; $i++) { 367 if ($this->cartSession[$productTypeId][$i]['cart_no'] == $cart_no) { 368 return $this->cartSession[$productTypeId][$i]['quantity']; 369 } 370 } 371 } 372 373 function setQuantity($quantity, $cart_no, $productTypeId) { 374 $max = $this->getMax($productTypeId); 375 for ($i = 0; $i <= $max; $i++) { 376 if ($this->cartSession[$productTypeId][$i]['cart_no'] == $cart_no) { 377 $this->cartSession[$productTypeId][$i]['quantity'] = $quantity; 378 } 379 } 380 } 381 382 function getProductClassId($cart_no, $productTypeId) { 383 for ($i = 0; $i <= $max; $i++) { 384 if ($this->cartSession[$productTypeId][$i]['cart_no'] == $cart_no) { 385 return $this->cartSession[$productTypeId][$i]['id']; 386 } 387 } 388 } 389 390 /** 391 * カート内の商品の妥当性をチェックする. 392 * 393 * エラーが発生した場合は, 商品をカート内から削除又は数量を調整し, 394 * エラーメッセージを返す. 395 * 396 * 1. 削除/非表示商品のチェック 397 * 2. 商品購入制限数のチェック 398 * 3. 在庫数チェック 399 * 400 * @param string $key 商品種別ID 401 * @return string エラーが発生した場合はエラーメッセージ 402 */ 403 function checkProducts($productTypeId) { 404 $objProduct = new SC_Product(); 405 $tpl_message = ""; 406 407 // カート内の情報を取得 408 $items = $this->getCartList($productTypeId); 409 foreach (array_keys($items) as $key) { 410 $item =& $items[$key]; 411 $product =& $item['productsClass']; 412 /* 413 * 表示/非表示商品のチェック 414 */ 415 if (SC_Utils_Ex::isBlank($product)) { 416 $this->delProduct($item['cart_no'], $productTypeId); 417 $tpl_message .= "※ 現時点で販売していない商品が含まれておりました。該当商品をカートから削除しました。\n"; 418 } 419 420 /* 421 * 商品購入制限数, 在庫数のチェック 422 */ 423 $limit = $objProduct->getBuyLimit($product); 424 if (!is_null($limit) && $item['quantity'] > $limit) { 425 if ($limit > 0) { 426 $this->setProductValue($item['id'], 'quantity', $limit, $productTypeId); 427 $tpl_message .= "※「" . $product['name'] . "」は販売制限(または在庫が不足)しております。一度に数量{$limit}以上の購入はできません。\n"; 428 } else { 429 $this->delProduct($item['cart_no'], $productTypeId); 430 $tpl_message .= "※「" . $product['name'] . "」は売り切れました。\n"; 431 continue; 432 } 433 } 434 } 435 return $tpl_message; 369 436 } 370 437 371 438 function getKeys() { 372 return $this->keys;439 return array_keys($this->cartSession); 373 440 } 374 441
Note: See TracChangeset
for help on using the changeset viewer.