source: branches/version-2_13_3/data/class/pages/products/LC_Page_Products_Detail.php @ 23654

Revision 23654, 27.6 KB checked in by kim, 10 years ago (diff)

#2560 r23461 r23464 をリバート

既存関数の削除が多く、2.13.3では採用を見送ります。
下位互換が担保された場合、2.13.4で採用を検討します。

  • 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-2014 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    public $arrSTATUS;
40
41    /** 商品ステータス画像 */
42    public $arrSTATUS_IMAGE;
43
44    /** 発送予定日 */
45    public $arrDELIVERYDATE;
46
47    /** おすすめレベル */
48    public $arrRECOMMEND;
49
50    /** @var SC_FormParam フォームパラメーター */
51    public $objFormParam;
52
53    /** @var SC_UploadFile アップロードファイル */
54    public $objUpFile;
55
56    /** @var string モード */
57    public $mode;
58
59    /** @var array 商品情報 */
60    public $arrProduct;
61
62    /** @var string 規格1クラス名 */
63    public $tpl_class_name1;
64
65    /** @var string 規格2クラス名 */
66    public $tpl_class_name2;
67
68    /** @var bool 在庫があるかどうか */
69    public $tpl_stock_find;
70
71    /** @var array 規格1の規格分類 */
72    public $arrClassCat1;
73
74    /** @var bool 規格1が設定されている */
75    public $tpl_classcat_find1;
76
77    /** @var bool 規格2が設定されている */
78    public $tpl_classcat_find2;
79
80    /** @var int デフォルトの商品規格ID */
81    public $tpl_product_class_id;
82
83    /** @var int デフォルトの商品タイプ */
84    public $tpl_product_type;
85
86    /** @var string ページ表示時に実行するJavaScript */
87    public $js_lnOnload;
88
89    /** @var int 商品ID */
90    public $tpl_product_id;
91
92    /** @var array フォーム情報 */
93    public $arrForm;
94
95    /** @var string サブタイトル */
96    public $tpl_subtitle;
97
98    /** @var array 関連カテゴリー */
99    public $arrRelativeCat;
100
101    /** @var array 商品ステータス(アイコン) */
102    public $productStatus;
103
104    /** @var bool サブ画像が存在するか */
105    public $subImageFlag;
106
107    /** @var array レビュー情報 */
108    public $arrReview;
109
110    /** @var array 関連商品情報 */
111    public $arrRecommend;
112
113    /** @var array ファイル情報 */
114    public $arrFile;
115
116    /** @var bool ログイン状態かどうか */
117    public $tpl_login;
118
119    /** @var bool お気に入りに登録済みか */
120    public $is_favorite;
121
122    /** @var bool お気に入りに登録したことを示すフラグ */
123    public $just_added_favorite;
124
125    /** @var array エラー情報 */
126    public $arrErr;
127
128    /**
129     * Page を初期化する.
130     *
131     * @return void
132     */
133    public function init()
134    {
135        parent::init();
136        $masterData = new SC_DB_MasterData_Ex();
137        $this->arrSTATUS = $masterData->getMasterData('mtb_status');
138        $this->arrSTATUS_IMAGE = $masterData->getMasterData('mtb_status_image');
139        $this->arrDELIVERYDATE = $masterData->getMasterData('mtb_delivery_date');
140        $this->arrRECOMMEND = $masterData->getMasterData('mtb_recommend');
141
142        // POST に限定する mode
143        $this->arrLimitPostMode[] = 'cart';
144        $this->arrLimitPostMode[] = 'add_favorite';
145        $this->arrLimitPostMode[] = 'add_favorite_sphone';
146        $this->arrLimitPostMode[] = 'select';
147        $this->arrLimitPostMode[] = 'select2';
148        $this->arrLimitPostMode[] = 'selectItem';
149    }
150
151    /**
152     * Page のプロセス.
153     *
154     * @return void
155     */
156    public function process()
157    {
158        parent::process();
159        $this->action();
160        $this->sendResponse();
161    }
162
163    /**
164     * Page のAction.
165     *
166     * @return void
167     */
168    public function action()
169    {
170        //決済処理中ステータスのロールバック
171        $objPurchase = new SC_Helper_Purchase_Ex();
172        $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG);
173
174        // 会員クラス
175        $objCustomer = new SC_Customer_Ex();
176
177        // パラメーター管理クラス
178        $this->objFormParam = new SC_FormParam_Ex();
179        // パラメーター情報の初期化
180        $this->arrForm = $this->lfInitParam($this->objFormParam);
181        // ファイル管理クラス
182        $this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
183        // ファイル情報の初期化
184        $this->objUpFile = $this->lfInitFile($this->objUpFile);
185        $this->mode = $this->getMode();
186
187        $objProduct = new SC_Product_Ex();
188
189        // プロダクトIDの正当性チェック
190        $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'), $this->objFormParam->getValue('product_id'), $objProduct);
191
192        $objProduct->setProductsClassByProductIds(array($product_id));
193
194        // 規格1クラス名
195        $this->tpl_class_name1 = $objProduct->className1[$product_id];
196
197        // 規格2クラス名
198        $this->tpl_class_name2 = $objProduct->className2[$product_id];
199
200        // 規格1
201        $this->arrClassCat1 = $objProduct->classCats1[$product_id];
202
203        // 規格1が設定されている
204        $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id];
205        // 規格2が設定されている
206        $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id];
207
208        $this->tpl_stock_find = $objProduct->stock_find[$product_id];
209        $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_class_id'];
210        $this->tpl_product_type = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_type'];
211
212        // 在庫が無い場合は、OnLoadしない。(javascriptエラー防止)
213        if ($this->tpl_stock_find) {
214            // 規格選択セレクトボックスの作成
215            $this->js_lnOnload .= $this->lfMakeSelect();
216        }
217
218        $this->tpl_javascript .= 'eccube.classCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories[$product_id]) . ';';
219        $this->tpl_javascript .= 'function lnOnLoad()
220        {' . $this->js_lnOnload . '}';
221        $this->tpl_onload .= 'lnOnLoad();';
222
223        // モバイル用 規格選択セレクトボックスの作成
224        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
225            $this->lfMakeSelectMobile($this, $product_id, $this->objFormParam->getValue('classcategory_id1'));
226        }
227
228        // 商品IDをFORM内に保持する
229        $this->tpl_product_id = $product_id;
230
231        switch ($this->mode) {
232            case 'cart':
233                $this->doCart();
234                break;
235
236            case 'add_favorite':
237                $this->doAddFavorite($objCustomer);
238                break;
239
240            case 'add_favorite_sphone':
241                $this->doAddFavoriteSphone($objCustomer);
242                break;
243
244            case 'select':
245            case 'select2':
246            case 'selectItem':
247                /**
248                 * モバイルの数量指定・規格選択の際に、
249                 * $_SESSION['cart_referer_url'] を上書きさせないために、
250                 * 何もせずbreakする。
251                 */
252                break;
253
254            default:
255                $this->doDefault();
256                break;
257        }
258
259        // モバイル用 ポストバック処理
260        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
261            switch ($this->mode) {
262                case 'select':
263                    $this->doMobileSelect();
264                    break;
265
266                case 'select2':
267                    $this->doMobileSelect2();
268                    break;
269
270                case 'selectItem':
271                    $this->doMobileSelectItem();
272                    break;
273
274                case 'cart':
275                    $this->doMobileCart();
276                    break;
277
278                default:
279                    $this->doMobileDefault();
280                    break;
281            }
282        }
283
284        // 商品詳細を取得
285        $this->arrProduct = $objProduct->getDetail($product_id);
286
287        // サブタイトルを取得
288        $this->tpl_subtitle = $this->arrProduct['name'];
289
290        // 関連カテゴリを取得
291        $this->arrRelativeCat = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id);
292
293        // 商品ステータスを取得
294        $this->productStatus = $objProduct->getProductStatus($product_id);
295
296        // 画像ファイル指定がない場合の置換処理
297        $this->arrProduct['main_image']
298            = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']);
299
300        $this->subImageFlag = $this->lfSetFile($this->objUpFile, $this->arrProduct, $this->arrFile);
301        //レビュー情報の取得
302        $this->arrReview = $this->lfGetReviewData($product_id);
303
304        //関連商品情報表示
305        $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id);
306
307        // ログイン判定
308        if ($objCustomer->isLoginSuccess() === true) {
309            //お気に入りボタン表示
310            $this->tpl_login = true;
311            $this->is_favorite = SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($objCustomer->getValue('customer_id'), $product_id));
312        }
313    }
314
315    /**
316     * プロダクトIDの正当性チェック
317     *
318     * @param string $admin_mode
319     * @param int $product_id
320     * @param SC_Product $objProduct
321     * @return integer
322     */
323    public function lfCheckProductId($admin_mode, $product_id, SC_Product $objProduct)
324    {
325        // 管理機能からの確認の場合は、非公開の商品も表示する。
326        if (isset($admin_mode) && $admin_mode == 'on' && SC_Utils_Ex::sfIsSuccess(new SC_Session_Ex(), false)) {
327            $include_hidden = true;
328        } else {
329            $include_hidden = false;
330        }
331
332        if (!$objProduct->isValidProductId($product_id, $include_hidden)) {
333                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
334        }
335
336        return $product_id;
337    }
338
339    /**
340     * ファイル情報の初期化
341     *
342     * @param SC_UploadFile $objUpFile
343     * @return SC_UploadFile
344     */
345    public function lfInitFile(SC_UploadFile $objUpFile)
346    {
347        $objUpFile->addFile('詳細-メイン画像', 'main_image', array('jpg'), IMAGE_SIZE);
348        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
349            $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE);
350        }
351
352        return $objUpFile;
353    }
354
355    /* 規格選択セレクトボックスの作成 */
356    public function lfMakeSelect()
357    {
358        return 'fnSetClassCategories('
359            . 'document.form1, '
360            . SC_Utils_Ex::jsonEncode($this->objFormParam->getValue('classcategory_id2'))
361            . '); ';
362    }
363
364    /* 規格選択セレクトボックスの作成(モバイル) */
365
366    /**
367     * @param LC_Page_Products_Detail $objPage
368     * @param integer $product_id
369     */
370    public function lfMakeSelectMobile(&$objPage, $product_id, $request_classcategory_id1)
371    {
372        $classcat_find1 = false;
373        $classcat_find2 = false;
374
375        // 規格名一覧
376        $arrClassName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_class', 'class_id', 'name');
377        // 規格分類名一覧
378        $arrClassCatName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_classcategory', 'classcategory_id', 'name');
379        // 商品規格情報の取得
380        $arrProductsClass = $this->lfGetProductsClass($product_id);
381
382        // 規格1クラス名の取得
383        $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
384        // 規格2クラス名の取得
385        $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
386
387        // 全ての組み合わせ数
388        $count = count($arrProductsClass);
389
390        $classcat_id1 = '';
391        $classcat_id2 = '';
392
393        $arrSele1 = array();
394        $arrSele2 = array();
395
396        for ($i = 0; $i < $count; $i++) {
397            // 在庫のチェック
398            if ($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
399                continue;
400            }
401
402            // 規格1のセレクトボックス用
403            if ($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']) {
404                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
405                $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1];
406            }
407
408            // 規格2のセレクトボックス用
409            if ($arrProductsClass[$i]['classcategory_id1'] == $request_classcategory_id1 and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) {
410                $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
411                $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2];
412            }
413        }
414
415        // 規格1
416        $objPage->arrClassCat1 = $arrSele1;
417        $objPage->arrClassCat2 = $arrSele2;
418
419        // 規格1が設定されている
420        if (isset($arrProductsClass[0]['classcategory_id1']) && $arrProductsClass[0]['classcategory_id1'] != '0') {
421            $classcat_find1 = true;
422        }
423
424        // 規格2が設定されている
425        if (isset($arrProductsClass[0]['classcategory_id2']) && $arrProductsClass[0]['classcategory_id2'] != '0') {
426            $classcat_find2 = true;
427        }
428
429        $objPage->tpl_classcat_find1 = $classcat_find1;
430        $objPage->tpl_classcat_find2 = $classcat_find2;
431    }
432
433    /**
434     * パラメーター情報の初期化
435     *
436     * @param SC_FormParam $objFormParam
437     * @return array
438     */
439    public function lfInitParam(SC_FormParam &$objFormParam)
440    {
441        $objFormParam->addParam('規格1', 'classcategory_id1', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
442        $objFormParam->addParam('規格2', 'classcategory_id2', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
443        $objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
444        $objFormParam->addParam('管理者ログイン', 'admin', INT_LEN, 'a', array('ALNUM_CHECK', 'MAX_LENGTH_CHECK'));
445        $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
446        $objFormParam->addParam('お気に入り商品ID', 'favorite_product_id', INT_LEN, 'n', array('ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
447        $objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
448        // 値の取得
449        $objFormParam->setParam($_REQUEST);
450        // 入力値の変換
451        $objFormParam->convParam();
452        // 入力情報を渡す
453        return $objFormParam->getFormParamList();
454    }
455
456    /* 商品規格情報の取得 */
457
458    /**
459     * @param integer $product_id
460     */
461    public function lfGetProductsClass($product_id)
462    {
463        $objProduct = new SC_Product_Ex();
464
465        return $objProduct->getProductsClassFullByProductId($product_id);
466    }
467
468    /* 登録済み関連商品の読み込み */
469
470    /**
471     * @param integer $product_id
472     */
473    public function lfPreGetRecommendProducts($product_id)
474    {
475        $objProduct = new SC_Product_Ex();
476        $objQuery =& SC_Query_Ex::getSingletonInstance();
477
478        $objQuery->setOrder('rank DESC');
479        $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));
480
481        $recommendProductIds = array();
482        foreach ($arrRecommendData as $recommend) {
483            $recommendProductIds[] = $recommend['recommend_product_id'];
484        }
485
486        $objQuery =& SC_Query_Ex::getSingletonInstance();
487        $arrProducts = $objProduct->getListByProductIds($objQuery, $recommendProductIds);
488
489        foreach ($arrRecommendData as $key => $arrRow) {
490            $arrRecommendData[$key] = array_merge($arrRow, $arrProducts[$arrRow['recommend_product_id']]);
491        }
492
493        return $arrRecommendData;
494    }
495
496    /* 入力内容のチェック */
497
498    /**
499     * @param string $mode
500     * @param boolean $tpl_classcat_find1
501     * @param boolean $tpl_classcat_find2
502     */
503    public function lfCheckError($mode, SC_FormParam &$objFormParam, $tpl_classcat_find1 = null, $tpl_classcat_find2 = null)
504    {
505        switch ($mode) {
506        case 'add_favorite_sphone':
507        case 'add_favorite':
508            $objCustomer = new SC_Customer_Ex();
509            $objErr = new SC_CheckError_Ex();
510            $customer_id = $objCustomer->getValue('customer_id');
511            $favorite_product_id = $objFormParam->getValue('favorite_product_id');
512            if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) {
513                $objErr->arrErr['add_favorite'.$favorite_product_id] = '※ この商品は既にお気に入りに追加されています。<br />';
514            }
515            break;
516        default:
517            // 入力データを渡す。
518            $arrRet =  $objFormParam->getHashArray();
519            $objErr = new SC_CheckError_Ex($arrRet);
520            $objErr->arrErr = $objFormParam->checkError();
521
522            // 複数項目チェック
523            if ($tpl_classcat_find1) {
524                $objErr->doFunc(array('規格1', 'classcategory_id1'), array('EXIST_CHECK'));
525            }
526            if ($tpl_classcat_find2) {
527                $objErr->doFunc(array('規格2', 'classcategory_id2'), array('EXIST_CHECK'));
528            }
529            break;
530        }
531
532        return $objErr->arrErr;
533    }
534
535    /**
536     * 商品ごとのレビュー情報を取得する
537     *
538     * @param int $product_id
539     * @return array
540     */
541    public function lfGetReviewData($product_id)
542    {
543        $objQuery =& SC_Query_Ex::getSingletonInstance();
544        //商品ごとのレビュー情報を取得する
545        $col = 'create_date, reviewer_url, reviewer_name, recommend_level, title, comment';
546        $from = 'dtb_review';
547        $where = 'del_flg = 0 AND status = 1 AND product_id = ?';
548        $objQuery->setOrder('create_date DESC');
549        $objQuery->setLimit(REVIEW_REGIST_MAX);
550        $arrWhereVal = array($product_id);
551        $arrReview = $objQuery->select($col, $from, $where, $arrWhereVal);
552
553        return $arrReview;
554    }
555
556    /**
557     * ファイルの情報をセットする
558     *
559     * @param SC_UploadFile $objUpFile
560     * @param array $arrProduct
561     * @param array $arrFile
562     * @return bool
563     */
564    public function lfSetFile(SC_UploadFile $objUpFile, $arrProduct, &$arrFile)
565    {
566        // DBからのデータを引き継ぐ
567        $objUpFile->setDBFileList($arrProduct);
568        // ファイル表示用配列を渡す
569        $arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true);
570
571        // サブ画像の有無を判定
572        $subImageFlag = false;
573        for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) {
574            if ($arrFile['sub_image' . $i]['filepath'] != '') {
575                $subImageFlag = true;
576            }
577        }
578
579        return $subImageFlag;
580    }
581
582    /*
583     * お気に入り商品登録
584     * @return void
585     */
586    public function lfRegistFavoriteProduct($favorite_product_id, $customer_id)
587    {
588        // ログイン中のユーザが商品をお気に入りにいれる処理
589        if (!SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $favorite_product_id, 'del_flg = 0 AND status = 1')) {
590            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
591
592            return false;
593        } else {
594            $objQuery =& SC_Query_Ex::getSingletonInstance();
595            $exists = $objQuery->exists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id));
596
597            if (!$exists) {
598                $sqlval['customer_id'] = $customer_id;
599                $sqlval['product_id'] = $favorite_product_id;
600                $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
601                $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
602
603                $objQuery->begin();
604                $objQuery->insert('dtb_customer_favorite_products', $sqlval);
605                $objQuery->commit();
606            }
607            // お気に入りに登録したことを示すフラグ
608            $this->just_added_favorite = true;
609
610            return true;
611        }
612    }
613
614    /**
615     * Add product(s) into the cart.
616     *
617     * @return void
618     */
619    public function doCart()
620    {
621        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam,
622                                            $this->tpl_classcat_find1,
623                                            $this->tpl_classcat_find2);
624        if (count($this->arrErr) == 0) {
625            $objCartSess = new SC_CartSession_Ex();
626            $product_class_id = $this->objFormParam->getValue('product_class_id');
627
628            $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'));
629
630            // 開いているカテゴリーツリーを維持するためのパラメーター
631            $arrQueryString = array(
632                'product_id' => $this->objFormParam->getValue('product_id'),
633            );
634
635            SC_Response_Ex::sendRedirect(CART_URL, $arrQueryString);
636            SC_Response_Ex::actionExit();
637        }
638    }
639
640    /**
641     * Add product to authenticated user's favorites.
642     *
643     * @param  SC_Customer $objCustomer
644     * @return void
645     */
646    public function doAddFavorite(SC_Customer &$objCustomer)
647    {
648        // ログイン中のユーザが商品をお気に入りにいれる処理
649        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
650            $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam);
651            if (count($this->arrErr) == 0) {
652                if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) {
653                    SC_Response_Ex::actionExit();
654                }
655                $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
656                $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this));
657            }
658        }
659    }
660
661    /**
662     * Add product to authenticated user's favorites. (for Smart phone)
663     *
664     * @param  SC_Customer $objCustomer
665     * @return void
666     */
667    public function doAddFavoriteSphone(SC_Customer $objCustomer)
668    {
669        // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用)
670        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
671            $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam);
672            if (count($this->arrErr) == 0) {
673                if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) {
674                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
675                    $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this));
676                    print 'true';
677                    SC_Response_Ex::actionExit();
678                }
679            }
680            print 'error';
681            SC_Response_Ex::actionExit();
682        }
683    }
684
685    /**
686     *
687     *
688     * @return void
689     */
690    public function doDefault()
691    {
692        // カート「戻るボタン」用に保持
693        $netURL = new Net_URL();
694        $_SESSION['cart_referer_url'] = $netURL->getURL();
695    }
696
697    /**
698     *
699     * @return void
700     */
701    public function doMobileSelect()
702    {
703        // 規格1が設定されている場合
704        if ($this->tpl_classcat_find1) {
705            // templateの変更
706            $this->tpl_mainpage = 'products/select_find1.tpl';
707
708            return;
709        }
710
711        // 数量の入力を行う
712        $this->tpl_mainpage = 'products/select_item.tpl';
713    }
714
715    /**
716     *
717     * @return void
718     */
719    public function doMobileSelect2()
720    {
721        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
722
723        // 規格1が設定されていて、エラーを検出した場合
724        if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
725            // templateの変更
726            $this->tpl_mainpage = 'products/select_find1.tpl';
727
728            return;
729        }
730
731        // 規格2が設定されている場合
732        if ($this->tpl_classcat_find2) {
733            $this->arrErr = array();
734
735            $this->tpl_mainpage = 'products/select_find2.tpl';
736
737            return;
738        }
739
740        $this->doMobileSelectItem();
741    }
742
743    /**
744     *
745     * @return void
746     */
747    public function doMobileSelectItem()
748    {
749        $objProduct = new SC_Product_Ex();
750
751        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
752
753        // この段階では、商品規格ID・数量の入力チェックエラーを出させない。
754        // FIXME: エラーチェックの定義で mode で定義を分岐する方が良いように感じる
755        unset($this->arrErr['product_class_id']);
756        unset($this->arrErr['quantity']);
757
758        // 規格2が設定されていて、エラーを検出した場合
759        if ($this->tpl_classcat_find2 and !empty($this->arrErr)) {
760            // templateの変更
761            $this->tpl_mainpage = 'products/select_find2.tpl';
762
763            return;
764        }
765
766        $product_id = $this->objFormParam->getValue('product_id');
767
768        $value1 = $this->objFormParam->getValue('classcategory_id1');
769        if (strlen($value1) === 0) {
770            $value1 = '__unselected';
771        }
772
773        // 規格2が設定されている場合.
774        if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false) {
775            $value2 = '#' . $this->objFormParam->getValue('classcategory_id2');
776        } else {
777            $value2 = '#0';
778        }
779
780        $objProduct->setProductsClassByProductIds(array($product_id));
781        $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id'];
782
783        // 数量の入力を行う
784        $this->tpl_mainpage = 'products/select_item.tpl';
785    }
786
787    /**
788     *
789     * @return void
790     */
791    public function doMobileCart()
792    {
793        // この段階でエラーが出る場合は、数量の入力エラーのはず
794        if (count($this->arrErr)) {
795            // 数量の入力を行う
796            $this->tpl_mainpage = 'products/select_item.tpl';
797        }
798    }
799
800    /**
801     *
802     * @return void
803     */
804    public function doMobileDefault()
805    {
806        $this->tpl_mainpage = 'products/detail.tpl';
807    }
808}
Note: See TracBrowser for help on using the repository browser.