| 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
| 5 | * Copyright(c) 2000-2011 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_EX_REALDIR . 'page_extends/LC_Page_Ex.php'; |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * 支払い方法選択 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
| 34 | class LC_Page_Shopping_Payment extends LC_Page_Ex { |
---|
| 35 | |
---|
| 36 | // {{{ properties |
---|
| 37 | |
---|
| 38 | /** フォームパラメーターの配列 */ |
---|
| 39 | var $objFormParam; |
---|
| 40 | |
---|
| 41 | /** 会員情報のインスタンス */ |
---|
| 42 | var $objCustomer; |
---|
| 43 | |
---|
| 44 | // }}} |
---|
| 45 | // {{{ functions |
---|
| 46 | |
---|
| 47 | /** |
---|
| 48 | * Page を初期化する. |
---|
| 49 | * |
---|
| 50 | * @return void |
---|
| 51 | */ |
---|
| 52 | function init() { |
---|
| 53 | parent::init(); |
---|
| 54 | $this->tpl_onload = 'fnCheckInputPoint();'; |
---|
| 55 | $this->tpl_title = 'お支払方法・お届け時間等の指定'; |
---|
| 56 | $masterData = new SC_DB_MasterData(); |
---|
| 57 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /** |
---|
| 61 | * Page のプロセス. |
---|
| 62 | * |
---|
| 63 | * @return void |
---|
| 64 | */ |
---|
| 65 | function process() { |
---|
| 66 | parent::process(); |
---|
| 67 | $this->action(); |
---|
| 68 | $this->sendResponse(); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | /** |
---|
| 72 | * Page のアクション. |
---|
| 73 | * |
---|
| 74 | * @return void |
---|
| 75 | */ |
---|
| 76 | function action() { |
---|
| 77 | // フックポイント. |
---|
| 78 | $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); |
---|
| 79 | $objPlugin->doAction('lc_page_shopping_payment_action_start', array($this)); |
---|
| 80 | |
---|
| 81 | $objSiteSess = new SC_SiteSession_Ex(); |
---|
| 82 | $objCartSess = new SC_CartSession_Ex(); |
---|
| 83 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
| 84 | $objCustomer = new SC_Customer_Ex(); |
---|
| 85 | $objFormParam = new SC_FormParam_Ex(); |
---|
| 86 | |
---|
| 87 | $this->is_multiple = $objPurchase->isMultiple(); |
---|
| 88 | |
---|
| 89 | // カートの情報を取得 |
---|
| 90 | $this->arrShipping = $objPurchase->getShippingTemp($this->is_multiple); |
---|
| 91 | |
---|
| 92 | $this->tpl_uniqid = $objSiteSess->getUniqId(); |
---|
| 93 | $cart_key = $objCartSess->getKey(); |
---|
| 94 | $this->cartKey = $cart_key; |
---|
| 95 | $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess); |
---|
| 96 | |
---|
| 97 | // 配送業者を取得 |
---|
| 98 | $this->arrDeliv = $objPurchase->getDeliv($cart_key); |
---|
| 99 | $this->is_single_deliv = $this->isSingleDeliv($this->arrDeliv); |
---|
| 100 | |
---|
| 101 | // 会員情報の取得 |
---|
| 102 | if ($objCustomer->isLoginSuccess(true)) { |
---|
| 103 | $this->tpl_login = '1'; |
---|
| 104 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
| 105 | $this->name01 = $objCustomer->getValue('name01'); |
---|
| 106 | $this->name02 = $objCustomer->getValue('name02'); |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | // 戻り URL の設定 |
---|
| 110 | $this->tpl_back_url = $this->getPreviousURL($objCustomer->isLoginSuccess(true), $cart_key, $this->is_multiple); |
---|
| 111 | |
---|
| 112 | $arrOrderTemp = $objPurchase->getOrderTemp($this->tpl_uniqid); |
---|
| 113 | // 正常に受注情報が格納されていない場合はカート画面へ戻す |
---|
| 114 | if (SC_Utils_Ex::isBlank($arrOrderTemp)) { |
---|
| 115 | SC_Response_Ex::sendRedirect(CART_URLPATH); |
---|
| 116 | exit; |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | // カート内商品の妥当性チェック |
---|
| 120 | $this->tpl_message = $objCartSess->checkProducts($cart_key); |
---|
| 121 | if (strlen($this->tpl_message) >= 1) { |
---|
| 122 | SC_Response_Ex::sendRedirect(CART_URLPATH); |
---|
| 123 | exit; |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | /* |
---|
| 127 | * 購入金額の取得 |
---|
| 128 | * ここでは送料を加算しない |
---|
| 129 | */ |
---|
| 130 | $this->arrPrices = $objCartSess->calculate($cart_key, $objCustomer); |
---|
| 131 | |
---|
| 132 | // お届け日一覧の取得 |
---|
| 133 | $this->arrDelivDate = $objPurchase->getDelivDate($objCartSess, $cart_key); |
---|
| 134 | |
---|
| 135 | switch ($this->getMode()) { |
---|
| 136 | /* |
---|
| 137 | * 配送業者選択時のアクション |
---|
| 138 | * モバイル端末以外の場合は, JSON 形式のデータを出力し, ajax で取得する. |
---|
| 139 | */ |
---|
| 140 | case 'select_deliv': |
---|
| 141 | $this->setFormParams($objFormParam, $arrOrderTemp, true, $this->arrShipping); |
---|
| 142 | $objFormParam->setParam($_POST); |
---|
| 143 | $this->arrErr = $objFormParam->checkError(); |
---|
| 144 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 145 | $deliv_id = $objFormParam->getValue('deliv_id'); |
---|
| 146 | $arrSelectedDeliv = $this->getSelectedDeliv($objPurchase, $objCartSess, $deliv_id); |
---|
| 147 | $arrSelectedDeliv['error'] = false; |
---|
| 148 | } else { |
---|
| 149 | $arrSelectedDeliv = array('error' => true); |
---|
| 150 | $this->tpl_mainpage = 'shopping/select_deliv.tpl'; // モバイル用 |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | if (SC_Display_Ex::detectDevice() != DEVICE_TYPE_MOBILE) { |
---|
| 154 | // フックポイント. |
---|
| 155 | $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); |
---|
| 156 | $objPlugin->doAction('lc_page_shopping_payment_action_select_deliv', array($this)); |
---|
| 157 | |
---|
| 158 | echo SC_Utils_Ex::jsonEncode($arrSelectedDeliv); |
---|
| 159 | exit; |
---|
| 160 | } else { |
---|
| 161 | $this->arrPayment = $arrSelectedDeliv['arrPayment']; |
---|
| 162 | $this->arrDelivTime = $arrSelectedDeliv['arrDelivTime']; |
---|
| 163 | } |
---|
| 164 | break; |
---|
| 165 | |
---|
| 166 | // 登録処理 |
---|
| 167 | case 'confirm': |
---|
| 168 | // パラメーター情報の初期化 |
---|
| 169 | $this->setFormParams($objFormParam, $_POST, false, $this->arrShipping); |
---|
| 170 | |
---|
| 171 | $deliv_id = $objFormParam->getValue('deliv_id'); |
---|
| 172 | $arrSelectedDeliv = $this->getSelectedDeliv($objPurchase, $objCartSess, $deliv_id); |
---|
| 173 | $this->arrPayment = $arrSelectedDeliv['arrPayment']; |
---|
| 174 | $this->arrDelivTime = $arrSelectedDeliv['arrDelivTime']; |
---|
| 175 | |
---|
| 176 | $this->arrErr = $this->lfCheckError($objFormParam, $this->arrPrices['subtotal'], $this->tpl_user_point); |
---|
| 177 | |
---|
| 178 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 179 | $this->saveShippings($objFormParam, $this->arrDelivTime); |
---|
| 180 | $this->lfRegistData($this->tpl_uniqid, $objFormParam->getDbArray(), $objPurchase, $this->arrPayment); |
---|
| 181 | |
---|
| 182 | // 正常に登録されたことを記録しておく |
---|
| 183 | $objSiteSess->setRegistFlag(); |
---|
| 184 | |
---|
| 185 | // フックポイント. |
---|
| 186 | $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); |
---|
| 187 | $objPlugin->doAction('lc_page_shopping_payment_action_confirm', array($this)); |
---|
| 188 | |
---|
| 189 | // 確認ページへ移動 |
---|
| 190 | SC_Response_Ex::sendRedirect(SHOPPING_CONFIRM_URLPATH); |
---|
| 191 | exit; |
---|
| 192 | } else { |
---|
| 193 | // 受注一時テーブルからの情報を格納 |
---|
| 194 | $this->img_show = $arrSelectedDeliv['img_show']; |
---|
| 195 | $objFormParam->setParam($objPurchase->getOrderTemp($this->tpl_uniqid)); |
---|
| 196 | } |
---|
| 197 | break; |
---|
| 198 | |
---|
| 199 | // 前のページに戻る |
---|
| 200 | case 'return': |
---|
| 201 | |
---|
| 202 | // 正常な推移であることを記録しておく |
---|
| 203 | $objSiteSess->setRegistFlag(); |
---|
| 204 | |
---|
| 205 | // フックポイント. |
---|
| 206 | $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); |
---|
| 207 | $objPlugin->doAction('lc_page_shopping_payment_action_return', array($this)); |
---|
| 208 | |
---|
| 209 | SC_Response_Ex::sendRedirect(SHOPPING_URL); |
---|
| 210 | exit; |
---|
| 211 | break; |
---|
| 212 | |
---|
| 213 | default: |
---|
| 214 | // FIXME 前のページから戻ってきた場合は別パラメーター(mode)で処理分岐する必要があるのかもしれない |
---|
| 215 | $this->setFormParams($objFormParam, $arrOrderTemp, false, $this->arrShipping); |
---|
| 216 | |
---|
| 217 | if (!$this->is_single_deliv) { |
---|
| 218 | $deliv_id = $objFormParam->getValue('deliv_id'); |
---|
| 219 | } else { |
---|
| 220 | $deliv_id = $this->arrDeliv[0]['deliv_id']; |
---|
| 221 | } |
---|
| 222 | |
---|
| 223 | if (!SC_Utils_Ex::isBlank($deliv_id)) { |
---|
| 224 | $objFormParam->setValue('deliv_id', $deliv_id); |
---|
| 225 | $arrSelectedDeliv = $this->getSelectedDeliv($objPurchase, $objCartSess, $deliv_id); |
---|
| 226 | $this->arrPayment = $arrSelectedDeliv['arrPayment']; |
---|
| 227 | $this->arrDelivTime = $arrSelectedDeliv['arrDelivTime']; |
---|
| 228 | $this->img_show = $arrSelectedDeliv['img_show']; |
---|
| 229 | } |
---|
| 230 | break; |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | // モバイル用 ポストバック処理 |
---|
| 234 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE |
---|
| 235 | && SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 236 | $this->tpl_mainpage = $this->getMobileMainpage($this->is_single_deliv, $this->getMode()); |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
| 240 | |
---|
| 241 | // フックポイント. |
---|
| 242 | $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); |
---|
| 243 | $objPlugin->doAction('lc_page_shopping_payment_end', array($this)); |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | /** |
---|
| 247 | * デストラクタ. |
---|
| 248 | * |
---|
| 249 | * @return void |
---|
| 250 | */ |
---|
| 251 | function destroy() { |
---|
| 252 | parent::destroy(); |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | /** |
---|
| 256 | * パラメーターの初期化を行い, 初期値を設定する. |
---|
| 257 | * |
---|
| 258 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 259 | * @param array $arrParam 設定する値の配列 |
---|
| 260 | * @param boolean $deliv_only deliv_id チェックのみの場合 true |
---|
| 261 | * @param array $arrShipping 配送先情報の配列 |
---|
| 262 | */ |
---|
| 263 | function setFormParams(&$objFormParam, $arrParam, $deliv_only, &$arrShipping) { |
---|
| 264 | $this->lfInitParam($objFormParam, $deliv_only, $arrShipping); |
---|
| 265 | $objFormParam->setParam($arrParam); |
---|
| 266 | $objFormParam->convParam(); |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | /** |
---|
| 270 | * パラメーター情報の初期化を行う. |
---|
| 271 | * |
---|
| 272 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 273 | * @param boolean $deliv_only 必須チェックは deliv_id のみの場合 true |
---|
| 274 | * @param array $arrShipping 配送先情報の配列 |
---|
| 275 | * @return void |
---|
| 276 | */ |
---|
| 277 | function lfInitParam(&$objFormParam, $deliv_only, &$arrShipping) { |
---|
| 278 | $objFormParam->addParam('配送業者', 'deliv_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 279 | $objFormParam->addParam('ポイント', 'use_point', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK', 'ZERO_START')); |
---|
| 280 | $objFormParam->addParam('その他お問い合わせ', 'message', LTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 281 | $objFormParam->addParam('ポイントを使用する', 'point_check', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '2'); |
---|
| 282 | |
---|
| 283 | if ($deliv_only) { |
---|
| 284 | $objFormParam->addParam('お支払い方法', 'payment_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 285 | } else { |
---|
| 286 | $objFormParam->addParam('お支払い方法', 'payment_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 287 | |
---|
| 288 | foreach ($arrShipping as $val) { |
---|
| 289 | $objFormParam->addParam('お届け時間', 'deliv_time_id' . $val['shipping_id'], INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 290 | $objFormParam->addParam('お届け日', 'deliv_date' . $val['shipping_id'], STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); |
---|
| 291 | } |
---|
| 292 | } |
---|
| 293 | |
---|
| 294 | $objFormParam->setParam($arrParam); |
---|
| 295 | $objFormParam->convParam(); |
---|
| 296 | } |
---|
| 297 | |
---|
| 298 | /** |
---|
| 299 | * 入力内容のチェックを行なう. |
---|
| 300 | * |
---|
| 301 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 302 | * @param integer $subtotal 購入金額の小計 |
---|
| 303 | * @param integer $max_point 会員の保持ポイント |
---|
| 304 | * @return array 入力チェック結果の配列 |
---|
| 305 | */ |
---|
| 306 | function lfCheckError(&$objFormParam, $subtotal, $max_point) { |
---|
| 307 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
| 308 | // 入力データを渡す。 |
---|
| 309 | $arrForm = $objFormParam->getHashArray(); |
---|
| 310 | $objErr = new SC_CheckError_Ex($arrForm); |
---|
| 311 | $objErr->arrErr = $objFormParam->checkError(); |
---|
| 312 | |
---|
| 313 | if (USE_POINT === false) { |
---|
| 314 | return $objErr->arrErr; |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | if ($arrForm['point_check'] == '1') { |
---|
| 318 | $objErr->doFunc(array('ポイントを使用する', 'point_check'), array('EXIST_CHECK')); |
---|
| 319 | $objErr->doFunc(array('ポイント', 'use_point'), array('EXIST_CHECK')); |
---|
| 320 | if ($max_point == '') { |
---|
| 321 | $max_point = 0; |
---|
| 322 | } |
---|
| 323 | // FIXME mobile 互換のため br は閉じない... |
---|
| 324 | if ($arrForm['use_point'] > $max_point) { |
---|
| 325 | $objErr->arrErr['use_point'] = '※ ご利用ポイントが所持ポイントを超えています。<br>'; |
---|
| 326 | } |
---|
| 327 | if (($arrForm['use_point'] * POINT_VALUE) > $subtotal) { |
---|
| 328 | $objErr->arrErr['use_point'] = '※ ご利用ポイントがご購入金額を超えています。<br>'; |
---|
| 329 | } |
---|
| 330 | // ポイント差し引き後の決済方法チェック |
---|
| 331 | $arrPayments = $objPurchase->getPaymentsByPaymentsId($arrForm['payment_id']); |
---|
| 332 | if ($arrPayments['rule'] > $subtotal - $arrForm['use_point'] * POINT_VALUE){ |
---|
| 333 | $objErr->arrErr['use_point'] = '※ 選択した支払方法では、ポイントは'.($subtotal - $arrPayments['rule']).'ポイントまでご利用いただけます。<br>'; |
---|
| 334 | } |
---|
| 335 | |
---|
| 336 | } |
---|
| 337 | return $objErr->arrErr; |
---|
| 338 | } |
---|
| 339 | |
---|
| 340 | /** |
---|
| 341 | * 配送情報を保存する. |
---|
| 342 | * |
---|
| 343 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 344 | * @param array $arrDelivTime 配送時間の配列 |
---|
| 345 | */ |
---|
| 346 | function saveShippings(&$objFormParam, $arrDelivTime) { |
---|
| 347 | $deliv_id = $objFormParam->getValue('deliv_id'); |
---|
| 348 | |
---|
| 349 | /* TODO |
---|
| 350 | * SC_Purchase::getShippingTemp() で取得して, |
---|
| 351 | * リファレンスで代入すると, セッションに添字を追加できない? |
---|
| 352 | */ |
---|
| 353 | foreach (array_keys($_SESSION['shipping']) as $key) { |
---|
| 354 | $shipping_id = $_SESSION['shipping'][$key]['shipping_id']; |
---|
| 355 | $time_id = $objFormParam->getValue('deliv_time_id' . $shipping_id); |
---|
| 356 | $_SESSION['shipping'][$key]['deliv_id'] = $deliv_id; |
---|
| 357 | $_SESSION['shipping'][$key]['time_id'] = $time_id; |
---|
| 358 | $_SESSION['shipping'][$key]['shipping_time'] = $arrDelivTime[$time_id]; |
---|
| 359 | $_SESSION['shipping'][$key]['shipping_date'] = $objFormParam->getValue('deliv_date' . $shipping_id); |
---|
| 360 | } |
---|
| 361 | } |
---|
| 362 | |
---|
| 363 | /** |
---|
| 364 | * 受注一時テーブルへ登録を行う. |
---|
| 365 | * |
---|
| 366 | * @param integer $uniqid 受注一時テーブルのユニークID |
---|
| 367 | * @param array $arrForm フォームの入力値 |
---|
| 368 | * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス |
---|
| 369 | * @param array $arrPayment お支払い方法の配列 |
---|
| 370 | * @return void |
---|
| 371 | */ |
---|
| 372 | function lfRegistData($uniqid, $arrForm, &$objPurchase, $arrPayment) { |
---|
| 373 | |
---|
| 374 | $arrForm['order_temp_id'] = $uniqid; |
---|
| 375 | $arrForm['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
| 376 | |
---|
| 377 | if ($arrForm['point_check'] != '1') { |
---|
| 378 | $arrForm['use_point'] = 0; |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | foreach ($arrPayment as $payment) { |
---|
| 382 | if ($arrForm['payment_id'] == $payment['payment_id']) { |
---|
| 383 | $arrForm['charge'] = $payment['charge']; |
---|
| 384 | $arrForm['payment_method'] = $payment['payment_method']; |
---|
| 385 | break; |
---|
| 386 | } |
---|
| 387 | } |
---|
| 388 | $objPurchase->saveOrderTemp($uniqid, $arrForm); |
---|
| 389 | } |
---|
| 390 | |
---|
| 391 | /** |
---|
| 392 | * 配送業者IDから, 支払い方法, お届け時間の配列を取得する. |
---|
| 393 | * |
---|
| 394 | * 結果の連想配列の添字の値は以下の通り |
---|
| 395 | * - 'arrDelivTime' - お届け時間の配列 |
---|
| 396 | * - 'arrPayment' - 支払い方法の配列 |
---|
| 397 | * - 'img_show' - 支払い方法の画像の有無 |
---|
| 398 | * |
---|
| 399 | * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス |
---|
| 400 | * @param SC_CartSession $objCartSess SC_CartSession インスタンス |
---|
| 401 | * @param integer $deliv_id 配送業者ID |
---|
| 402 | * @return array 支払い方法, お届け時間を格納した配列 |
---|
| 403 | */ |
---|
| 404 | function getSelectedDeliv(&$objPurchase, &$objCartSess, $deliv_id) { |
---|
| 405 | $arrResults = array(); |
---|
| 406 | $arrResults['arrDelivTime'] = $objPurchase->getDelivTime($deliv_id); |
---|
| 407 | $total = $objCartSess->getAllProductsTotal($objCartSess->getKey(), $deliv_id); |
---|
| 408 | $arrResults['arrPayment'] = $objPurchase->getPaymentsByPrice($total, $deliv_id); |
---|
| 409 | $arrResults['img_show'] = $this->hasPaymentImage($arrResults['arrPayment']); |
---|
| 410 | return $arrResults; |
---|
| 411 | } |
---|
| 412 | |
---|
| 413 | /** |
---|
| 414 | * 支払い方法の画像があるかどうか. |
---|
| 415 | * |
---|
| 416 | * @param array $arrPayment 支払い方法の配列 |
---|
| 417 | * @return boolean 支払い方法の画像がある場合 true |
---|
| 418 | */ |
---|
| 419 | function hasPaymentImage($arrPayment) { |
---|
| 420 | foreach ($arrPayment as $val) { |
---|
| 421 | if (!SC_Utils_Ex::isBlank($val['payment_image'])) { |
---|
| 422 | return true; |
---|
| 423 | } |
---|
| 424 | } |
---|
| 425 | return false; |
---|
| 426 | } |
---|
| 427 | |
---|
| 428 | /** |
---|
| 429 | * 配送業者が1社のみかどうか. |
---|
| 430 | * |
---|
| 431 | * @param array $arrDeliv 配送業者の配列 |
---|
| 432 | * @return boolean 配送業者が1社のみの場合 true |
---|
| 433 | */ |
---|
| 434 | function isSingleDeliv($arrDeliv) { |
---|
| 435 | if (count($arrDeliv) == 1) { |
---|
| 436 | return true; |
---|
| 437 | } else { |
---|
| 438 | return false; |
---|
| 439 | } |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | /** |
---|
| 443 | * 前に戻るボタンの URL を取得する. |
---|
| 444 | * |
---|
| 445 | * @param boolean $is_login ユーザーがログインしている場合 true |
---|
| 446 | * @param integer $product_type_id 商品種別ID |
---|
| 447 | * @param boolean $is_multiple 複数配送の場合 true |
---|
| 448 | * @return string 前に戻るボタンの URL |
---|
| 449 | */ |
---|
| 450 | function getPreviousURL($is_login = false, $product_type_id, $is_multiple) { |
---|
| 451 | if ($is_multiple) { |
---|
| 452 | return MULTIPLE_URLPATH . '?from=multiple'; |
---|
| 453 | } |
---|
| 454 | if ($is_login) { |
---|
| 455 | if ($product_type_id == PRODUCT_TYPE_DOWNLOAD) { |
---|
| 456 | return CART_URLPATH; |
---|
| 457 | } else { |
---|
| 458 | return DELIV_URLPATH; |
---|
| 459 | } |
---|
| 460 | } else { |
---|
| 461 | return SHOPPING_URL . '?from=nonmember'; |
---|
| 462 | } |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | /** |
---|
| 466 | * モバイル用テンプレートのパスを取得する. |
---|
| 467 | * |
---|
| 468 | * @param boolean $is_single_deliv 配送業者が1社の場合 true |
---|
| 469 | * @param string $mode フォームパラメーター 'mode' の文字列 |
---|
| 470 | * @return string モバイル用テンプレートのパス |
---|
| 471 | */ |
---|
| 472 | function getMobileMainpage($is_single_deliv = true, $mode) { |
---|
| 473 | switch ($mode) { |
---|
| 474 | case 'select_deliv': |
---|
| 475 | return 'shopping/payment.tpl'; |
---|
| 476 | |
---|
| 477 | case 'confirm': |
---|
| 478 | case 'return': |
---|
| 479 | default: |
---|
| 480 | if ($is_single_deliv) { |
---|
| 481 | return 'shopping/payment.tpl'; |
---|
| 482 | } else { |
---|
| 483 | return 'shopping/select_deliv.tpl'; |
---|
| 484 | } |
---|
| 485 | break; |
---|
| 486 | } |
---|
| 487 | } |
---|
| 488 | } |
---|