source: branches/feature-module-update/data/class/pages/cart/LC_Page_Cart.php @ 15179

Revision 15179, 4.6 KB checked in by nanasess, 17 years ago (diff)

LC_Page の抽象化対応

  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to application/x-httpd-php
Line 
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
9require_once(CLASS_PATH . "pages/LC_Page.php");
10
11/**
12 * カート のページクラス.
13 *
14 * @package Page
15 * @author LOCKON CO.,LTD.
16 * @version $Id$
17 */
18class LC_Page_Cart extends LC_Page {
19
20    // {{{ properties
21
22    // TODO
23    var $arrSession;
24    var $arrProductsClass;
25    var $tpl_total_pretax;
26    var $tpl_total_tax;
27    var $tpl_total_point;
28    var $tpl_message;
29
30    // }}}
31    // {{{ functions
32
33    /**
34     * Page を初期化する.
35     *
36     * @return void
37     */
38    function init() {
39        parent::init();
40        $this->tpl_css = URL_DIR.'css/layout/cartin/index.css';
41        $this->tpl_mainpage = 'cart/index.tpl';
42        $this->tpl_title = "カゴの中を見る";
43    }
44
45    /**
46     * Page のプロセス.
47     *
48     * @return void
49     */
50    function process() {
51        $objView = new SC_SiteView(false);
52        $objCartSess = new SC_CartSession("", false);
53        $objSiteSess = new SC_SiteSession();
54        $objCampaignSess = new SC_CampaignSession();
55        $objSiteInfo = $objView->objSiteInfo;
56        $objCustomer = new SC_Customer();
57        $db = new SC_Helper_DB_Ex();
58        // 基本情報の取得
59        $arrInfo = $objSiteInfo->data;
60
61        // 商品購入中にカート内容が変更された。
62        if($objCartSess->getCancelPurchase()) {
63            $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。";
64        }
65
66        switch($_POST['mode']) {
67        case 'up':
68            $objCartSess->upQuantity($_POST['cart_no']);
69            SC_Utils_Ex::sfReload();
70            break;
71        case 'down':
72            $objCartSess->downQuantity($_POST['cart_no']);
73            SC_Utils_Ex::sfReload();
74            break;
75        case 'delete':
76            $objCartSess->delProduct($_POST['cart_no']);
77            SC_Utils_Ex::sfReload();
78            break;
79        case 'confirm':
80            // カート内情報の取得
81            $arrRet = $objCartSess->getCartList();
82            $max = count($arrRet);
83            $cnt = 0;
84            for ($i = 0; $i < $max; $i++) {
85                // 商品規格情報の取得
86                $arrData = $db->sfGetProductsClass($arrRet[$i]['id']);
87                // DBに存在する商品
88                if($arrData != "") {
89                    $cnt++;
90                }
91            }
92            // カート商品が1件以上存在する場合
93            if($cnt > 0) {
94                // 正常に登録されたことを記録しておく
95                $objSiteSess->setRegistFlag();
96                $pre_uniqid = $objSiteSess->getUniqId();
97                // 注文一時IDの発行
98                $objSiteSess->setUniqId();
99                $uniqid = $objSiteSess->getUniqId();
100                // エラーリトライなどで既にuniqidが存在する場合は、設定を引き継ぐ
101                if($pre_uniqid != "") {
102                    $sqlval['order_temp_id'] = $uniqid;
103                    $where = "order_temp_id = ?";
104                    $objQuery = new SC_Query();
105                    $objQuery->update("dtb_order_temp", $sqlval, $where, array($pre_uniqid));
106                }
107                // カートを購入モードに設定
108                $objCartSess->saveCurrentCart($uniqid);
109                // 購入ページへ
110                $this->sendRedirect(URL_SHOP_TOP, array());
111            }
112            break;
113        default:
114            break;
115        }
116
117        // カート集計処理
118        $this = $db->sfTotalCart($this, $objCartSess, $arrInfo);
119        $this->arrData = SC_Utils_Ex::sfTotalConfirm($arrData, $this, $objCartSess, $arrInfo, $objCustomer);
120
121        $this->arrInfo = $arrInfo;
122
123        // ログイン判定
124        if($objCustomer->isLoginSuccess()) {
125            $this->tpl_login = true;
126            $this->tpl_user_point = $objCustomer->getValue('point');
127            $this->tpl_name = $objCustomer->getValue('name01');
128        }
129
130        // 送料無料までの金額を計算
131        $this->tpl_deliv_free = $this->arrInfo['free_rule'] - $this->tpl_total_pretax;
132
133        // 前頁のURLを取得
134        $this->tpl_prev_url = $objCartSess->getPrevURL();
135
136        $objView->assignobj($this);
137        // フレームを選択(キャンペーンページから遷移なら変更)
138        $objCampaignSess->pageView($objView);
139    }
140
141    /**
142     * デストラクタ.
143     *
144     * @return void
145     */
146    function destroy() {
147        parent::destroy();
148    }
149}
150?>
Note: See TracBrowser for help on using the repository browser.