Changeset 18852 for branches/version-2_5-dev/data/class
- Timestamp:
- 2010/10/13 18:03:46 (16 years ago)
- bzr:base-revision:
- svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_5-dev:18851
- bzr:committer:
- Kentaro Ohkouchi <[email protected]>
- 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:
[email protected]- bzr:repository-uuid:
- 1e3b908f-19a9-db11-a64c-001125224ba8
- bzr:revision-id:
- [email protected]
- 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 [email protected]
data/Smarty/templates/default/list.tpl [email protected]
data/Smarty/templates/default/shopping/confirm.tpl [email protected]
data/class/SC_CartSession.php [email protected]
data/class/SC_Product.php [email protected]
data/class/helper/SC_Helper_DB.php [email protected]
data/class/pages/cart/LC_Page_Cart.php [email protected]
data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Cart.php [email protected]
data/class/pages/products/LC_Page_Products_List.php [email protected]
data/class/pages/shopping/LC_Page_Shopping_Complete.php [email protected]
data/class/pages/shopping/LC_Page_Shopping_Confirm.php [email protected]
data/class/util/SC_Utils.php [email protected]- 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
- Location:
- branches/version-2_5-dev/data/class
- Files:
-
- 9 edited
-
SC_CartSession.php (modified) (16 diffs)
-
SC_Product.php (modified) (6 diffs)
-
helper/SC_Helper_DB.php (modified) (2 diffs)
-
pages/cart/LC_Page_Cart.php (modified) (5 diffs)
-
pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Cart.php (modified) (2 diffs)
-
pages/products/LC_Page_Products_List.php (modified) (1 diff)
-
pages/shopping/LC_Page_Shopping_Complete.php (modified) (1 diff)
-
pages/shopping/LC_Page_Shopping_Confirm.php (modified) (2 diffs)
-
util/SC_Utils.php (modified) (1 diff)
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 -
branches/version-2_5-dev/data/class/SC_Product.php
r18833 r18852 188 188 $stock_find_class = ($productsClass['stock_unlimited'] || $productsClass['stock'] > 0); 189 189 190 $classCategories[$productsClass1][$productsClass2]['name'] = $productsClass[' name2'] . ($stock_find_class ? '' : ' (品切れ中)');190 $classCategories[$productsClass1][$productsClass2]['name'] = $productsClass['classcategory_name2'] . ($stock_find_class ? '' : ' (品切れ中)'); 191 191 192 192 $classCategories[$productsClass1][$productsClass2]['stock_find'] = $stock_find_class; … … 197 197 198 198 if (!in_array($classcat_id1, $classCats1)) { 199 $classCats1[$productsClass1] = $productsClass[' name1']199 $classCats1[$productsClass1] = $productsClass['classcategory_name1'] 200 200 . ($productsClass2 == 0 && !$stock_find_class ? ' (品切れ中)' : ''); 201 201 } … … 258 258 T2.classcategory_id, 259 259 T2.level, 260 T3.name ,260 T3.name AS classcategory_name, 261 261 T4.name AS class_name, 262 262 T4.class_id … … 290 290 T1.parent_class_combination_id, 291 291 T1.level, 292 T2.name ,292 T2.name AS classcategory_name, 293 293 T3.name AS class_name, 294 294 T3.class_id … … 325 325 $val['class_id' . $val['level']] = $val['class_id']; 326 326 $val['class_name' . $val['level']] = $val['class_name']; 327 $val[' name' . $val['level']] = $val['name'];327 $val['classcategory_name' . $val['level']] = $val['classcategory_name']; 328 328 $val['classcategory_id' . $val['level']] = $val['classcategory_id']; 329 329 $arrProductsClass[] = $val; … … 421 421 } 422 422 return $productsClass; 423 } 424 425 /** 426 * 商品詳細の結果から, 購入制限数を取得する. 427 * 428 * getDetailAndProductsClass() の結果から, 購入制限数を取得する. 429 * 430 * @param array $p 商品詳細の検索結果の配列 431 * @return integer 商品詳細の結果から求めた購入制限数. 432 * @see getDetailAndProductsClass() 433 */ 434 function getBuyLimit($p) { 435 $limit = null; 436 if ($p['stock_unlimited'] != '1' && is_numeric($p['sale_limit'])) { 437 $limit = min($p['sale_limit'], $p['stock']); 438 } elseif (is_numeric($p['sale_limit'])) { 439 $limit = $p['sale_limit']; 440 } elseif ($p['stock_unlimited'] != '1') { 441 $limit = $p['stock']; 442 } 443 return $limit; 423 444 } 424 445 -
branches/version-2_5-dev/data/class/helper/SC_Helper_DB.php
r18851 r18852 244 244 * @param null $dummy1 互換性確保用(決済モジュール互換のため) 245 245 * @return LC_Page 集計処理後のページクラスインスタンス 246 * @deprecated SC_CartSession クラスを使用して下さい 246 247 */ 247 248 function sfTotalCart(&$objPage, $objCartSess, $dummy1 = null, $key = "") { … … 1913 1914 * @return bool 0:実商品のみ 1:ダウンロード販売と実商品混在 2:全てダウンロード販売 1914 1915 */ 1915 function chkCartDown( $objCartSess) {1916 function chkCartDown(&$objCartSess, $cartKey = 1) { 1916 1917 $objQuery =& SC_Query::getSingletonInstance(); 1917 1918 $down = false; -
branches/version-2_5-dev/data/class/pages/cart/LC_Page_Cart.php
r18833 r18852 69 69 */ 70 70 function process() { 71 global $objCampaignSess;72 71 73 72 $objView = new SC_SiteView(false); … … 79 78 $objDb = new SC_Helper_DB_Ex(); 80 79 $objProduct = new SC_Product(); 81 // 商品購入中にカート内容が変更された。 82 if($objCartSess->getCancelPurchase()) { 83 $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。"; 80 81 $i = 0; 82 $this->cartKeys = $objCartSess->getKeys(); 83 foreach ($this->cartKeys as $key) { 84 // 商品購入中にカート内容が変更された。 85 if($objCartSess->getCancelPurchase($key)) { 86 $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。"; 87 } 88 89 // カートの商品規格を取得 90 $cartItems = $objCartSess->getCartList($key); 91 foreach (array_keys($cartItems) as $itemKey) { 92 $cartItem =& $cartItems[$itemKey]; 93 if (!SC_Utils_Ex::isBlank($cartItem)) { 94 $this->cartItems[$key][$i] =& $cartItem; 95 $i++; 96 } 97 } 84 98 } 85 99 … … 88 102 switch($_POST['mode']) { 89 103 case 'up': 90 $objCartSess->upQuantity($_POST['cart_no'] );104 $objCartSess->upQuantity($_POST['cart_no'], $_POST['cartKey']); 91 105 $this->reload(); // PRG pattern 92 106 break; 93 107 case 'down': 94 $objCartSess->downQuantity($_POST['cart_no'] );108 $objCartSess->downQuantity($_POST['cart_no'], $_POST['cartKey']); 95 109 $this->reload(); // PRG pattern 96 110 break; 97 111 case 'delete': 98 $objCartSess->delProduct($_POST['cart_no'] );112 $objCartSess->delProduct($_POST['cart_no'], $_POST['cartKey']); 99 113 $this->reload(); // PRG pattern 100 114 break; 101 115 case 'confirm': 102 116 // カート内情報の取得 103 $cartKey = $_POST['cartKey']; // TODO 104 $arrRet = $objCartSess->getCartList($cartKey); 105 $max = count($arrRet); 106 $cnt = 0; 107 for ($i = 0; $i < $max; $i++) { 108 // 商品規格情報の取得 109 $this->arrData = $objProduct->getProductsClass($arrRet[$i]['id']); 110 // DBに存在する商品 111 if($this->arrData != "") { 112 $cnt++; 113 } 114 } 117 $cartKey = $_POST['cartKey']; 118 $cartList = $objCartSess->getCartList($cartKey); 115 119 // カート商品が1件以上存在する場合 116 if( $cnt> 0) {120 if(count($cartList) > 0) { 117 121 // 正常に登録されたことを記録しておく 118 122 $objSiteSess->setRegistFlag(); … … 141 145 // 基本情報の取得 142 146 $this->arrInfo = $objSiteInfo->data; 143 144 $this->cartKeys = $objCartSess->getKeys();145 147 foreach ($this->cartKeys as $key) { 146 148 // カート集計処理 147 $objDb->sfTotalCart($this, $objCartSess, $key); 148 $this->arrData = $objDb->sfTotalConfirm($this->arrData, $this, $objCartSess, null, $objCustomer, $key); 149 $this->tpl_message = $objCartSess->checkProducts($key); 150 $this->tpl_total_pretax[$key] = $objCartSess->getAllProductsTotal($key); 151 $this->tpl_total_tax[$key] = $objCartSess->getAllProductsTax($key); 152 // ポイント合計 153 $this->tpl_total_point[$key] = $objCartSess->getAllProductsPoint($key); 154 155 $this->arrData = $objDb->sfTotalConfirm($this->cartItems[$key], $this, $objCartSess, null, $objCustomer, $key); 149 156 // 送料無料までの金額を計算 150 157 $this->tpl_deliv_free[$key] = $this->arrInfo['free_rule'] - $this->tpl_total_pretax[$key]; 151 152 153 158 } 154 159 … … 159 164 $this->tpl_name = $objCustomer->getValue('name01'); 160 165 } 161 162 166 163 167 // 前頁のURLを取得 -
branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Cart.php
r18701 r18852 58 58 $objSiteInfo = new SC_SiteInfo; 59 59 60 if (count($_SESSION[$objCart->key]) > 0){ 60 $cartKeys = $objCart->getKeys(); 61 foreach ($cartKeys as $cartKey) { 62 61 63 // カート情報を取得 62 $arrCartList = $objCart->getCartList( );64 $arrCartList = $objCart->getCartList($cartKey); 63 65 64 66 // カート内の商品ID一覧を取得 65 $arrAllProductID = $objCart->getAllProductID( );67 $arrAllProductID = $objCart->getAllProductID($cartKey); 66 68 // 商品が1つ以上入っている場合には商品名称を取得 67 if (count($arrAllProductID) > 0){ 68 $objQuery = new SC_Query(); 69 $arrVal = array(); 70 $sql = ""; 71 $sql = "SELECT name FROM dtb_products WHERE product_id IN ( ?"; 72 $arrVal = array($arrAllProductID[0]); 73 for($i = 1 ; $i < count($arrAllProductID) ; $i++){ 74 $sql.= " ,? "; 75 array_push($arrVal, $arrAllProductID[$i]); 76 } 77 $sql.= " )"; 69 if (count($arrCartList) > 0){ 78 70 79 $arrProduct_name = $objQuery->getAll($sql, $arrVal); 80 81 foreach($arrProduct_name as $key => $val){ 71 foreach($arrCartList['productsClass'] as $key => $val){ 82 72 $arrCartList[$key]['product_name'] = $val['name']; 83 73 } … … 86 76 $arrInfo = $objSiteInfo->data; 87 77 // 購入金額合計 88 $ProductsTotal = $objCart->getAllProductsTotal( );78 $ProductsTotal = $objCart->getAllProductsTotal($cartKey); 89 79 90 80 // 合計数量 91 $TotalQuantity = $objCart->getTotalQuantity( );81 $TotalQuantity = $objCart->getTotalQuantity($cartKey); 92 82 93 83 // 送料無料までの金額 -
branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_List.php
r18833 r18852 158 158 $objProduct = new SC_Product(); 159 159 $product_class_id = $this->arrForm['product_class_id']; 160 $product_type = $this->arrForm['product_type']; 160 161 $objCartSess = new SC_CartSession(); 161 $objCartSess->addProduct($product_class_id, $this->arrForm['quantity'] );162 $objCartSess->addProduct($product_class_id, $this->arrForm['quantity'], $product_type); 162 163 $this->sendRedirect($this->getLocation(URL_CART_TOP)); 163 164 exit; -
branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_Complete.php
r18851 r18852 525 525 $objDb = new SC_Helper_DB_Ex(); 526 526 // カート内情報の取得 527 $arrCart = $objCartSess->getCartList(); 527 $this->cartKey = $_SESSION['cartKey']; 528 $arrCart = $objCartSess->getCartList($this->cartKey); 528 529 $max = count($arrCart); 529 530 -
branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_Confirm.php
r18833 r18852 85 85 // カート集計処理 86 86 $this->cartKey = $_SESSION['cartKey']; 87 $objDb->sfTotalCart($this, $objCartSess, $this->cartKey); 87 $cartItems = $objCartSess->getCartList($this->cartKey); 88 $i = 0; 89 foreach (array_keys($cartItems) as $itemKey) { 90 $cartItem =& $cartItems[$itemKey]; 91 if (!SC_Utils_Ex::isBlank($cartItem)) { 92 $this->cartItems[$i] =& $cartItem; 93 $i++; 94 } 95 } 96 $this->tpl_message = $objCartSess->checkProducts($this->cartKey); 97 $this->tpl_total_pretax[$this->cartKey] = $objCartSess->getAllProductsTotal($this->cartKey); 98 $this->tpl_total_tax[$this->cartKey] = $objCartSess->getAllProductsTax($this->cartKey); 99 // ポイント合計 100 $this->tpl_total_point[$this->cartKey] = $objCartSess->getAllProductsPoint($this->cartKey); 101 88 102 if (strlen($this->tpl_message) >= 1) { 89 103 SC_Utils_Ex::sfDispSiteError(SOLD_OUT, '', true); 90 104 } 105 106 // TODO リファクタリング 91 107 // 一時受注テーブルの読込 92 $arrData = $objDb->sfGetOrderTemp($uniqid); 108 $tmpData = $objDb->sfGetOrderTemp($uniqid); 109 93 110 // カート集計を元に最終計算 94 $arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, null, $objCustomer); 111 $arrData = $objDb->sfTotalConfirm($this->cartItems, $this, $objCartSess, null, $objCustomer, $this->cartKey); 112 $arrData = array_merge($tmpData, $arrData); 95 113 // キャンペーンからの遷移で送料が無料だった場合の処理 96 114 if($objCampaignSess->getIsCampaign()) { … … 137 155 138 156 // 集計結果を受注一時テーブルに反映 157 unset($arrData[0]); // TODO 158 unset($arrData[1]); 139 159 $objDb->sfRegistTempOrder($uniqid, $arrData); 140 160 // 正常に登録されたことを記録しておく -
branches/version-2_5-dev/data/class/util/SC_Utils.php
r18820 r18852 313 313 // ユーザユニークIDの取得 314 314 $uniqid = $objSiteSess->getUniqId(); 315 // 購入ボタンを押した時のカート内容がコピーされていない場合のみコピーする。 316 $objCartSess->saveCurrentCart($uniqid); 317 // POSTのユニークIDとセッションのユニークIDを比較(ユニークIDがPOSTされていない場合はスルー) 318 $ret = $objSiteSess->checkUniqId(); 319 if($ret != true) { 320 // エラーページの表示 321 SC_Utils_Ex::sfDispSiteError(CANCEL_PURCHASE, $objSiteSess); 322 } 323 324 // カート内が空でないか || 購入ボタンを押してから変化がないか 325 $quantity = $objCartSess->getTotalQuantity(); 326 $ret = $objCartSess->checkChangeCart(); 327 if($ret == true || !($quantity > 0)) { 328 // カート情報表示に強制移動する 329 // FIXME false を返して, Page クラスで遷移させるべき... 330 if (defined("MOBILE_SITE")) { 331 header("Location: ". MOBILE_URL_CART_TOP 332 . "?" . session_name() . "=" . session_id()); 333 } else { 334 header("Location: ".URL_CART_TOP); 335 } 336 exit; 315 316 $cartkeys = $objCartSess->getKeys(); 317 318 foreach ($cartKeys as $cartKey) { 319 // 購入ボタンを押した時のカート内容がコピーされていない場合のみコピーする。 320 $objCartSess->saveCurrentCart($uniqid, $cartKey); 321 // POSTのユニークIDとセッションのユニークIDを比較(ユニークIDがPOSTされていない場合はスルー) 322 $ret = $objSiteSess->checkUniqId(); 323 if($ret != true) { 324 // エラーページの表示 325 SC_Utils_Ex::sfDispSiteError(CANCEL_PURCHASE, $objSiteSess); 326 } 327 328 // カート内が空でないか || 購入ボタンを押してから変化がないか 329 $quantity = $objCartSess->getTotalQuantity($cartKey); 330 $ret = $objCartSess->checkChangeCart($cartKey); 331 if($ret == true || !($quantity > 0)) { 332 // カート情報表示に強制移動する 333 // FIXME false を返して, Page クラスで遷移させるべき... 334 if (defined("MOBILE_SITE")) { 335 header("Location: ". MOBILE_URL_CART_TOP 336 . "?" . session_name() . "=" . session_id()); 337 } else { 338 header("Location: ".URL_CART_TOP); 339 } 340 exit; 341 } 337 342 } 338 343 return $uniqid;
Note: See TracChangeset
for help on using the changeset viewer.
