source: branches/version-2_13-dev/data/class/pages/shopping/LC_Page_Shopping_Deliv.php @ 23026

Revision 23026, 8.8 KB checked in by AMUAMU, 11 years ago (diff)

#2323 (税率対応)
#2235 (越境ECを想定した機能の追加)
#2234 (非会員お客様情報入力テンプレートと機能の共通化)
#2324 (会員登録、注文フォームに「会社名」フィールドを足す)
#2233 (購入手続きのログイン画面でログイン出来ないユーザーがいる)
などの修正

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • 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-2013 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
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26/**
27 * お届け先の指定 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_Shopping_Deliv extends LC_Page_Ex
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    function init()
41    {
42        parent::init();
43        $masterData = new SC_DB_MasterData_Ex();
44        $this->arrPref = $masterData->getMasterData('mtb_pref');
45        $this->arrCountry = $masterData->getMasterData('mtb_country');
46        $this->tpl_title = 'お届け先の指定';
47        $this->httpCacheControl('nocache');
48    }
49
50    /**
51     * Page のプロセス.
52     *
53     * @return void
54     */
55    function process()
56    {
57        parent::process();
58        $this->action();
59        $this->sendResponse();
60    }
61
62    /**
63     * Page のプロセス.
64     *
65     * @return void
66     */
67    function action()
68    {
69        $objSiteSess = new SC_SiteSession_Ex();
70        $objCartSess = new SC_CartSession_Ex();
71        $objCustomer = new SC_Customer_Ex();
72        $objPurchase = new SC_Helper_Purchase_Ex();
73        $objFormParam = new SC_FormParam_Ex();
74        $objAddress = new SC_Helper_Address_Ex();
75
76        $this->tpl_uniqid = $objSiteSess->getUniqId();
77        $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);
78
79        $this->cartKey = $objCartSess->getKey();
80
81        // ログインチェック
82        if (!$objCustomer->isLoginSuccess(true)) {
83            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
84        }
85
86        // ダウンロード商品の場合は、支払方法画面に転送
87        if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD) {
88            $objPurchase->copyFromCustomer($sqlval, $objCustomer, 'shipping');
89            $objPurchase->saveShippingTemp($sqlval);
90            $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer);
91            $objSiteSess->setRegistFlag();
92
93            SC_Response_Ex::sendRedirect('payment.php');
94            SC_Response_Ex::actionExit();
95        }
96
97        $this->lfInitParam($objFormParam);
98        $objFormParam->setParam($_POST);
99        $objFormParam->convParam();
100        $arrErr = $objFormParam->checkError();
101        if (!SC_Utils_Ex::isBlank($arrErr)) {
102            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
103            SC_Response_Ex::actionExit();
104        }
105
106        $arrForm = $objFormParam->getHashArray();
107
108        switch ($this->getMode()) {
109            // 削除
110            case 'delete':
111                $objAddress->deleteAddress($arrForm['other_deliv_id']);
112                break;
113
114            // 会員登録住所に送る
115            case 'customer_addr':
116                $objPurchase->unsetShippingTemp();
117
118                $shipping_id = $arrForm['deliv_check'] == -1 ? 0 : $arrForm['deliv_check'];
119                $success = $this->registerDeliv($shipping_id, $this->tpl_uniqid, $objPurchase, $objCustomer, $objAddress);
120                if (!$success) {
121                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
122                }
123
124                $objPurchase->setShipmentItemTempForSole($objCartSess, $shipping_id);
125                $objSiteSess->setRegistFlag();
126
127                SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH);
128                SC_Response_Ex::actionExit();
129                break;
130
131            // 前のページに戻る
132            case 'return':
133
134                // 確認ページへ移動
135                SC_Response_Ex::sendRedirect(CART_URLPATH);
136                SC_Response_Ex::actionExit();
137                break;
138
139            // お届け先複数指定
140            case 'multiple':
141                // 複数配送先指定が無効な場合はエラー
142                if (USE_MULTIPLE_SHIPPING === false) {
143                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
144                    SC_Response_Ex::actionExit();
145                }
146
147                SC_Response_Ex::sendRedirect('multiple.php');
148                SC_Response_Ex::actionExit();
149                break;
150
151            default:
152                // 配送IDの取得
153                $shippingData = $objPurchase->getShippingTemp();
154                if (!SC_Utils_Ex::isBlank($shippingData)) {
155                    $arrShippingId = array_keys($shippingData);
156                }
157                if (isset($arrShippingId[0])) {
158                    $this->arrForm['deliv_check']['value'] = $arrShippingId[0] == 0 ? -1 : $arrShippingId[0];
159                }
160                break;
161        }
162
163        // 登録済み住所を取得
164        $addr = array(
165            array(
166                'other_deliv_id'    => NULL,
167                'customer_id'       => $objCustomer->getValue('customer_id'),
168                'name01'            => $objCustomer->getValue('name01'),
169                'name02'            => $objCustomer->getValue('name02'),
170                'kana01'            => $objCustomer->getValue('kana01'),
171                'kana02'            => $objCustomer->getValue('kana02'),
172                'company_name'      => $objCustomer->getValue('company_name'),
173                'country_id'           => $objCustomer->getValue('country_id'),
174                'zipcode'           => $objCustomer->getValue('zipcode'),
175                'zip01'             => $objCustomer->getValue('zip01'),
176                'zip02'             => $objCustomer->getValue('zip02'),
177                'pref'              => $objCustomer->getValue('pref'),
178                'addr01'            => $objCustomer->getValue('addr01'),
179                'addr02'            => $objCustomer->getValue('addr02'),
180                'tel01'             => $objCustomer->getValue('tel01'),
181                'tel02'             => $objCustomer->getValue('tel02'),
182                'tel03'             => $objCustomer->getValue('tel03'),
183            )
184        );
185        $this->arrAddr = array_merge($addr, $objAddress->getList($objCustomer->getValue('customer_id')));
186        $this->tpl_addrmax = count($this->arrAddr) - 1; // 会員の住所をカウントしない
187
188
189    }
190
191    /**
192     * パラメーター情報の初期化を行う.
193     *
194     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
195     * @return void
196     */
197    function lfInitParam(&$objFormParam)
198    {
199        $objFormParam->addParam('その他のお届け先ID', 'other_deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
200        $objFormParam->addParam('お届け先チェック', 'deliv_check', INT_LEN, 'n', array('MAX_LENGTH_CHECK'));
201    }
202
203    /**
204     * お届け先チェックの値に応じて, お届け先情報を保存する.
205     *
206     * 会員住所がチェックされている場合は, 会員情報からお届け先を取得する.
207     * その他のお届け先がチェックされている場合は, その他のお届け先からお届け先を取得する.
208     * お届け先チェックの値が不正な場合は false を返す.
209     *
210     * @param integer $other_deliv_id
211     * @param string $uniqid 受注一時テーブルのユニークID
212     * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
213     * @param SC_Customer $objCustomer SC_Customer インスタンス
214     * @return boolean お届け先チェックの値が妥当な場合 true
215     */
216    function registerDeliv($other_deliv_id, $uniqid, &$objPurchase, &$objCustomer, $objAddress)
217    {
218        $arrValues = array();
219        // 会員登録住所がチェックされている場合
220        if ($other_deliv_id == 0) {
221            $objPurchase->copyFromCustomer($arrValues, $objCustomer, 'shipping');
222        }
223        // 別のお届け先がチェックされている場合
224        else {
225            $arrOtherDeliv = $objAddress->getAddress($other_deliv_id);
226            if (!$arrOtherDeliv) {
227                return false;
228            }
229
230            $objPurchase->copyFromOrder($arrValues, $arrOtherDeliv, 'shipping', '');
231        }
232        $objPurchase->saveShippingTemp($arrValues, $other_deliv_id);
233        $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
234
235        return true;
236    }
237}
Note: See TracBrowser for help on using the repository browser.