source: branches/version-2_5-dev/data/class/pages/cart/LC_Page_Cart.php @ 20067

Revision 20067, 7.7 KB checked in by yomoro, 13 years ago (diff)

不要なインスタンスの削除

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • 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-2010 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
24// {{{ requires
25require_once(CLASS_REALDIR . "pages/LC_Page.php");
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 *
33 * @package Page
34 * @author LOCKON CO.,LTD.
35 * @version $Id$
36 */
37class LC_Page_Cart extends LC_Page {
38
39    // {{{ properties
40
41    /** セッションの配列 */
42    var $arrSession;
43
44    /** カテゴリの配列 */
45    var $arrProductsClass;
46
47    /** 商品規格情報の配列 */
48    var $arrData;
49
50    // }}}
51    // {{{ functions
52
53    /**
54     * Page を初期化する.
55     *
56     * @return void
57     */
58    function init() {
59        parent::init();
60        $this->tpl_title = "現在のカゴの中";
61        $masterData = new SC_DB_MasterData_Ex();
62        $this->arrProductType = $masterData->getMasterData("mtb_product_type");
63
64    }
65
66    /**
67     * Page のプロセス.
68     *
69     * @return void
70     */
71    function process() {
72        parent::process();
73        $this->action();
74        $this->sendResponse();
75    }
76
77    /**
78     * Page のアクション.
79     *
80     * @return void
81     */
82    function action() {
83        $objCartSess = new SC_CartSession();
84        $objSiteSess = new SC_SiteSession();
85        $objSiteInfo = $objView->objSiteInfo;
86        $objCustomer = new SC_Customer();
87
88        $this->cartKeys = $objCartSess->getKeys();
89        foreach ($this->cartKeys as $key) {
90            // 商品購入中にカート内容が変更された。
91            if($objCartSess->getCancelPurchase($key)) {
92                $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。";
93            }
94        }
95        $this->cartItems =& $objCartSess->getAllCartList();
96
97        //TODO: 要リファクタリング(MODE switch 2か所で行われている)
98        switch($this->getMode()) {
99        case 'confirm':
100            // カート内情報の取得
101            $cartKey = $_POST['cartKey'];
102            $cartList = $objCartSess->getCartList($cartKey);
103            // カート商品が1件以上存在する場合
104            if(count($cartList) > 0) {
105                // 正常に登録されたことを記録しておく
106                $objSiteSess->setRegistFlag();
107                $pre_uniqid = $objSiteSess->getUniqId();
108                // 注文一時IDの発行
109                $objSiteSess->setUniqId();
110                $uniqid = $objSiteSess->getUniqId();
111                // エラーリトライなどで既にuniqidが存在する場合は、設定を引き継ぐ
112                if($pre_uniqid != "") {
113                    $sqlval['order_temp_id'] = $uniqid;
114                    $where = "order_temp_id = ?";
115                    $objQuery = new SC_Query();
116                    $objQuery->update("dtb_order_temp", $sqlval, $where, array($pre_uniqid));
117                }
118                // カートを購入モードに設定
119                $objCartSess->saveCurrentCart($uniqid, $cartKey);
120                // 購入ページへ
121                SC_Response_Ex::sendRedirect(SHOPPING_URL);
122                exit;
123            }
124            break;
125        default:
126            break;
127        }
128
129        // 商品の個数変更、削除処理
130        /*
131         * FIXME モバイルの場合 sfReload() ではなく sendRedirect() を使った方が良いが無限ループしてしまう...
132         */
133        //TODO: 要リファクタリング(MODE switch 2か所で行われている)
134        switch($this->getMode()) {
135        case 'up':
136            if(Net_UserAgent_Mobile::isMobile() === true) {
137                $objCartSess->upQuantity($_GET['cart_no'], $_GET['cartKey']);
138                SC_Utils_Ex::sfReload(session_name() . "=" . session_id());
139            } else {
140                $objCartSess->upQuantity($_POST['cart_no'], $_POST['cartKey']);
141                $this->objDisplay->reload(); // PRG pattern
142            }
143            break;
144        case 'down':
145            if(Net_UserAgent_Mobile::isMobile() === true) {
146                $objCartSess->downQuantity($_GET['cart_no'], $_GET['cartKey']);
147                SC_Utils_Ex::sfReload(session_name() . "=" . session_id());
148            } else {
149                $objCartSess->downQuantity($_POST['cart_no'], $_POST['cartKey']);
150                $this->objDisplay->reload(); // PRG pattern
151            }
152            break;
153        case 'delete':
154            if(Net_UserAgent_Mobile::isMobile() === true) {
155                $objCartSess->delProduct($_GET['cart_no'], $_GET['cartKey']);
156                SC_Utils_Ex::sfReload(session_name() . "=" . session_id());
157            } else {
158                $objCartSess->delProduct($_POST['cart_no'], $_POST['cartKey']);
159                $this->objDisplay->reload(); // PRG pattern
160            }
161            break;
162        default:
163            break;
164        }
165
166        // 基本情報の取得
167        $this->arrInfo = $objSiteInfo->data;
168        foreach ($this->cartKeys as $key) {
169            // カート集計処理
170            $this->tpl_message = $objCartSess->checkProducts($key);
171            $this->tpl_total_inctax[$key] = $objCartSess->getAllProductsTotal($key);
172            $this->tpl_total_tax[$key] = $objCartSess->getAllProductsTax($key);
173            // ポイント合計
174            $this->tpl_total_point[$key] = $objCartSess->getAllProductsPoint($key);
175
176            $this->arrData[$key] = $objCartSess->calculate($key, $objCustomer);
177            // 送料無料までの金額を計算
178            $this->tpl_deliv_free[$key] = $this->arrInfo['free_rule'] - $this->tpl_total_inctax[$key];
179        }
180
181        // ログイン判定
182        if($objCustomer->isLoginSuccess(true)) {
183            $this->tpl_login = true;
184            $this->tpl_user_point = $objCustomer->getValue('point');
185            $this->tpl_name = $objCustomer->getValue('name01');
186        }
187
188        // 前頁のURLを取得
189        // TODO: SC_CartSession::setPrevURL()利用不可。
190        if (!preg_match("/cart/", $_SERVER['HTTP_REFERER'])) {
191            if (!empty($_SESSION['cart_referer_url'])) {
192                $_SESSION['cart_prev_url'] = $_SESSION['cart_referer_url'];
193                unset($_SESSION['cart_referer_url']);
194            } else {
195                if (preg_match("/entry/", $_SERVER['HTTP_REFERER'])) {
196                    $_SESSION['cart_prev_url'] = HTTPS_URL . 'entry/kiyaku.php';
197                } else {
198                    $_SESSION['cart_prev_url'] = $_SERVER['HTTP_REFERER'];
199                }
200            }
201        }
202        // 妥当性チェック
203        if (!SC_Utils_Ex::sfIsInternalDomain($_SESSION['cart_prev_url'])) {
204            $_SESSION['cart_prev_url'] = '';
205        }
206
207        $this->tpl_prev_url = (isset($_SESSION['cart_prev_url'])) ? $_SESSION['cart_prev_url'] : '';
208    }
209
210    /**
211     * デストラクタ.
212     *
213     * @return void
214     */
215    function destroy() {
216        parent::destroy();
217    }
218}
219?>
Note: See TracBrowser for help on using the repository browser.