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$ |
---|
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_title = "カゴの中を見る"; |
---|
44 | } |
---|
45 | |
---|
46 | /** |
---|
47 | * Page のプロセス. |
---|
48 | * |
---|
49 | * @return void |
---|
50 | */ |
---|
51 | function process() { |
---|
52 | $objView = new SC_SiteView(false); |
---|
53 | $objCartSess = new SC_CartSession("", false); |
---|
54 | $objSiteSess = new SC_SiteSession(); |
---|
55 | $objCampaignSess = new SC_CampaignSession(); |
---|
56 | $objSiteInfo = $objView->objSiteInfo; |
---|
57 | $objCustomer = new SC_Customer(); |
---|
58 | $db = new SC_Helper_DB_Ex(); |
---|
59 | // 基本情報の取得 |
---|
60 | $arrInfo = $objSiteInfo->data; |
---|
61 | |
---|
62 | // 商品購入中にカート内容が変更された。 |
---|
63 | if($objCartSess->getCancelPurchase()) { |
---|
64 | $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。"; |
---|
65 | } |
---|
66 | |
---|
67 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
68 | |
---|
69 | switch($_POST['mode']) { |
---|
70 | case 'up': |
---|
71 | $objCartSess->upQuantity($_POST['cart_no']); |
---|
72 | SC_Utils_Ex::sfReload(); |
---|
73 | break; |
---|
74 | case 'down': |
---|
75 | $objCartSess->downQuantity($_POST['cart_no']); |
---|
76 | SC_Utils_Ex::sfReload(); |
---|
77 | break; |
---|
78 | case 'delete': |
---|
79 | $objCartSess->delProduct($_POST['cart_no']); |
---|
80 | SC_Utils_Ex::sfReload(); |
---|
81 | break; |
---|
82 | case 'confirm': |
---|
83 | // カート内情報の取得 |
---|
84 | $arrRet = $objCartSess->getCartList(); |
---|
85 | $max = count($arrRet); |
---|
86 | $cnt = 0; |
---|
87 | for ($i = 0; $i < $max; $i++) { |
---|
88 | // 商品規格情報の取得 |
---|
89 | $this->arrData = $db->sfGetProductsClass($arrRet[$i]['id']); |
---|
90 | // DBに存在する商品 |
---|
91 | if($this->arrData != "") { |
---|
92 | $cnt++; |
---|
93 | } |
---|
94 | } |
---|
95 | // カート商品が1件以上存在する場合 |
---|
96 | if($cnt > 0) { |
---|
97 | // 正常に登録されたことを記録しておく |
---|
98 | $objSiteSess->setRegistFlag(); |
---|
99 | $pre_uniqid = $objSiteSess->getUniqId(); |
---|
100 | // 注文一時IDの発行 |
---|
101 | $objSiteSess->setUniqId(); |
---|
102 | $uniqid = $objSiteSess->getUniqId(); |
---|
103 | // エラーリトライなどで既にuniqidが存在する場合は、設定を引き継ぐ |
---|
104 | if($pre_uniqid != "") { |
---|
105 | $sqlval['order_temp_id'] = $uniqid; |
---|
106 | $where = "order_temp_id = ?"; |
---|
107 | $objQuery = new SC_Query(); |
---|
108 | $objQuery->update("dtb_order_temp", $sqlval, $where, array($pre_uniqid)); |
---|
109 | } |
---|
110 | // カートを購入モードに設定 |
---|
111 | $objCartSess->saveCurrentCart($uniqid); |
---|
112 | // 購入ページへ |
---|
113 | $this->sendRedirect(URL_SHOP_TOP, array()); |
---|
114 | } |
---|
115 | break; |
---|
116 | default: |
---|
117 | break; |
---|
118 | } |
---|
119 | |
---|
120 | // カート集計処理 |
---|
121 | $this = $db->sfTotalCart($this, $objCartSess, $arrInfo); |
---|
122 | $this->arrData = SC_Utils_Ex::sfTotalConfirm($this->arrData, $this, $objCartSess, $arrInfo, $objCustomer); |
---|
123 | |
---|
124 | $this->arrInfo = $arrInfo; |
---|
125 | |
---|
126 | // ログイン判定 |
---|
127 | if($objCustomer->isLoginSuccess()) { |
---|
128 | $this->tpl_login = true; |
---|
129 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
130 | $this->tpl_name = $objCustomer->getValue('name01'); |
---|
131 | } |
---|
132 | |
---|
133 | // 送料無料までの金額を計算 |
---|
134 | $this->tpl_deliv_free = $this->arrInfo['free_rule'] - $this->tpl_total_pretax; |
---|
135 | |
---|
136 | // 前頁のURLを取得 |
---|
137 | $this->tpl_prev_url = $objCartSess->getPrevURL(); |
---|
138 | |
---|
139 | $objView->assignobj($this); |
---|
140 | // フレームを選択(キャンペーンページから遷移なら変更) |
---|
141 | $objCampaignSess->pageView($objView); |
---|
142 | } |
---|
143 | |
---|
144 | /** |
---|
145 | * デストラクタ. |
---|
146 | * |
---|
147 | * @return void |
---|
148 | */ |
---|
149 | function destroy() { |
---|
150 | parent::destroy(); |
---|
151 | } |
---|
152 | } |
---|
153 | ?> |
---|