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

Revision 19803, 10.2 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある)

  • 一斉置換前の現状記録のためのコミット

#628(未使用処理・定義などの削除)

  • 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_FILE_PATH . "pages/LC_Page.php");
26if (file_exists(MODULE_FILE_PATH . "mdl_gmopg/inc/function.php")) {
27    require_once(MODULE_FILE_PATH . "mdl_gmopg/inc/function.php");
28}
29
30/**
31 * カート のページクラス.
32 *
33 * @package Page
34 * @author LOCKON CO.,LTD.
35 * @version $Id:LC_Page_Cart.php 15532 2007-08-31 14:39:46Z nanasess $
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    }
62
63    /**
64     * Page のプロセス.
65     *
66     * @return void
67     */
68    function process() {
69        parent::process();
70        $this->action();
71        $this->sendResponse();
72    }
73
74    /**
75     * Page のアクション.
76     *
77     * @return void
78     */
79    function action() {
80        $objView = new SC_SiteView(false);
81        $objCartSess = new SC_CartSession();
82        $objSiteSess = new SC_SiteSession();
83        $objSiteInfo = $objView->objSiteInfo;
84        $objCustomer = new SC_Customer();
85        $objDb = new SC_Helper_DB_Ex();
86        $objProduct = new SC_Product();
87
88        $i = 0;
89        $this->cartKeys = $objCartSess->getKeys();
90        foreach ($this->cartKeys as $key) {
91            // 商品購入中にカート内容が変更された。
92            if($objCartSess->getCancelPurchase($key)) {
93                $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。";
94            }
95        }
96        $this->cartItems =& $objCartSess->getAllCartList();
97
98        if (!isset($_POST['mode'])) $_POST['mode'] = "";
99
100        switch($_POST['mode']) {
101        case 'up':
102            $objCartSess->upQuantity($_POST['cart_no'], $_POST['cartKey']);
103            $this->objDisplay->reload(); // PRG pattern
104            break;
105        case 'down':
106            $objCartSess->downQuantity($_POST['cart_no'], $_POST['cartKey']);
107            $this->objDisplay->reload(); // PRG pattern
108            break;
109        case 'delete':
110            $objCartSess->delProduct($_POST['cart_no'], $_POST['cartKey']);
111            $this->objDisplay->reload(); // PRG pattern
112            break;
113        case 'confirm':
114            // カート内情報の取得
115            $cartKey = $_POST['cartKey'];
116            $cartList = $objCartSess->getCartList($cartKey);
117            // カート商品が1件以上存在する場合
118            if(count($cartList) > 0) {
119                // 正常に登録されたことを記録しておく
120                $objSiteSess->setRegistFlag();
121                $pre_uniqid = $objSiteSess->getUniqId();
122                // 注文一時IDの発行
123                $objSiteSess->setUniqId();
124                $uniqid = $objSiteSess->getUniqId();
125                // エラーリトライなどで既にuniqidが存在する場合は、設定を引き継ぐ
126                if($pre_uniqid != "") {
127                    $sqlval['order_temp_id'] = $uniqid;
128                    $where = "order_temp_id = ?";
129                    $objQuery = new SC_Query();
130                    $objQuery->update("dtb_order_temp", $sqlval, $where, array($pre_uniqid));
131                }
132                // カートを購入モードに設定
133                $objCartSess->saveCurrentCart($uniqid, $cartKey);
134                // 購入ページへ
135                $this->objDisplay->redirect(URL_SHOP_TOP);
136                exit;
137            }
138            break;
139        default:
140            break;
141        }
142
143        // 基本情報の取得
144        $this->arrInfo = $objSiteInfo->data;
145        foreach ($this->cartKeys as $key) {
146            // カート集計処理
147            $this->tpl_message = $objCartSess->checkProducts($key);
148            $this->tpl_total_inctax[$key] = $objCartSess->getAllProductsTotal($key);
149            $this->tpl_total_tax[$key] = $objCartSess->getAllProductsTax($key);
150            // ポイント合計
151            $this->tpl_total_point[$key] = $objCartSess->getAllProductsPoint($key);
152            $this->arrData = $objCartSess->calculate($key, $objCustomer);
153
154            // 送料無料までの金額を計算
155            $this->tpl_deliv_free[$key] = $this->arrInfo['free_rule'] - $this->tpl_total_inctax[$key];
156        }
157
158        // ログイン判定
159        if($objCustomer->isLoginSuccess()) {
160            $this->tpl_login = true;
161            $this->tpl_user_point = $objCustomer->getValue('point');
162            $this->tpl_name = $objCustomer->getValue('name01');
163        }
164
165        // 前頁のURLを取得
166        $this->tpl_prev_url = $objCartSess->getPrevURL();
167    }
168
169    /**
170     * モバイルページを初期化する.
171     *
172     * @return void
173     */
174    function mobileInit() {
175        $this->init();
176    }
177
178    /**
179     * Page のプロセス(モバイル).
180     *
181     * @return void
182     */
183    function mobileProcess() {
184        parent::mobileProcess();
185        $this->mobileAction();
186        $this->sendResponse();
187    }
188
189    /**
190     * Page のアクション(モバイル).
191     *
192     * @return void
193     */
194    function mobileAction() {
195        // 買い物を続ける場合
196        if ($_REQUEST['mode'] == 'continue') {
197            $this->objDisplay->redirect($this->getLocation(MOBILE_URL_SITE_TOP));
198            exit;
199        }
200
201        $objView = new SC_MobileView(false);
202        $objCartSess = new SC_CartSession();
203        $objSiteSess = new SC_SiteSession();
204        $objSiteInfo = $objView->objSiteInfo;
205        $objCustomer = new SC_Customer();
206        $objDb = new SC_Helper_DB_Ex();
207
208        // 商品購入中にカート内容が変更された。
209        if($objCartSess->getCancelPurchase()) {
210            $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。";
211        }
212
213        switch($_POST['mode']) {
214        case 'confirm':
215            // カート内情報の取得
216            $arrRet = $objCartSess->getCartList();
217            $max = count($arrRet);
218            $cnt = 0;
219            for ($i = 0; $i < $max; $i++) {
220                // 商品規格情報の取得
221                $arrData = $objDb->sfGetProductsClass($arrRet[$i]['id']);
222                // DBに存在する商品
223                if($arrData != "") {
224                    $cnt++;
225                }
226            }
227            // カート商品が1件以上存在する場合
228            if($cnt > 0) {
229                // 正常に登録されたことを記録しておく
230                $objSiteSess->setRegistFlag();
231                $pre_uniqid = $objSiteSess->getUniqId();
232                // 注文一時IDの発行
233                $objSiteSess->setUniqId();
234                $uniqid = $objSiteSess->getUniqId();
235                // エラーリトライなどで既にuniqidが存在する場合は、設定を引き継ぐ
236                if($pre_uniqid != "") {
237                    $sqlval['order_temp_id'] = $uniqid;
238                    $where = "order_temp_id = ?";
239                    $objQuery = new SC_Query();
240                    $objQuery->update("dtb_order_temp", $sqlval, $where, array($pre_uniqid));
241                }
242                // カートを購入モードに設定
243                $objCartSess->saveCurrentCart($uniqid);
244                // 購入ページへ
245                $this->objDisplay->redirect(MOBILE_URL_SHOP_TOP);
246                exit;
247            }
248            break;
249        default:
250            break;
251        }
252
253        if (!isset($_GET['mode'])) $_GET['mode'] = "";
254
255        /*
256         * FIXME sendRedirect() を使った方が良いが無限ループしてしまう...
257         */
258        switch($_GET['mode']) {
259        case 'up':
260            $objCartSess->upQuantity($_GET['cart_no']);
261            SC_Utils_Ex::sfReload(session_name() . "=" . session_id());
262            break;
263        case 'down':
264            $objCartSess->downQuantity($_GET['cart_no']);
265            SC_Utils_Ex::sfReload(session_name() . "=" . session_id());
266            break;
267        case 'delete':
268            $objCartSess->delProduct($_GET['cart_no']);
269            SC_Utils_Ex::sfReload(session_name() . "=" . session_id());
270            break;
271        }
272
273        // カート集計処理
274        if (empty($arrData)) {
275            $arrData = array();
276        }
277        $objDb->sfTotalCart($this, $objCartSess);
278        $this->arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, null, $objCustomer);
279
280        // 基本情報の取得
281        $this->arrInfo = $objSiteInfo->data;
282
283        // ログイン判定
284        if($objCustomer->isLoginSuccess(true)) {
285            $this->tpl_login = true;
286            $this->tpl_user_point = $objCustomer->getValue('point');
287            $this->tpl_name = $objCustomer->getValue('name01');
288        }
289
290        // 送料無料までの金額を計算
291        $tpl_deliv_free = $this->arrInfo['free_rule'] - $this->tpl_total_inctax;
292        $this->tpl_deliv_free = $tpl_deliv_free;
293
294        // 前頁のURLを取得
295        $this->tpl_prev_url = $objCartSess->getPrevURL();
296    }
297
298    /**
299     * デストラクタ.
300     *
301     * @return void
302     */
303    function destroy() {
304        parent::destroy();
305    }
306}
307?>
Note: See TracBrowser for help on using the repository browser.