source: branches/comu-ver2/data/class/pages/cart/LC_Page_Cart.php @ 17969

Revision 17969, 9.9 KB checked in by Seasoft, 15 years ago (diff)

rv r17968
・影響範囲に不安があるため、一旦差し戻します。

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