1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | |
---|
8 | // {{{ requires |
---|
9 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
---|
10 | |
---|
11 | /** |
---|
12 | * カート のページクラス. |
---|
13 | * |
---|
14 | * @package Page |
---|
15 | * @author LOCKON CO.,LTD. |
---|
16 | * @version $Id:LC_Page_Cart.php 15532 2007-08-31 14:39:46Z nanasess $ |
---|
17 | */ |
---|
18 | class LC_Page_Cart extends LC_Page { |
---|
19 | |
---|
20 | // {{{ properties |
---|
21 | |
---|
22 | /** セッションの配列 */ |
---|
23 | var $arrSession; |
---|
24 | |
---|
25 | /** カテゴリの配列 */ |
---|
26 | var $arrProductsClass; |
---|
27 | |
---|
28 | /** 商品規格情報の配列 */ |
---|
29 | var $arrData; |
---|
30 | |
---|
31 | // }}} |
---|
32 | // {{{ functions |
---|
33 | |
---|
34 | /** |
---|
35 | * Page を初期化する. |
---|
36 | * |
---|
37 | * @return void |
---|
38 | */ |
---|
39 | function init() { |
---|
40 | parent::init(); |
---|
41 | $this->tpl_css = URL_DIR.'css/layout/cartin/index.css'; |
---|
42 | $this->tpl_mainpage = 'cart/index.tpl'; |
---|
43 | $this->tpl_column_num = 1; |
---|
44 | $this->tpl_title = "カゴの中を見る"; |
---|
45 | } |
---|
46 | |
---|
47 | /** |
---|
48 | * Page のプロセス. |
---|
49 | * |
---|
50 | * @return void |
---|
51 | */ |
---|
52 | function process() { |
---|
53 | $objView = new SC_SiteView(false); |
---|
54 | $objCartSess = new SC_CartSession("", false); |
---|
55 | $objSiteSess = new SC_SiteSession(); |
---|
56 | $objCampaignSess = new SC_CampaignSession(); |
---|
57 | $objSiteInfo = $objView->objSiteInfo; |
---|
58 | $objCustomer = new SC_Customer(); |
---|
59 | $db = new SC_Helper_DB_Ex(); |
---|
60 | // 基本情報の取得 |
---|
61 | $arrInfo = $objSiteInfo->data; |
---|
62 | |
---|
63 | // 商品購入中にカート内容が変更された。 |
---|
64 | if($objCartSess->getCancelPurchase()) { |
---|
65 | $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。"; |
---|
66 | } |
---|
67 | |
---|
68 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
69 | |
---|
70 | switch($_POST['mode']) { |
---|
71 | case 'up': |
---|
72 | $objCartSess->upQuantity($_POST['cart_no']); |
---|
73 | SC_Utils_Ex::sfReload(); |
---|
74 | break; |
---|
75 | case 'down': |
---|
76 | $objCartSess->downQuantity($_POST['cart_no']); |
---|
77 | SC_Utils_Ex::sfReload(); |
---|
78 | break; |
---|
79 | case 'delete': |
---|
80 | $objCartSess->delProduct($_POST['cart_no']); |
---|
81 | SC_Utils_Ex::sfReload(); |
---|
82 | break; |
---|
83 | case 'confirm': |
---|
84 | // カート内情報の取得 |
---|
85 | $arrRet = $objCartSess->getCartList(); |
---|
86 | $max = count($arrRet); |
---|
87 | $cnt = 0; |
---|
88 | for ($i = 0; $i < $max; $i++) { |
---|
89 | // 商品規格情報の取得 |
---|
90 | $this->arrData = $db->sfGetProductsClass($arrRet[$i]['id']); |
---|
91 | // DBに存在する商品 |
---|
92 | if($this->arrData != "") { |
---|
93 | $cnt++; |
---|
94 | } |
---|
95 | } |
---|
96 | // カート商品が1件以上存在する場合 |
---|
97 | if($cnt > 0) { |
---|
98 | // 正常に登録されたことを記録しておく |
---|
99 | $objSiteSess->setRegistFlag(); |
---|
100 | $pre_uniqid = $objSiteSess->getUniqId(); |
---|
101 | // 注文一時IDの発行 |
---|
102 | $objSiteSess->setUniqId(); |
---|
103 | $uniqid = $objSiteSess->getUniqId(); |
---|
104 | // エラーリトライなどで既にuniqidが存在する場合は、設定を引き継ぐ |
---|
105 | if($pre_uniqid != "") { |
---|
106 | $sqlval['order_temp_id'] = $uniqid; |
---|
107 | $where = "order_temp_id = ?"; |
---|
108 | $objQuery = new SC_Query(); |
---|
109 | $objQuery->update("dtb_order_temp", $sqlval, $where, array($pre_uniqid)); |
---|
110 | } |
---|
111 | // カートを購入モードに設定 |
---|
112 | $objCartSess->saveCurrentCart($uniqid); |
---|
113 | // 購入ページへ |
---|
114 | $this->sendRedirect(URL_SHOP_TOP); |
---|
115 | } |
---|
116 | break; |
---|
117 | default: |
---|
118 | break; |
---|
119 | } |
---|
120 | |
---|
121 | // カート集計処理 |
---|
122 | $db->sfTotalCart($this, $objCartSess, $arrInfo); |
---|
123 | $this->arrData = $db->sfTotalConfirm($this->arrData, $this, $objCartSess, $arrInfo, $objCustomer); |
---|
124 | |
---|
125 | $this->arrInfo = $arrInfo; |
---|
126 | |
---|
127 | // ログイン判定 |
---|
128 | if($objCustomer->isLoginSuccess()) { |
---|
129 | $this->tpl_login = true; |
---|
130 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
131 | $this->tpl_name = $objCustomer->getValue('name01'); |
---|
132 | } |
---|
133 | |
---|
134 | // 送料無料までの金額を計算 |
---|
135 | $this->tpl_deliv_free = $this->arrInfo['free_rule'] - $this->tpl_total_pretax; |
---|
136 | |
---|
137 | // 前頁のURLを取得 |
---|
138 | $this->tpl_prev_url = $objCartSess->getPrevURL(); |
---|
139 | |
---|
140 | $objView->assignobj($this); |
---|
141 | // フレームを選択(キャンペーンページから遷移なら変更) |
---|
142 | $objCampaignSess->pageView($objView); |
---|
143 | } |
---|
144 | |
---|
145 | /** |
---|
146 | * モバイルページを初期化する. |
---|
147 | * |
---|
148 | * @return void |
---|
149 | */ |
---|
150 | function mobileInit() { |
---|
151 | $this->init(); |
---|
152 | } |
---|
153 | |
---|
154 | /** |
---|
155 | * Page のプロセス(モバイル). |
---|
156 | * |
---|
157 | * @return void |
---|
158 | */ |
---|
159 | function mobileProcess() { |
---|
160 | |
---|
161 | // 買い物を続ける場合 |
---|
162 | if (!isset($_REQUEST['continue'])) $_REQUEST['continue'] = ""; |
---|
163 | if($_REQUEST['continue']) { |
---|
164 | $this->sendRedirect($this->getLocation(MOBILE_URL_SITE_TOP, array(session_name() => session_id()))); |
---|
165 | exit; |
---|
166 | } |
---|
167 | |
---|
168 | $objView = new SC_MobileView(false); |
---|
169 | $objCartSess = new SC_CartSession("", false); |
---|
170 | $objSiteSess = new SC_SiteSession(); |
---|
171 | $objSiteInfo = $objView->objSiteInfo; |
---|
172 | $objCustomer = new SC_Customer(); |
---|
173 | $objDb = new SC_Helper_DB_Ex(); |
---|
174 | |
---|
175 | // 基本情報の取得 |
---|
176 | $arrInfo = $objSiteInfo->data; |
---|
177 | |
---|
178 | // 商品購入中にカート内容が変更された。 |
---|
179 | if($objCartSess->getCancelPurchase()) { |
---|
180 | $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。"; |
---|
181 | } |
---|
182 | |
---|
183 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
184 | |
---|
185 | switch($_POST['mode']) { |
---|
186 | case 'confirm': |
---|
187 | // カート内情報の取得 |
---|
188 | $arrRet = $objCartSess->getCartList(); |
---|
189 | $max = count($arrRet); |
---|
190 | $cnt = 0; |
---|
191 | for ($i = 0; $i < $max; $i++) { |
---|
192 | // 商品規格情報の取得 |
---|
193 | $arrData = $objDb->sfGetProductsClass($arrRet[$i]['id']); |
---|
194 | // DBに存在する商品 |
---|
195 | if($arrData != "") { |
---|
196 | $cnt++; |
---|
197 | } |
---|
198 | } |
---|
199 | // カート商品が1件以上存在する場合 |
---|
200 | if($cnt > 0) { |
---|
201 | // 正常に登録されたことを記録しておく |
---|
202 | $objSiteSess->setRegistFlag(); |
---|
203 | $pre_uniqid = $objSiteSess->getUniqId(); |
---|
204 | // 注文一時IDの発行 |
---|
205 | $objSiteSess->setUniqId(); |
---|
206 | $uniqid = $objSiteSess->getUniqId(); |
---|
207 | // エラーリトライなどで既にuniqidが存在する場合は、設定を引き継ぐ |
---|
208 | if($pre_uniqid != "") { |
---|
209 | $sqlval['order_temp_id'] = $uniqid; |
---|
210 | $where = "order_temp_id = ?"; |
---|
211 | $objQuery = new SC_Query(); |
---|
212 | $objQuery->update("dtb_order_temp", $sqlval, $where, array($pre_uniqid)); |
---|
213 | } |
---|
214 | // カートを購入モードに設定 |
---|
215 | $objCartSess->saveCurrentCart($uniqid); |
---|
216 | // 購入ページへ |
---|
217 | $this->sendRedirect(SC_Helper_Mobile_Ex::gfAddSessionId(MOBILE_URL_SHOP_TOP)); |
---|
218 | |
---|
219 | exit; |
---|
220 | } |
---|
221 | break; |
---|
222 | default: |
---|
223 | break; |
---|
224 | } |
---|
225 | |
---|
226 | if (!isset($_GET['mode'])) $_GET['mode'] = ""; |
---|
227 | |
---|
228 | /* |
---|
229 | * FIXME sendRedirect() を使った方が良いが無限ループしてしまう... |
---|
230 | */ |
---|
231 | switch($_GET['mode']) { |
---|
232 | case 'up': |
---|
233 | $objCartSess->upQuantity($_GET['cart_no']); |
---|
234 | SC_Utils_Ex::sfReload(session_name() . "=" . session_id()); |
---|
235 | break; |
---|
236 | case 'down': |
---|
237 | $objCartSess->downQuantity($_GET['cart_no']); |
---|
238 | SC_Utils_Ex::sfReload(session_name() . "=" . session_id()); |
---|
239 | break; |
---|
240 | case 'delete': |
---|
241 | $objCartSess->delProduct($_GET['cart_no']); |
---|
242 | SC_Utils_Ex::sfReload(session_name() . "=" . session_id()); |
---|
243 | break; |
---|
244 | } |
---|
245 | |
---|
246 | // カート集計処理 |
---|
247 | if (empty($arrData)) { |
---|
248 | $arrData = array(); |
---|
249 | } |
---|
250 | $objDb->sfTotalCart($this, $objCartSess, $arrInfo); |
---|
251 | $this->arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, $arrInfo, $objCustomer); |
---|
252 | |
---|
253 | $this->arrInfo = $arrInfo; |
---|
254 | |
---|
255 | // ログイン判定 |
---|
256 | if($objCustomer->isLoginSuccess()) { |
---|
257 | $this->tpl_login = true; |
---|
258 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
259 | $this->tpl_name = $objCustomer->getValue('name01'); |
---|
260 | } |
---|
261 | |
---|
262 | // 送料無料までの金額を計算 |
---|
263 | $tpl_deliv_free = $this->arrInfo['free_rule'] - $this->tpl_total_pretax; |
---|
264 | $this->tpl_deliv_free = $tpl_deliv_free; |
---|
265 | |
---|
266 | // 前頁のURLを取得 |
---|
267 | $this->tpl_prev_url = $objCartSess->getPrevURL(); |
---|
268 | |
---|
269 | $objView->assignobj($this); |
---|
270 | $objView->display(SITE_FRAME); |
---|
271 | } |
---|
272 | |
---|
273 | /** |
---|
274 | * デストラクタ. |
---|
275 | * |
---|
276 | * @return void |
---|
277 | */ |
---|
278 | function destroy() { |
---|
279 | parent::destroy(); |
---|
280 | } |
---|
281 | } |
---|
282 | ?> |
---|