Changeset 21957 for branches/version-2_12-dev/data/class/pages/products
- Timestamp:
- 2012/07/04 10:13:22 (11 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
r21953 r21957 149 149 switch ($this->mode) { 150 150 case 'cart': 151 $this->doCart(); 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 } 152 164 break; 153 154 165 case 'add_favorite': 155 $this->doAddFavorite($objCustomer); 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 } 156 179 break; 157 180 158 181 case 'add_favorite_sphone': 159 $this->doAddFavoriteSphone($objCustomer); 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 } 160 198 break; 161 199 … … 171 209 172 210 default: 173 $this->doDefault(); 211 // カート「戻るボタン」用に保持 212 $netURL = new Net_URL(); 213 $_SESSION['cart_referer_url'] = $netURL->getURL(); 174 214 break; 175 215 } … … 179 219 switch ($this->mode) { 180 220 case 'select': 181 $this->doMobileSelect(); 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'; 182 230 break; 183 231 184 232 case 'select2': 185 $this->doMobileSelect2(); 186 break; 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 } 187 249 188 250 case 'selectItem': 189 $this->doMobileSelectItem(); 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'; 190 280 break; 191 281 192 282 case 'cart': 193 $this->doMobileCart(); 283 // この段階でエラーが出る場合は、数量の入力エラーのはず 284 if (count($this->arrErr)) { 285 // 数量の入力を行う 286 $this->tpl_mainpage = 'products/select_item.tpl'; 287 } 194 288 break; 195 289 196 290 default: 197 $this-> doMobileDefault();291 $this->tpl_mainpage = 'products/detail.tpl'; 198 292 break; 199 293 } … … 483 577 } 484 578 } 485 486 /**487 * Add product(s) into the cart.488 *489 * @return void490 */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 $objCustomer511 * @return void512 */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 $objCustomer533 * @return void534 */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 void558 */559 function doDefault() {560 // カート「戻るボタン」用に保持561 $netURL = new Net_URL();562 $_SESSION['cart_referer_url'] = $netURL->getURL();563 }564 565 /**566 *567 * @return void568 */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 type584 */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 void609 */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 void645 */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 void657 */658 function doMobileDefault() {659 $this->tpl_mainpage = 'products/detail.tpl';660 }661 579 } -
branches/version-2_12-dev/data/class/pages/products/LC_Page_Products_List.php
r21953 r21957 135 135 136 136 case 'json': 137 $this->doJson($objProduct); 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(); 138 147 break; 139 148 140 149 default: 141 $this->doDefault($objProduct); 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(); '; 142 213 break; 143 214 } … … 445 516 return $arrProducts; 446 517 } 447 448 /**449 *450 * @param type $objProduct451 * @return void452 */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 $objProduct469 * @return void470 */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 // 規格1484 $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 }535 518 }
Note: See TracChangeset
for help on using the changeset viewer.