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 |
---|
25 | require_once(CLASS_REALDIR . "pages/LC_Page.php"); |
---|
26 | if (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 | */ |
---|
37 | class 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 | $objView = new SC_SiteView(false); |
---|
84 | $objCartSess = new SC_CartSession(); |
---|
85 | $objSiteSess = new SC_SiteSession(); |
---|
86 | $objSiteInfo = $objView->objSiteInfo; |
---|
87 | $objCustomer = new SC_Customer(); |
---|
88 | |
---|
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 'confirm': |
---|
102 | // カート内情報の取得 |
---|
103 | $cartKey = $_POST['cartKey']; |
---|
104 | $cartList = $objCartSess->getCartList($cartKey); |
---|
105 | // カート商品が1件以上存在する場合 |
---|
106 | if(count($cartList) > 0) { |
---|
107 | // 正常に登録されたことを記録しておく |
---|
108 | $objSiteSess->setRegistFlag(); |
---|
109 | $pre_uniqid = $objSiteSess->getUniqId(); |
---|
110 | // 注文一時IDの発行 |
---|
111 | $objSiteSess->setUniqId(); |
---|
112 | $uniqid = $objSiteSess->getUniqId(); |
---|
113 | // エラーリトライなどで既にuniqidが存在する場合は、設定を引き継ぐ |
---|
114 | if($pre_uniqid != "") { |
---|
115 | $sqlval['order_temp_id'] = $uniqid; |
---|
116 | $where = "order_temp_id = ?"; |
---|
117 | $objQuery = new SC_Query(); |
---|
118 | $objQuery->update("dtb_order_temp", $sqlval, $where, array($pre_uniqid)); |
---|
119 | } |
---|
120 | // カートを購入モードに設定 |
---|
121 | $objCartSess->saveCurrentCart($uniqid, $cartKey); |
---|
122 | // 購入ページへ |
---|
123 | $this->objDisplay->redirect(SHOPPING_URL); |
---|
124 | exit; |
---|
125 | } |
---|
126 | break; |
---|
127 | default: |
---|
128 | break; |
---|
129 | } |
---|
130 | |
---|
131 | // 商品の個数変更、削除処理 |
---|
132 | $changeCartMode = (Net_UserAgent_Mobile::isMobile() === true) ? $_GET['mode'] : $_POST['mode']; |
---|
133 | /* |
---|
134 | * FIXME モバイルの場合 sfReload() ではなく sendRedirect() を使った方が良いが無限ループしてしまう... |
---|
135 | */ |
---|
136 | switch($changeCartMode) { |
---|
137 | case 'up': |
---|
138 | if(Net_UserAgent_Mobile::isMobile() === true) { |
---|
139 | $objCartSess->upQuantity($_GET['cart_no'], $_GET['cartKey']); |
---|
140 | SC_Utils_Ex::sfReload(session_name() . "=" . session_id()); |
---|
141 | } else { |
---|
142 | $objCartSess->upQuantity($_POST['cart_no'], $_POST['cartKey']); |
---|
143 | $this->objDisplay->reload(); // PRG pattern |
---|
144 | } |
---|
145 | break; |
---|
146 | case 'down': |
---|
147 | if(Net_UserAgent_Mobile::isMobile() === true) { |
---|
148 | $objCartSess->downQuantity($_GET['cart_no'], $_GET['cartKey']); |
---|
149 | SC_Utils_Ex::sfReload(session_name() . "=" . session_id()); |
---|
150 | } else { |
---|
151 | $objCartSess->downQuantity($_POST['cart_no'], $_POST['cartKey']); |
---|
152 | $this->objDisplay->reload(); // PRG pattern |
---|
153 | } |
---|
154 | break; |
---|
155 | case 'delete': |
---|
156 | if(Net_UserAgent_Mobile::isMobile() === true) { |
---|
157 | $objCartSess->delProduct($_GET['cart_no'], $_GET['cartKey']); |
---|
158 | SC_Utils_Ex::sfReload(session_name() . "=" . session_id()); |
---|
159 | } else { |
---|
160 | $objCartSess->delProduct($_POST['cart_no'], $_POST['cartKey']); |
---|
161 | $this->objDisplay->reload(); // PRG pattern |
---|
162 | } |
---|
163 | break; |
---|
164 | default: |
---|
165 | break; |
---|
166 | } |
---|
167 | |
---|
168 | // 基本情報の取得 |
---|
169 | $this->arrInfo = $objSiteInfo->data; |
---|
170 | foreach ($this->cartKeys as $key) { |
---|
171 | // カート集計処理 |
---|
172 | $this->tpl_message = $objCartSess->checkProducts($key); |
---|
173 | $this->tpl_total_inctax[$key] = $objCartSess->getAllProductsTotal($key); |
---|
174 | $this->tpl_total_tax[$key] = $objCartSess->getAllProductsTax($key); |
---|
175 | // ポイント合計 |
---|
176 | $this->tpl_total_point[$key] = $objCartSess->getAllProductsPoint($key); |
---|
177 | |
---|
178 | $this->arrData[$key] = $objCartSess->calculate($key, $objCustomer); |
---|
179 | // 送料無料までの金額を計算 |
---|
180 | $this->tpl_deliv_free[$key] = $this->arrInfo['free_rule'] - $this->tpl_total_inctax[$key]; |
---|
181 | } |
---|
182 | |
---|
183 | // ログイン判定 |
---|
184 | if($objCustomer->isLoginSuccess(true)) { |
---|
185 | $this->tpl_login = true; |
---|
186 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
187 | $this->tpl_name = $objCustomer->getValue('name01'); |
---|
188 | } |
---|
189 | |
---|
190 | // 前頁のURLを取得 |
---|
191 | $this->tpl_prev_url = $objCartSess->getPrevURL(); |
---|
192 | } |
---|
193 | |
---|
194 | /** |
---|
195 | * デストラクタ. |
---|
196 | * |
---|
197 | * @return void |
---|
198 | */ |
---|
199 | function destroy() { |
---|
200 | parent::destroy(); |
---|
201 | } |
---|
202 | } |
---|
203 | ?> |
---|