Changeset 21953 for branches/version-2_12-dev/data
- Timestamp:
- 2012/07/03 18:48:58 (12 years ago)
- Location:
- branches/version-2_12-dev/data/class/pages/products
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/pages/products/LC_Page_Products_Detail.php
r21900 r21953 149 149 switch ($this->mode) { 150 150 case 'cart': 151 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam, 152 $this->tpl_classcat_find1, 153 $this->tpl_classcat_find2); 154 if (count($this->arrErr) == 0) { 155 $objCartSess = new SC_CartSession_Ex(); 156 $product_class_id = $this->objFormParam->getValue('product_class_id'); 157 158 $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity')); 159 160 161 SC_Response_Ex::sendRedirect(CART_URLPATH); 162 SC_Response_Ex::actionExit(); 163 } 151 $this->doCart(); 164 152 break; 153 165 154 case 'add_favorite': 166 // ログイン中のユーザが商品をお気に入りにいれる処理 167 if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) { 168 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam); 169 if (count($this->arrErr) == 0) { 170 if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) { 171 172 $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); 173 $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this)); 174 175 SC_Response_Ex::actionExit(); 176 } 177 } 178 } 155 $this->doAddFavorite($objCustomer); 179 156 break; 180 157 181 158 case 'add_favorite_sphone': 182 // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用) 183 if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) { 184 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam); 185 if (count($this->arrErr) == 0) { 186 if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) { 187 188 $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); 189 $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this)); 190 191 print 'true'; 192 SC_Response_Ex::actionExit(); 193 } 194 } 195 print 'error'; 196 SC_Response_Ex::actionExit(); 197 } 159 $this->doAddFavoriteSphone($objCustomer); 198 160 break; 199 161 … … 209 171 210 172 default: 211 // カート「戻るボタン」用に保持 212 $netURL = new Net_URL(); 213 $_SESSION['cart_referer_url'] = $netURL->getURL(); 173 $this->doDefault(); 214 174 break; 215 175 } … … 219 179 switch ($this->mode) { 220 180 case 'select': 221 // 規格1が設定されている場合 222 if ($this->tpl_classcat_find1) { 223 // templateの変更 224 $this->tpl_mainpage = 'products/select_find1.tpl'; 225 break; 226 } 227 228 // 数量の入力を行う 229 $this->tpl_mainpage = 'products/select_item.tpl'; 181 $this->doMobileSelect(); 230 182 break; 231 183 232 184 case 'select2': 233 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2); 234 235 // 規格1が設定されていて、エラーを検出した場合 236 if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) { 237 // templateの変更 238 $this->tpl_mainpage = 'products/select_find1.tpl'; 239 break; 240 } 241 242 // 規格2が設定されている場合 243 if ($this->tpl_classcat_find2) { 244 $this->arrErr = array(); 245 246 $this->tpl_mainpage = 'products/select_find2.tpl'; 247 break; 248 } 185 $this->doMobileSelect2(); 186 break; 249 187 250 188 case 'selectItem': 251 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2); 252 253 // 規格2が設定されていて、エラーを検出した場合 254 if ($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) { 255 // templateの変更 256 $this->tpl_mainpage = 'products/select_find2.tpl'; 257 break; 258 } 259 260 $value1 = $this->objFormParam->getValue('classcategory_id1'); 261 262 // 規格2が設定されている場合. 263 if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false){ 264 $value2 = '#' . $this->objFormParam->getValue('classcategory_id2'); 265 } else { 266 $value2 = '#0'; 267 } 268 269 if (strlen($value1) === 0) { 270 $value1 = '__unselected'; 271 } 272 273 $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id']; 274 275 // この段階では、数量の入力チェックエラーを出させない。 276 unset($this->arrErr['quantity']); 277 278 // 数量の入力を行う 279 $this->tpl_mainpage = 'products/select_item.tpl'; 189 $this->doMobileSelectItem(); 280 190 break; 281 191 282 192 case 'cart': 283 // この段階でエラーが出る場合は、数量の入力エラーのはず 284 if (count($this->arrErr)) { 285 // 数量の入力を行う 286 $this->tpl_mainpage = 'products/select_item.tpl'; 287 } 193 $this->doMobileCart(); 288 194 break; 289 195 290 196 default: 291 $this-> tpl_mainpage = 'products/detail.tpl';197 $this->doMobileDefault(); 292 198 break; 293 199 } … … 577 483 } 578 484 } 485 486 /** 487 * Add product(s) into the cart. 488 * 489 * @return void 490 */ 491 function doCart() { 492 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam, 493 $this->tpl_classcat_find1, 494 $this->tpl_classcat_find2); 495 if (count($this->arrErr) == 0) { 496 $objCartSess = new SC_CartSession_Ex(); 497 $product_class_id = $this->objFormParam->getValue('product_class_id'); 498 499 $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity')); 500 501 502 SC_Response_Ex::sendRedirect(CART_URLPATH); 503 SC_Response_Ex::actionExit(); 504 } 505 } 506 507 /** 508 * Add product to authenticated user's favorites. 509 * 510 * @param type $objCustomer 511 * @return void 512 */ 513 function doAddFavorite(&$objCustomer) { 514 // ログイン中のユーザが商品をお気に入りにいれる処理 515 if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) { 516 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam); 517 if (count($this->arrErr) == 0) { 518 if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) { 519 520 $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); 521 $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this)); 522 523 SC_Response_Ex::actionExit(); 524 } 525 } 526 } 527 } 528 529 /** 530 * Add product to authenticated user's favorites. (for Smart phone) 531 * 532 * @param type $objCustomer 533 * @return void 534 */ 535 function doAddFavoriteSphone($objCustomer) { 536 // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用) 537 if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) { 538 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam); 539 if (count($this->arrErr) == 0) { 540 if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) { 541 542 $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); 543 $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this)); 544 545 print 'true'; 546 SC_Response_Ex::actionExit(); 547 } 548 } 549 print 'error'; 550 SC_Response_Ex::actionExit(); 551 } 552 } 553 554 /** 555 * 556 * 557 * @return void 558 */ 559 function doDefault() { 560 // カート「戻るボタン」用に保持 561 $netURL = new Net_URL(); 562 $_SESSION['cart_referer_url'] = $netURL->getURL(); 563 } 564 565 /** 566 * 567 * @return void 568 */ 569 function doMobileSelect() { 570 // 規格1が設定されている場合 571 if ($this->tpl_classcat_find1) { 572 // templateの変更 573 $this->tpl_mainpage = 'products/select_find1.tpl'; 574 return; 575 } 576 577 // 数量の入力を行う 578 $this->tpl_mainpage = 'products/select_item.tpl'; 579 } 580 581 /** 582 * 583 * @return type 584 */ 585 function doMobileSelect2() { 586 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2); 587 588 // 規格1が設定されていて、エラーを検出した場合 589 if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) { 590 // templateの変更 591 $this->tpl_mainpage = 'products/select_find1.tpl'; 592 return; 593 } 594 595 // 規格2が設定されている場合 596 if ($this->tpl_classcat_find2) { 597 $this->arrErr = array(); 598 599 $this->tpl_mainpage = 'products/select_find2.tpl'; 600 return; 601 } 602 603 $this->doMobileSelectItem(); 604 } 605 606 /** 607 * 608 * @return void 609 */ 610 function doMobileSelectItem() { 611 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2); 612 613 // 規格2が設定されていて、エラーを検出した場合 614 if ($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) { 615 // templateの変更 616 $this->tpl_mainpage = 'products/select_find2.tpl'; 617 break; 618 } 619 620 $value1 = $this->objFormParam->getValue('classcategory_id1'); 621 622 // 規格2が設定されている場合. 623 if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false){ 624 $value2 = '#' . $this->objFormParam->getValue('classcategory_id2'); 625 } else { 626 $value2 = '#0'; 627 } 628 629 if (strlen($value1) === 0) { 630 $value1 = '__unselected'; 631 } 632 633 $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id']; 634 635 // この段階では、数量の入力チェックエラーを出させない。 636 unset($this->arrErr['quantity']); 637 638 // 数量の入力を行う 639 $this->tpl_mainpage = 'products/select_item.tpl'; 640 } 641 642 /** 643 * 644 * @return void 645 */ 646 function doMobileCart() { 647 // この段階でエラーが出る場合は、数量の入力エラーのはず 648 if (count($this->arrErr)) { 649 // 数量の入力を行う 650 $this->tpl_mainpage = 'products/select_item.tpl'; 651 } 652 } 653 654 /** 655 * 656 * @return void 657 */ 658 function doMobileDefault() { 659 $this->tpl_mainpage = 'products/detail.tpl'; 660 } 579 661 } -
branches/version-2_12-dev/data/class/pages/products/LC_Page_Products_List.php
r21949 r21953 135 135 136 136 case 'json': 137 $this->arrProducts = $this->setStatusDataTo($this->arrProducts, $this->arrSTATUS, $this->arrSTATUS_IMAGE); 138 $this->arrProducts = $objProduct->setPriceTaxTo($this->arrProducts); 139 140 // 一覧メイン画像の指定が無い商品のための処理 141 foreach ($this->arrProducts as $key=>$val) { 142 $this->arrProducts[$key]['main_list_image'] = SC_Utils_Ex::sfNoImageMainList($val['main_list_image']); 143 } 144 145 echo SC_Utils_Ex::jsonEncode($this->arrProducts); 146 SC_Response_Ex::actionExit(); 137 $this->doJson($objProduct); 147 138 break; 148 139 149 140 default: 150 151 //商品一覧の表示処理 152 $strnavi = $this->objNavi->strnavi; 153 // 表示文字列 154 $this->tpl_strnavi = empty($strnavi) ? ' ' : $strnavi; 155 156 // 規格1クラス名 157 $this->tpl_class_name1 = $objProduct->className1; 158 159 // 規格2クラス名 160 $this->tpl_class_name2 = $objProduct->className2; 161 162 // 規格1 163 $this->arrClassCat1 = $objProduct->classCats1; 164 165 // 規格1が設定されている 166 $this->tpl_classcat_find1 = $objProduct->classCat1_find; 167 // 規格2が設定されている 168 $this->tpl_classcat_find2 = $objProduct->classCat2_find; 169 170 $this->tpl_stock_find = $objProduct->stock_find; 171 $this->tpl_product_class_id = $objProduct->product_class_id; 172 $this->tpl_product_type = $objProduct->product_type; 173 174 // 商品ステータスを取得 175 $this->productStatus = $this->arrProducts['productStatus']; 176 unset($this->arrProducts['productStatus']); 177 $this->tpl_javascript .= 'var productsClassCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories) . ';'; 178 //onloadスクリプトを設定. 在庫ありの商品のみ出力する 179 foreach ($this->arrProducts as $arrProduct) { 180 if ($arrProduct['stock_unlimited_max'] || $arrProduct['stock_max'] > 0) { 181 $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});"; 182 } 183 } 184 185 //カート処理 186 $target_product_id = intval($this->arrForm['product_id']); 187 if ($target_product_id > 0) { 188 // 商品IDの正当性チェック 189 if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id']) 190 || !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $this->arrForm['product_id'], 'del_flg = 0 AND status = 1')) { 191 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 192 } 193 194 // 入力内容のチェック 195 $arrErr = $this->lfCheckError($target_product_id, $this->arrForm, $this->tpl_classcat_find1, $this->tpl_classcat_find2); 196 if (empty($arrErr)) { 197 $this->lfAddCart($this->arrForm, $_SERVER['HTTP_REFERER']); 198 199 200 SC_Response_Ex::sendRedirect(CART_URLPATH); 201 SC_Response_Ex::actionExit(); 202 } 203 $js_fnOnLoad .= $this->lfSetSelectedData($this->arrProducts, $this->arrForm, $arrErr, $target_product_id); 204 } else { 205 // カート「戻るボタン」用に保持 206 $netURL = new Net_URL(); 207 //該当メソッドが無いため、$_SESSIONに直接セット 208 $_SESSION['cart_referer_url'] = $netURL->getURL(); 209 } 210 211 $this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}'; 212 $this->tpl_onload .= 'fnOnLoad(); '; 141 $this->doDefault($objProduct); 213 142 break; 214 143 } … … 516 445 return $arrProducts; 517 446 } 447 448 /** 449 * 450 * @param type $objProduct 451 * @return void 452 */ 453 function doJson(&$objProduct) { 454 $this->arrProducts = $this->setStatusDataTo($this->arrProducts, $this->arrSTATUS, $this->arrSTATUS_IMAGE); 455 $this->arrProducts = $objProduct->setPriceTaxTo($this->arrProducts); 456 457 // 一覧メイン画像の指定が無い商品のための処理 458 foreach ($this->arrProducts as $key=>$val) { 459 $this->arrProducts[$key]['main_list_image'] = SC_Utils_Ex::sfNoImageMainList($val['main_list_image']); 460 } 461 462 echo SC_Utils_Ex::jsonEncode($this->arrProducts); 463 SC_Response_Ex::actionExit(); 464 } 465 466 /** 467 * 468 * @param type $objProduct 469 * @return void 470 */ 471 function doDefault(&$objProduct) { 472 //商品一覧の表示処理 473 $strnavi = $this->objNavi->strnavi; 474 // 表示文字列 475 $this->tpl_strnavi = empty($strnavi) ? ' ' : $strnavi; 476 477 // 規格1クラス名 478 $this->tpl_class_name1 = $objProduct->className1; 479 480 // 規格2クラス名 481 $this->tpl_class_name2 = $objProduct->className2; 482 483 // 規格1 484 $this->arrClassCat1 = $objProduct->classCats1; 485 486 // 規格1が設定されている 487 $this->tpl_classcat_find1 = $objProduct->classCat1_find; 488 // 規格2が設定されている 489 $this->tpl_classcat_find2 = $objProduct->classCat2_find; 490 491 $this->tpl_stock_find = $objProduct->stock_find; 492 $this->tpl_product_class_id = $objProduct->product_class_id; 493 $this->tpl_product_type = $objProduct->product_type; 494 495 // 商品ステータスを取得 496 $this->productStatus = $this->arrProducts['productStatus']; 497 unset($this->arrProducts['productStatus']); 498 $this->tpl_javascript .= 'var productsClassCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories) . ';'; 499 //onloadスクリプトを設定. 在庫ありの商品のみ出力する 500 foreach ($this->arrProducts as $arrProduct) { 501 if ($arrProduct['stock_unlimited_max'] || $arrProduct['stock_max'] > 0) { 502 $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});"; 503 } 504 } 505 506 //カート処理 507 $target_product_id = intval($this->arrForm['product_id']); 508 if ($target_product_id > 0) { 509 // 商品IDの正当性チェック 510 if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id']) 511 || !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $this->arrForm['product_id'], 'del_flg = 0 AND status = 1')) { 512 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 513 } 514 515 // 入力内容のチェック 516 $arrErr = $this->lfCheckError($target_product_id, $this->arrForm, $this->tpl_classcat_find1, $this->tpl_classcat_find2); 517 if (empty($arrErr)) { 518 $this->lfAddCart($this->arrForm, $_SERVER['HTTP_REFERER']); 519 520 521 SC_Response_Ex::sendRedirect(CART_URLPATH); 522 SC_Response_Ex::actionExit(); 523 } 524 $js_fnOnLoad .= $this->lfSetSelectedData($this->arrProducts, $this->arrForm, $arrErr, $target_product_id); 525 } else { 526 // カート「戻るボタン」用に保持 527 $netURL = new Net_URL(); 528 //該当メソッドが無いため、$_SESSIONに直接セット 529 $_SESSION['cart_referer_url'] = $netURL->getURL(); 530 } 531 532 $this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}'; 533 $this->tpl_onload .= 'fnOnLoad(); '; 534 } 518 535 }
Note: See TracChangeset
for help on using the changeset viewer.