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

Revision 19783, 10.2 KB checked in by nanasess, 13 years ago (diff)

#748(モバイル/スマートフォンのデザイン管理)

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