Source for file LC_Page_Shopping_Payment.php
Documentation is available at LC_Page_Shopping_Payment.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Shopping_Payment.php 21185 2011-08-11 10:37:10Z shutta $
$this->tpl_onload = "fnCheckInputPoint();";
$this->tpl_title = "お支払方法・お届け時間等の指定";
$this->arrPref = $masterData->getMasterData('mtb_pref');
$objSiteSess = new SC_SiteSession_Ex();
$objCartSess = new SC_CartSession_Ex();
$objPurchase = new SC_Helper_Purchase_Ex();
$objCustomer = new SC_Customer_Ex();
$objFormParam = new SC_FormParam_Ex();
$this->is_multiple = $objPurchase->isMultiple();
$this->arrShipping = $objPurchase->getShippingTemp($this->is_multiple);
$this->tpl_uniqid = $objSiteSess->getUniqId();
$cart_key = $objCartSess->getKey();
$this->cartKey = $cart_key;
$objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);
$this->arrDeliv = $objPurchase->getDeliv($cart_key);
if ($objCustomer->isLoginSuccess(true)) {
$this->tpl_user_point = $objCustomer->getValue('point');
$this->name01 = $objCustomer->getValue('name01');
$this->name02 = $objCustomer->getValue('name02');
$this->tpl_back_url = $this->getPreviousURL($objCustomer->isLoginSuccess(true), $cart_key, $this->is_multiple);
$arrOrderTemp = $objPurchase->getOrderTemp($this->tpl_uniqid);
// 正常に受注情報が格納されていない場合はカート画面へ戻す
if (SC_Utils_Ex::isBlank($arrOrderTemp)) {
SC_Response_Ex::sendRedirect(CART_URLPATH);
$this->tpl_message = $objCartSess->checkProducts($cart_key);
if (strlen($this->tpl_message) >= 1) {
SC_Response_Ex::sendRedirect(CART_URLPATH);
$this->arrPrices = $objCartSess->calculate($cart_key, $objCustomer);
$this->arrDelivDate = $objPurchase->getDelivDate($objCartSess, $cart_key);
switch($this->getMode()) {
* モバイル端末以外の場合は, JSON 形式のデータを出力し, ajax で取得する.
$this->setFormParams($objFormParam, $arrOrderTemp, true, $this->arrShipping);
$objFormParam->setParam($_POST);
$this->arrErr = $objFormParam->checkError();
if (SC_Utils_Ex::isBlank($this->arrErr)) {
$deliv_id = $objFormParam->getValue('deliv_id');
$arrSelectedDeliv = $this->getSelectedDeliv($objPurchase, $objCartSess, $deliv_id);
$arrSelectedDeliv['error'] = false;
$arrSelectedDeliv = array('error' => true);
$this->tpl_mainpage = 'shopping/select_deliv.tpl'; // モバイル用
if (SC_Display_Ex::detectDevice() != DEVICE_TYPE_MOBILE) {
echo SC_Utils_Ex::jsonEncode($arrSelectedDeliv);
$this->arrPayment = $arrSelectedDeliv['arrPayment'];
$this->arrDelivTime = $arrSelectedDeliv['arrDelivTime'];
$this->setFormParams($objFormParam, $_POST, false, $this->arrShipping);
$deliv_id = $objFormParam->getValue('deliv_id');
$arrSelectedDeliv = $this->getSelectedDeliv($objPurchase, $objCartSess, $deliv_id);
$this->arrPayment = $arrSelectedDeliv['arrPayment'];
$this->arrDelivTime = $arrSelectedDeliv['arrDelivTime'];
$this->arrErr = $this->lfCheckError($objFormParam, $this->arrPrices['subtotal'], $this->tpl_user_point);
if (SC_Utils_Ex::isBlank($this->arrErr)) {
$this->lfRegistData($this->tpl_uniqid, $objFormParam->getDbArray(), $objPurchase, $this->arrPayment);
$objSiteSess->setRegistFlag();
SC_Response_Ex::sendRedirect(SHOPPING_CONFIRM_URLPATH);
$this->img_show = $arrSelectedDeliv['img_show'];
$objFormParam->setParam($objPurchase->getOrderTemp($this->tpl_uniqid));
$objSiteSess->setRegistFlag();
SC_Response_Ex::sendRedirect(SHOPPING_URL);
// FIXME 前のページから戻ってきた場合は別パラメーター(mode)で処理分岐する必要があるのかもしれない
$this->setFormParams($objFormParam, $arrOrderTemp, false, $this->arrShipping);
if (!$this->is_single_deliv) {
$deliv_id = $objFormParam->getValue('deliv_id');
$deliv_id = $this->arrDeliv[0]['deliv_id'];
if (!SC_Utils_Ex::isBlank($deliv_id)) {
$objFormParam->setValue('deliv_id', $deliv_id);
$arrSelectedDeliv = $this->getSelectedDeliv($objPurchase, $objCartSess, $deliv_id);
$this->arrPayment = $arrSelectedDeliv['arrPayment'];
$this->arrDelivTime = $arrSelectedDeliv['arrDelivTime'];
$this->img_show = $arrSelectedDeliv['img_show'];
if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE
&& SC_Utils_Ex::isBlank($this->arrErr)) {
$this->tpl_mainpage = $this->getMobileMainpage($this->is_single_deliv, $this->getMode());
$this->arrForm = $objFormParam->getFormParamList();
* パラメーターの初期化を行い, 初期値を設定する.
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
* @param array $arrParam 設定する値の配列
* @param boolean $deliv_only deliv_id チェックのみの場合 true
* @param array $arrShipping 配送先情報の配列
function setFormParams(&$objFormParam, $arrParam, $deliv_only, &$arrShipping) {
$this->lfInitParam($objFormParam, $deliv_only, $arrShipping);
$objFormParam->setParam($arrParam);
$objFormParam->convParam();
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
* @param boolean $deliv_only 必須チェックは deliv_id のみの場合 true
* @param array $arrShipping 配送先情報の配列
function lfInitParam(&$objFormParam, $deliv_only, &$arrShipping) {
$objFormParam->addParam("配送業者", "deliv_id", INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("ポイント", "use_point", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK", "ZERO_START"));
$objFormParam->addParam("その他お問い合わせ", 'message', LTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("ポイントを使用する", "point_check", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"), '2');
$objFormParam->addParam("お支払い方法", "payment_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("お支払い方法", "payment_id", INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
foreach ($arrShipping as $val) {
$objFormParam->addParam("お届け時間", "deliv_time_id" . $val['shipping_id'], INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("お届け日", "deliv_date" . $val['shipping_id'], STEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK"));
$objFormParam->setParam($arrParam);
$objFormParam->convParam();
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
* @param integer $subtotal 購入金額の小計
* @param integer $max_point 会員の保持ポイント
* @return array 入力チェック結果の配列
function lfCheckError(&$objFormParam, $subtotal, $max_point) {
$arrForm = $objFormParam->getHashArray();
$objErr = new SC_CheckError_Ex($arrForm);
$objErr->arrErr = $objFormParam->checkError();
if (USE_POINT === false) {
if($arrForm['point_check'] == '1') {
$objErr->doFunc(array("ポイントを使用する", "point_check"), array("EXIST_CHECK"));
$objErr->doFunc(array("ポイント", "use_point"), array("EXIST_CHECK"));
// FIXME mobile 互換のため br は閉じない...
if($arrForm['use_point'] > $max_point) {
$objErr->arrErr['use_point'] = "※ ご利用ポイントが所持ポイントを超えています。<br>";
if(($arrForm['use_point'] * POINT_VALUE) > $subtotal) {
$objErr->arrErr['use_point'] = "※ ご利用ポイントがご購入金額を超えています。<br>";
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
* @param array $arrDelivTime 配送時間の配列
$deliv_id = $objFormParam->getValue('deliv_id');
* SC_Purchase::getShippingTemp() で取得して,
* リファレンスで代入すると, セッションに添字を追加できない?
foreach (array_keys($_SESSION['shipping']) as $key) {
$shipping_id = $_SESSION['shipping'][$key]['shipping_id'];
$time_id = $objFormParam->getValue('deliv_time_id' . $shipping_id);
$_SESSION['shipping'][$key]['deliv_id'] = $deliv_id;
$_SESSION['shipping'][$key]['time_id'] = $time_id;
$_SESSION['shipping'][$key]['shipping_time'] = $arrDelivTime[$time_id];
$_SESSION['shipping'][$key]['shipping_date'] = $objFormParam->getValue('deliv_date' . $shipping_id);
* @param integer $uniqid 受注一時テーブルのユニークID
* @param array $arrForm フォームの入力値
* @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
* @param array $arrPayment お支払い方法の配列
function lfRegistData($uniqid, $arrForm, &$objPurchase, $arrPayment) {
$arrForm['order_temp_id'] = $uniqid;
$arrForm['update_date'] = 'CURRENT_TIMESTAMP';
if($arrForm['point_check'] != '1') {
$arrForm['use_point'] = 0;
foreach ($arrPayment as $payment) {
if ($arrForm['payment_id'] == $payment['payment_id']) {
$arrForm['charge'] = $payment['charge'];
$arrForm['payment_method'] = $payment['payment_method'];
$objPurchase->saveOrderTemp($uniqid, $arrForm);
* 配送業者IDから, 支払い方法, お届け時間の配列を取得する.
* - 'arrDelivTime' - お届け時間の配列
* - 'arrPayment' - 支払い方法の配列
* - 'img_show' - 支払い方法の画像の有無
* @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
* @param SC_CartSession $objCartSess SC_CartSession インスタンス
* @param integer $deliv_id 配送業者ID
* @return array 支払い方法, お届け時間を格納した配列
$arrResults['arrDelivTime'] = $objPurchase->getDelivTime($deliv_id);
$total = $objCartSess->getAllProductsTotal($objCartSess->getKey(),
$arrResults['arrPayment'] = $objPurchase->getPaymentsByPrice($total,
$arrResults['img_show'] = $this->hasPaymentImage($arrResults['arrPayment']);
* @param array $arrPayment 支払い方法の配列
* @return boolean 支払い方法の画像がある場合 true
foreach ($arrPayment as $val) {
if (!SC_Utils_Ex::isBlank($val['payment_image'])) {
* @param array $arrDeliv 配送業者の配列
* @return boolean 配送業者が1社のみの場合 true
if (count($arrDeliv) == 1) {
* @param boolean $is_login ユーザーがログインしている場合 true
* @param integer $product_type_id 商品種別ID
* @param boolean $is_multiple 複数配送の場合 true
* @return string 前に戻るボタンの URL
function getPreviousURL($is_login = false, $product_type_id, $is_multiple) {
return MULTIPLE_URLPATH . '?from=multiple';
if ($product_type_id == PRODUCT_TYPE_DOWNLOAD) {
return SHOPPING_URL . "?from=nonmember";
* @param boolean $is_single_deliv 配送業者が1社の場合 true
* @param string $mode フォームパラメーター 'mode' の文字列
* @return string モバイル用テンプレートのパス
return 'shopping/payment.tpl';
return 'shopping/payment.tpl';
return 'shopping/select_deliv.tpl';
Documentation generated on Fri, 24 Feb 2012 14:02:20 +0900 by Seasoft
|