source: branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Detail.php @ 22960

Revision 22960, 24.7 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 語句統一「全て」
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26if (file_exists(MODULE_REALDIR . 'mdl_gmopg/inc/function.php')) {
27    require_once MODULE_REALDIR . 'mdl_gmopg/inc/function.php';
28}
29/**
30 * 商品詳細 のページクラス.
31 *
32 * @package Page
33 * @author LOCKON CO.,LTD.
34 * @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $
35 */
36class LC_Page_Products_Detail extends LC_Page_Ex
37{
38    /** 商品ステータス */
39    var $arrSTATUS;
40
41    /** 商品ステータス画像 */
42    var $arrSTATUS_IMAGE;
43
44    /** 発送予定日 */
45    var $arrDELIVERYDATE;
46
47    /** おすすめレベル */
48    var $arrRECOMMEND;
49
50    /** フォームパラメーター */
51    var $objFormParam;
52
53    /** アップロードファイル */
54    var $objUpFile;
55
56    /** モード */
57    var $mode;
58
59    /**
60     * Page を初期化する.
61     *
62     * @return void
63     */
64    function init()
65    {
66        parent::init();
67        $masterData = new SC_DB_MasterData_Ex();
68        $this->arrSTATUS = $masterData->getMasterData('mtb_status');
69        $this->arrSTATUS_IMAGE = $masterData->getMasterData('mtb_status_image');
70        $this->arrDELIVERYDATE = $masterData->getMasterData('mtb_delivery_date');
71        $this->arrRECOMMEND = $masterData->getMasterData('mtb_recommend');
72
73        // POST に限定する mode
74        $this->arrLimitPostMode[] = 'cart';
75        $this->arrLimitPostMode[] = 'add_favorite';
76        $this->arrLimitPostMode[] = 'add_favorite_sphone';
77        $this->arrLimitPostMode[] = 'select';
78        $this->arrLimitPostMode[] = 'select2';
79        $this->arrLimitPostMode[] = 'selectItem';
80    }
81
82    /**
83     * Page のプロセス.
84     *
85     * @return void
86     */
87    function process()
88    {
89        parent::process();
90        $this->action();
91        $this->sendResponse();
92    }
93
94    /**
95     * Page のAction.
96     *
97     * @return void
98     */
99    function action()
100    {
101        // 会員クラス
102        $objCustomer = new SC_Customer_Ex();
103
104        // パラメーター管理クラス
105        $this->objFormParam = new SC_FormParam_Ex();
106        // パラメーター情報の初期化
107        $this->arrForm = $this->lfInitParam($this->objFormParam);
108        // ファイル管理クラス
109        $this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
110        // ファイル情報の初期化
111        $this->objUpFile = $this->lfInitFile($this->objUpFile);
112
113        // プロダクトIDの正当性チェック
114        $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'), $this->objFormParam->getValue('product_id'));
115        $this->mode = $this->getMode();
116
117        $objProduct = new SC_Product_Ex();
118        $objProduct->setProductsClassByProductIds(array($product_id));
119
120        // 規格1クラス名
121        $this->tpl_class_name1 = $objProduct->className1[$product_id];
122
123        // 規格2クラス名
124        $this->tpl_class_name2 = $objProduct->className2[$product_id];
125
126        // 規格1
127        $this->arrClassCat1 = $objProduct->classCats1[$product_id];
128
129        // 規格1が設定されている
130        $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id];
131        // 規格2が設定されている
132        $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id];
133
134        $this->tpl_stock_find = $objProduct->stock_find[$product_id];
135        $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_class_id'];
136        $this->tpl_product_type = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_type'];
137
138        // 在庫が無い場合は、OnLoadしない。(javascriptエラー防止)
139        if ($this->tpl_stock_find) {
140            // 規格選択セレクトボックスの作成
141            $this->js_lnOnload .= $this->lfMakeSelect();
142        }
143
144        $this->tpl_javascript .= 'classCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories[$product_id]) . ';';
145        $this->tpl_javascript .= 'function lnOnLoad()
146        {' . $this->js_lnOnload . '}';
147        $this->tpl_onload .= 'lnOnLoad();';
148
149        // モバイル用 規格選択セレクトボックスの作成
150        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
151            $this->lfMakeSelectMobile($this, $product_id, $this->objFormParam->getValue('classcategory_id1'));
152        }
153
154        // 商品IDをFORM内に保持する
155        $this->tpl_product_id = $product_id;
156
157        switch ($this->mode) {
158            case 'cart':
159                $this->doCart();
160                break;
161
162            case 'add_favorite':
163                $this->doAddFavorite($objCustomer);
164                break;
165
166            case 'add_favorite_sphone':
167                $this->doAddFavoriteSphone($objCustomer);
168                break;
169
170            case 'select':
171            case 'select2':
172            case 'selectItem':
173                /**
174                 * モバイルの数量指定・規格選択の際に、
175                 * $_SESSION['cart_referer_url'] を上書きさせないために、
176                 * 何もせずbreakする。
177                 */
178                break;
179
180            default:
181                $this->doDefault();
182                break;
183        }
184
185        // モバイル用 ポストバック処理
186        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
187            switch ($this->mode) {
188                case 'select':
189                    $this->doMobileSelect();
190                    break;
191
192                case 'select2':
193                    $this->doMobileSelect2();
194                    break;
195
196                case 'selectItem':
197                    $this->doMobileSelectItem();
198                    break;
199
200                case 'cart':
201                    $this->doMobileCart();
202                    break;
203
204                default:
205                    $this->doMobileDefault();
206                    break;
207            }
208        }
209
210        // 商品詳細を取得
211        $this->arrProduct = $objProduct->getDetail($product_id);
212
213        // サブタイトルを取得
214        $this->tpl_subtitle = $this->arrProduct['name'];
215
216        // 関連カテゴリを取得
217        $this->arrRelativeCat = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id);
218
219        // 商品ステータスを取得
220        $this->productStatus = $objProduct->getProductStatus($product_id);
221
222        // 画像ファイル指定がない場合の置換処理
223        $this->arrProduct['main_image']
224            = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']);
225
226        $this->subImageFlag = $this->lfSetFile($this->objUpFile, $this->arrProduct, $this->arrFile);
227        //レビュー情報の取得
228        $this->arrReview = $this->lfGetReviewData($product_id);
229
230        //関連商品情報表示
231        $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id);
232
233        // ログイン判定
234        if ($objCustomer->isLoginSuccess() === true) {
235            //お気に入りボタン表示
236            $this->tpl_login = true;
237            $this->is_favorite = SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($objCustomer->getValue('customer_id'), $product_id));
238        }
239    }
240
241    /* プロダクトIDの正当性チェック */
242    function lfCheckProductId($admin_mode, $product_id)
243    {
244        // 管理機能からの確認の場合は、非公開の商品も表示する。
245        if (isset($admin_mode) && $admin_mode == 'on') {
246            SC_Utils_Ex::sfIsSuccess(new SC_Session_Ex());
247            $status = true;
248            $where = 'del_flg = 0';
249        } else {
250            $status = false;
251            $where = 'del_flg = 0 AND status = 1';
252        }
253
254        if (!SC_Utils_Ex::sfIsInt($product_id)
255            || SC_Utils_Ex::sfIsZeroFilling($product_id)
256            || !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', (array)$product_id, $where)
257        ) {
258                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
259        }
260
261        return $product_id;
262    }
263
264    /* ファイル情報の初期化 */
265    function lfInitFile($objUpFile)
266    {
267        $objUpFile->addFile('詳細-メイン画像', 'main_image', array('jpg'), IMAGE_SIZE);
268        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
269            $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE);
270        }
271
272        return $objUpFile;
273    }
274
275    /* 規格選択セレクトボックスの作成 */
276    function lfMakeSelect()
277    {
278        return 'fnSetClassCategories('
279            . 'document.form1, '
280            . SC_Utils_Ex::jsonEncode($this->objFormParam->getValue('classcategory_id2'))
281            . '); ';
282    }
283
284    /* 規格選択セレクトボックスの作成(モバイル) */
285    function lfMakeSelectMobile(&$objPage, $product_id, $request_classcategory_id1)
286    {
287        $classcat_find1 = false;
288        $classcat_find2 = false;
289
290        // 規格名一覧
291        $arrClassName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_class', 'class_id', 'name');
292        // 規格分類名一覧
293        $arrClassCatName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_classcategory', 'classcategory_id', 'name');
294        // 商品規格情報の取得
295        $arrProductsClass = $this->lfGetProductsClass($product_id);
296
297        // 規格1クラス名の取得
298        $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
299        // 規格2クラス名の取得
300        $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
301
302        // 全ての組み合わせ数
303        $count = count($arrProductsClass);
304
305        $classcat_id1 = '';
306
307        $arrSele1 = array();
308        $arrSele2 = array();
309
310        for ($i = 0; $i < $count; $i++) {
311            // 在庫のチェック
312            if ($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
313                continue;
314            }
315
316            // 規格1のセレクトボックス用
317            if ($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']) {
318                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
319                $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1];
320            }
321
322            // 規格2のセレクトボックス用
323            if ($arrProductsClass[$i]['classcategory_id1'] == $request_classcategory_id1 and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) {
324                $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
325                $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2];
326            }
327        }
328
329        // 規格1
330        $objPage->arrClassCat1 = $arrSele1;
331        $objPage->arrClassCat2 = $arrSele2;
332
333        // 規格1が設定されている
334        if (isset($arrProductsClass[0]['classcategory_id1']) && $arrProductsClass[0]['classcategory_id1'] != '0') {
335            $classcat_find1 = true;
336        }
337
338        // 規格2が設定されている
339        if (isset($arrProductsClass[0]['classcategory_id2']) && $arrProductsClass[0]['classcategory_id2'] != '0') {
340            $classcat_find2 = true;
341        }
342
343        $objPage->tpl_classcat_find1 = $classcat_find1;
344        $objPage->tpl_classcat_find2 = $classcat_find2;
345    }
346
347    /* パラメーター情報の初期化 */
348    function lfInitParam(&$objFormParam)
349    {
350        $objFormParam->addParam('規格1', 'classcategory_id1', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
351        $objFormParam->addParam('規格2', 'classcategory_id2', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
352        $objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
353        $objFormParam->addParam('管理者ログイン', 'admin', INT_LEN, 'a', array('ALNUM_CHECK','MAX_LENGTH_CHECK'));
354        $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
355        $objFormParam->addParam('お気に入り商品ID', 'favorite_product_id', INT_LEN, 'n', array('ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
356        $objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
357        // 値の取得
358        $objFormParam->setParam($_REQUEST);
359        // 入力値の変換
360        $objFormParam->convParam();
361        // 入力情報を渡す
362        return $objFormParam->getFormParamList();
363    }
364
365    /* 商品規格情報の取得 */
366    function lfGetProductsClass($product_id)
367    {
368        $objProduct = new SC_Product_Ex();
369
370        return $objProduct->getProductsClassFullByProductId($product_id);
371    }
372
373    /* 登録済み関連商品の読み込み */
374    function lfPreGetRecommendProducts($product_id)
375    {
376        $objProduct = new SC_Product_Ex();
377        $objQuery =& SC_Query_Ex::getSingletonInstance();
378
379        $objQuery->setOrder('rank DESC');
380        $arrRecommendData = $objQuery->select('recommend_product_id, comment', 'dtb_recommend_products as t1 left join dtb_products as t2 on t1.recommend_product_id = t2.product_id', 't1.product_id = ? and t2.del_flg = 0 and t2.status = 1', array($product_id));
381
382        $recommendProductIds = array();
383        foreach ($arrRecommendData as $recommend) {
384            $recommendProductIds[] = $recommend['recommend_product_id'];
385        }
386
387        $objQuery =& SC_Query_Ex::getSingletonInstance();
388        $arrProducts = $objProduct->getListByProductIds($objQuery, $recommendProductIds);
389
390        foreach ($arrRecommendData as $key => $arrRow) {
391            $arrRecommendData[$key] = array_merge($arrRow, $arrProducts[$arrRow['recommend_product_id']]);
392        }
393
394        return $arrRecommendData;
395    }
396
397    /* 入力内容のチェック */
398    function lfCheckError($mode, &$objFormParam, $tpl_classcat_find1 = null , $tpl_classcat_find2 = null)
399    {
400        switch ($mode) {
401        case 'add_favorite_sphone':
402        case 'add_favorite':
403            $objCustomer = new SC_Customer_Ex();
404            $objErr = new SC_CheckError_Ex();
405            $customer_id = $objCustomer->getValue('customer_id');
406            if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) {
407                $objErr->arrErr['add_favorite'.$favorite_product_id] = '※ この商品は既にお気に入りに追加されています。<br />';
408            }
409            break;
410        default:
411            // 入力データを渡す。
412            $arrRet =  $objFormParam->getHashArray();
413            $objErr = new SC_CheckError_Ex($arrRet);
414            $objErr->arrErr = $objFormParam->checkError();
415
416            // 複数項目チェック
417            if ($tpl_classcat_find1) {
418                $objErr->doFunc(array('規格1', 'classcategory_id1'), array('EXIST_CHECK'));
419            }
420            if ($tpl_classcat_find2) {
421                $objErr->doFunc(array('規格2', 'classcategory_id2'), array('EXIST_CHECK'));
422            }
423            break;
424        }
425
426        return $objErr->arrErr;
427    }
428
429    //商品ごとのレビュー情報を取得する
430    function lfGetReviewData($product_id)
431    {
432        $objQuery =& SC_Query_Ex::getSingletonInstance();
433        //商品ごとのレビュー情報を取得する
434        $col = 'create_date, reviewer_url, reviewer_name, recommend_level, title, comment';
435        $from = 'dtb_review';
436        $where = 'del_flg = 0 AND status = 1 AND product_id = ?';
437        $objQuery->setOrder('create_date DESC');
438        $objQuery->setLimit(REVIEW_REGIST_MAX);
439        $arrWhereVal = array($product_id);
440        $arrReview = $objQuery->select($col, $from, $where, $arrWhereVal);
441
442        return $arrReview;
443    }
444
445    /*
446     * ファイルの情報をセットする
447     * @return $subImageFlag
448     */
449    function lfSetFile($objUpFile, $arrProduct, &$arrFile)
450    {
451        // DBからのデータを引き継ぐ
452        $objUpFile->setDBFileList($arrProduct);
453        // ファイル表示用配列を渡す
454        $arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true);
455
456        // サブ画像の有無を判定
457        $subImageFlag = false;
458        for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) {
459            if ($arrFile['sub_image' . $i]['filepath'] != '') {
460                $subImageFlag = true;
461            }
462        }
463
464        return $subImageFlag;
465    }
466
467    /*
468     * お気に入り商品登録
469     * @return void
470     */
471    function lfRegistFavoriteProduct($favorite_product_id, $customer_id)
472    {
473        // ログイン中のユーザが商品をお気に入りにいれる処理
474        if (!SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $favorite_product_id, 'del_flg = 0 AND status = 1')) {
475            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
476            return false;
477        } else {
478            $objQuery =& SC_Query_Ex::getSingletonInstance();
479            $exists = $objQuery->exists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id));
480
481            if (!$exists) {
482                $sqlval['customer_id'] = $customer_id;
483                $sqlval['product_id'] = $favorite_product_id;
484                $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
485                $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
486
487                $objQuery->begin();
488                $objQuery->insert('dtb_customer_favorite_products', $sqlval);
489                $objQuery->commit();
490            }
491            // お気に入りに登録したことを示すフラグ
492            $this->just_added_favorite = true;
493            return true;
494        }
495    }
496
497    /**
498     * Add product(s) into the cart.
499     *
500     * @return void
501     */
502    function doCart()
503    {
504        $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,
505                                            $this->tpl_classcat_find1,
506                                            $this->tpl_classcat_find2);
507        if (count($this->arrErr) == 0) {
508            $objCartSess = new SC_CartSession_Ex();
509            $product_class_id = $this->objFormParam->getValue('product_class_id');
510
511            $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'));
512
513            // 開いているカテゴリーツリーを維持するためのパラメーター
514            $arrQueryString = array(
515                'product_id' => $this->objFormParam->getValue('product_id'),
516            );
517
518            SC_Response_Ex::sendRedirect(CART_URLPATH, $arrQueryString);
519            SC_Response_Ex::actionExit();
520        }
521    }
522
523    /**
524     * Add product to authenticated user's favorites.
525     *
526     * @param type $objCustomer
527     * @return void
528     */
529    function doAddFavorite(&$objCustomer)
530    {
531        // ログイン中のユーザが商品をお気に入りにいれる処理
532        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
533            $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam);
534            if (count($this->arrErr) == 0) {
535                if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) {
536                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
537                    $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this));
538
539                    SC_Response_Ex::actionExit();
540                }
541            }
542        }
543    }
544
545    /**
546     * Add product to authenticated user's favorites. (for Smart phone)
547     *
548     * @param type $objCustomer
549     * @return void
550     */
551    function doAddFavoriteSphone($objCustomer)
552    {
553        // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用)
554        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
555            $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam);
556            if (count($this->arrErr) == 0) {
557                if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) {
558                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
559                    $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this));
560
561                    print 'true';
562                    SC_Response_Ex::actionExit();
563                }
564            }
565            print 'error';
566            SC_Response_Ex::actionExit();
567        }
568    }
569
570    /**
571     *
572     *
573     * @return void
574     */
575    function doDefault()
576    {
577        // カート「戻るボタン」用に保持
578        $netURL = new Net_URL();
579        $_SESSION['cart_referer_url'] = $netURL->getURL();
580    }
581
582    /**
583     *
584     * @return void
585     */
586    function doMobileSelect()
587    {
588        // 規格1が設定されている場合
589        if ($this->tpl_classcat_find1) {
590            // templateの変更
591            $this->tpl_mainpage = 'products/select_find1.tpl';
592            return;
593        }
594
595        // 数量の入力を行う
596        $this->tpl_mainpage = 'products/select_item.tpl';
597    }
598
599    /**
600     *
601     * @return type
602     */
603    function doMobileSelect2()
604    {
605        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
606
607        // 規格1が設定されていて、エラーを検出した場合
608        if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
609            // templateの変更
610            $this->tpl_mainpage = 'products/select_find1.tpl';
611            return;
612        }
613
614        // 規格2が設定されている場合
615        if ($this->tpl_classcat_find2) {
616            $this->arrErr = array();
617
618            $this->tpl_mainpage = 'products/select_find2.tpl';
619            return;
620        }
621
622        $this->doMobileSelectItem();
623    }
624
625    /**
626     *
627     * @return void
628     */
629    function doMobileSelectItem()
630    {
631        $objProduct = new SC_Product_Ex();
632
633        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
634
635        // この段階では、商品規格ID・数量の入力チェックエラーを出させない。
636        // FIXME: エラーチェックの定義で mode で定義を分岐する方が良いように感じる
637        unset($this->arrErr['product_class_id']);
638        unset($this->arrErr['quantity']);
639
640        // 規格2が設定されていて、エラーを検出した場合
641        if ($this->tpl_classcat_find2 and !empty($this->arrErr)) {
642            // templateの変更
643            $this->tpl_mainpage = 'products/select_find2.tpl';
644            return;
645        }
646
647        $product_id = $this->objFormParam->getValue('product_id');
648
649        $value1 = $this->objFormParam->getValue('classcategory_id1');
650        if (strlen($value1) === 0) {
651            $value1 = '__unselected';
652        }
653
654        // 規格2が設定されている場合.
655        if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false){
656            $value2 = '#' . $this->objFormParam->getValue('classcategory_id2');
657        } else {
658            $value2 = '#0';
659        }
660
661        $objProduct->setProductsClassByProductIds(array($product_id));
662        $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id'];
663
664        // 数量の入力を行う
665        $this->tpl_mainpage = 'products/select_item.tpl';
666    }
667
668    /**
669     *
670     * @return void
671     */
672    function doMobileCart()
673    {
674        // この段階でエラーが出る場合は、数量の入力エラーのはず
675        if (count($this->arrErr)) {
676            // 数量の入力を行う
677            $this->tpl_mainpage = 'products/select_item.tpl';
678        }
679    }
680
681    /**
682     *
683     * @return void
684     */
685    function doMobileDefault()
686    {
687        $this->tpl_mainpage = 'products/detail.tpl';
688    }
689}
Note: See TracBrowser for help on using the repository browser.