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

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