EC-CUBE EC-CUBEのカスタマイズ・制作会社 強いネットショップ構築します|EC-Orange

EC-Orange とは

EC-CUBE カスタマイズ

EC-CUBEインストール

EC-CUBE 環境構築ノウハウ

EC-CUBE 基本構成理解

ソースコード読解

EC-CUBE カスタマイズ:初歩

EC-CUBE カスタマイズ:基礎

EC-CUBE カスタマイズ:応用

EC-CUBE 機能拡張ノウハウ

EC-CUBE カスタマイズ    お問い合わせ返信機能をカスタマイズ

    EC-CUBE カスタマイズ  >  EC-CUBE カスタマイズ:応用  >  お問い合わせ返信機能 (Confirmed with Ver.2.4!)

カスタマイズ:応用/お問い合わせ返信機能 (Confirmed with Ver.2.4!)

お問い合わせ機能[2.4対応]で作成した、お問合わせ機能では、閲覧は可能ですが、返信はメーラーから行わなければなりません。
そこで、返信機能までを持たせたEC-CUBEお問合わせ機能へとカスタマイズします。

    システム開発でお悩みの方は、ネットショップ構築パッケージ EC-Orange にお問い合わせください


動作確認

ver.2.4.0rc2

メールテンプレートの作成

まず問合わせ返信用のテンプレートを作成します。
「管理画面」-「システム設定」-「マスタデータ管理」画面で「mtb_mail_template」を選択してください。
そして「ID:101」と「値:問合わせ返信」として新しいメールテンプレートを登録します。
次に「管理画面」-「基本情報管理」-「メール設定」画面で「問合わせ返信」を選択し、お好みの内容で登録してください。

テーブルの作成

返信メールの内容を保存するためのテーブルを新たに作ります。
以下に示すSQLを発行してEC-CUBE用データベース内に"dtd_contact_reply"というテーブルを作成してください。

CREATE TABLE dtb_contact_reply (
    
mail_id serial NOT NULL,
    
contact_id integer,
    
email text,
    
title text,
    
content text,
    
create_date timestamp without time zone,
    
del_flg integer DEFAULT 0
);

ALTER TABLE ONLY dtb_contact_reply ADD CONSTRAINT dtb_contact_reply_mail_id_key UNIQUE (mail_id);

ファイルの作成

返信フォームのためのファイルを作成します。

[EC-CUBE root]/html/admin/customer/contact_reply.php
[EC-CUBE root]/data/class/pages/admin/customer/LC_Page_Admin_Customer_Contact_Reply.php
[EC-CUBE root]/data/Smarty/templates/default/admin/customer/contact_reply.tpl

  • contact_reply.php
<?php
require_once("../require.php");
require_once(CLASS_PATH . "pages/admin/customer/LC_Page_Admin_Customer_Contact_Reply.php");

$objPage = new LC_Page_Admin_Customer_Contact_Reply();
register_shutdown_function(array($objPage, "destroy"));
$objPage->init();
$objPage->process();
?>

  • LC_Page_Admin_Customer_Contact_Reply.php
<?php
require_once(CLASS_PATH . "pages/LC_Page.php");

class SC_Query_Ex extends SC_Query {
    
function unsetorder() {
        
$this->order = "";
    
}
}

class LC_Page_Admin_Customer_Contact_Reply extends LC_Page {
    
function init() {
        
parent::init();
        
$this->tpl_mainpage = 'customer/contact_reply.tpl';
        
$this->tpl_mainno = 'customer';
        
$this->tpl_subnavi = 'customer/subnavi.tpl';
        
$this->tpl_subno = 'contact';
        
$this->tpl_subtitle = 'お問合せ返信';
        
        
// メールテンプレート一覧
        
$masterData = new SC_DB_MasterData_Ex();
        
$this->arrMailTemplate = $masterData->getMasterData("mtb_mail_template");
        
$this->mailTemplateId = "101";
    
}
    
    
function process() {
        
// 認証判定
        
$objSess = new SC_Session();
        
SC_Utils_Ex::sfIsSuccess($objSess);
        
        
// contact_idの取得
        
if(isset($_GET['contact_id']) && SC_Utils_Ex::sfIsInt($_GET['contact_id'])) {
            
$this->contact_id = $_GET['contact_id'];
        
} elseif(isset($_POST['contact_id']) && SC_Utils_Ex::sfIsInt($_POST['contact_id'])) {
            
$this->contact_id = $_POST['contact_id'];
        
}
        
        
$objQuery = new SC_Query_Ex();
        
        
// お問合せ内容の取得
        
$this->contact_data = $objQuery->select("*", "dtb_contact", "contact_id=?", array($this->contact_id));
        
        
// modeの判定
        
if(isset($_POST['mode'])) {
            
if($_POST['mode']=="send") {
                
$this->arrForm = $_POST;
                
                
// 入力値のチェック
                
// ①文字列変換
                
/*
                 *  文字列の変換
                 *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
                 *  C :  「全角ひら仮名」を「全角かた仮名」に変換
                 *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
                 *  n :  「全角」数字を「半角(ハンカク)」に変換
                 *  a :  「全角」英数字を「半角」に
                
*/
                
$arrConvList['contact_id'] = "n";
                
$arrConvList['title']      = "KV";
                
$arrConvList['content']    = "KV";
                
foreach ($arrConvList as $key => $val) {
                    
$this->arrForm[$key] = mb_convert_kana($this->arrForm[$key] ,$val);
                
}
                
// ②値チェック
                
$objErr = new SC_CheckError($this->arrForm);
                
$objErr->doFunc(array("タイトル", 'title', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
                
$objErr->doFunc(array("本文", 'content', LTEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
                
$this->arrErr = $objErr->arrErr;
                
if(!$this->arrErr) {
                    
// メール送信
                    
$objSiteInfo = new SC_SiteInfo();
                    
// $objSiteInfo["email01"]:"商品注文受付メールアドレス"
                    
// $objSiteInfo["email02"]:"問い合わせ受付メールアドレス"
                    
// $objSiteInfo["email03"]:"メール送信元メールアドレス"
                    
// $objSiteInfo["email04"]:"送信エラー受付メールアドレス"
                    
$arrInfo = $objSiteInfo->data;
                    
$objSendMail = new SC_SendMail_Ex();
                    
                    
$to          = $this->contact_data[0]['email'];
                    
$subject     = $_POST['title'];
                    
$body        = $_POST['content'];
                    
$fromaddress = $arrInfo['email03'];
                    
$from_name   = $arrInfo['shop_name'];
                    
$reply_to    = $arrInfo['email02'];
                    
$return_path = $arrInfo['email04'];
                    
$errors_to   = $arrInfo['email04'];
                    
$bcc         = $arrInfo['email02'];
                    
$objSendMail->setItem($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc);
                    
$objSendMail->setTo($to, $arrInfo["name"] . $arrInfo["name_f"] . "");
                    
$objSendMail->sendMail();
                    
                    
// メール保存
                    
$sqlval['contact_id']  = $this->contact_id;
                    
$sqlval['email']       = $this->contact_data[0]['email'];
                    
$sqlval['title']       = $_POST['title'];
                    
$sqlval['content']     = $_POST['content'];
                    
$sqlval['content']     = $_POST['content'];
                    
$sqlval['create_date'] = 'NOW()';
                    
$objQuery->begin();
                    
$objQuery->insert("dtb_contact_reply", $sqlval);
                    
$objQuery->commit();
                
}
            
} elseif($_POST['mode']=="template" && SC_Utils_Ex::sfIsInt($_POST['template_id'])) {
                
$this->mailTemplateId = $_POST['template_id'];
            
}
        
}
        
        
// メールテンプレート内容取得
        
$objQuery->unsetorder();
        
$this->mail_template = $objQuery->select("subject, header, footer", "dtb_mailtemplate", "template_id=?", array($this->mailTemplateId));
        
        
// GETから(初めてのページ表示時)またはテンプレート変更時は$arrFormと$arrErrを用意
        
if(isset($_GET['contact_id']) || $_POST['mode']=="template") {
            
$this->arrForm['title']   = $this->mail_template[0]['subject'];
            
$this->arrForm['content'] = $this->contact_data[0]['name'] . $this->contact_data[0]['name_f'] . '

' . $this->mail_template[0]['header'] . '



' . $this->mail_template[0]['footer'];
            
$this->arrErr['title'] = '';
            
$this->arrErr['content'] = '';
        
}
        
        
// 返信一覧の取得
        
$objQuery->setorder("create_date DESC");
        
$this->arrReply = $objQuery->select("*", "dtb_contact_reply", "contact_id = ?", array($this->contact_id));
        
        
$objView = new SC_AdminView();
        
$objView->assignobj($this);
        
$objView->display(MAIN_FRAME);
    
}
}
?>

  • contact_reply.tpl
<script type="text/javascript">
<
!--

function confirm_send() {
    
res = confirm('この内容で送信しますか?');
    
if(res) {
        
document.form1.mode.value = 'send';
        
document.form1.submit();
    
}
    
return false;
}

//-->
<
/script>

<
form name="form1" id="form1" method="post" action="<!--{$smarty.server.PHP_SELF|escape}-->">
    <
input type="hidden" name="mode" value="">
    <
input type="hidden" name="contact_id" value="<!--{$contact_id}-->">
    <
table width="878" border="0" cellspacing="0" cellpadding="0">
        <
tr valign="top">
            <
td background="<!--{$TPL_DIR}-->img/contents/navi_bg.gif" height="402">
                <
!--{include file=$tpl_subnavi}-->
            <
/td>
            <
td class="mainbg">
                <
table width="737" border="0" cellspacing="0" cellpadding="0">
                    <
tr>
                        <
td align="center">
                            <
table width="706" border="0" cellspacing="0" cellpadding="0">
                                <
tr>
                                    <
td colspan="3" height="14"></td>
                                <
/tr>
                                <
tr>
                                    <
td colspan="3">
                                        <
img src="<!--{$TPL_DIR}-->img/contents/main_top.jpg" width="706" height="14" alt="">
                                    <
/td>
                                <
/tr>
                                <
tr>
                                    <
td background="<!--{$TPL_DIR}-->img/contents/main_left.jpg">
                                        <
img src="<!--{$TPL_DIR}-->img/common/_.gif" width="14" height="1" alt="">
                                    <
/td>
                                    <
td bgcolor="#cccccc">
                                        <
table width="678" border="0" cellspacing="0" cellpadding="0">
                                            <
tr>
                                                <
td colspan="3">
                                                    <
img src="<!--{$TPL_DIR}-->img/contents/contents_title_top.gif" width="678" height="7" alt="">
                                                <
/td>
                                            <
/tr>
                                            <
tr>
                                                <
td background="<!--{$TPL_DIR}-->img/contents/contents_title_left_bg.gif">
                                                    <
img src="<!--{$TPL_DIR}-->img/contents/contents_title_left.gif" width="22" height="12" alt="">
                                                <
/td>
                                                <
td bgcolor="#636469" width="638" class="fs14n">
                                                    <
span class="white">
                                                        返信内容
                                                    <
/span>
                                                <
/td>
                                                <
td background="<!--{$TPL_DIR}-->img/contents/contents_title_right_bg.gif">
                                                    <
img src="<!--{$TPL_DIR}-->img/common/_.gif" width="18" height="1" alt="">
                                                <
/td>
                                            <
/tr>
                                            <
tr>
                                                <
td colspan="3">
                                                    <
img src="<!--{$TPL_DIR}-->img/contents/contents_title_bottom.gif" width="678" height="7" alt="">
                                                <
/td>
                                            <
/tr>
                                            <
tr>
                                                <
td colspan="3">
                                                    <
img src="<!--{$TPL_DIR}-->img/contents/main_bar.jpg" width="678" height="10" alt="">
                                                <
/td>
                                            <
/tr>
                                        <
/table>
                                        
                                        <
!--メイン部分 -->
                                        <
table width="678" border="0" cellspacing="1" cellpadding="8">
                                            <
tr class="fs12n">
                                                <
td bgcolor="#f2f1ec" width="110">
                                                    テンプレート
                                                <
/td>
                                                <
td bgcolor="#ffffff">
                                                    <
select name="template_id" onchange="return fnSetvalAndSubmit('form1', 'mode', 'template');">
                                                    <
!--{foreach from=$arrMailTemplate key="key" item="value"}-->
                                                        <
option value="<!--{$key}-->" <!--{if $key==$mailTemplateId}-->selected<!--{/if}-->><!--{$value|escape}-->
                                                    <
!--{/foreach}-->
                                                    <
/select>
                                                <
/td>
                                            <
/tr>
                                            <tr class=
"fs12n">
                                                <td bgcolor=
"#f2f1ec" width="110">
                                                    宛先
                                                <
/td>
                                                <
td bgcolor="#ffffff">
                                                    <
!--{$contact_data[0].email|escape}-->
                                                <
/td>
                                            <
/tr>
                                            <
tr class="fs12n">
                                                <
td bgcolor="#f2f1ec" width="110">
                                                    タイトル
                                                <
/td>
                                                <
td bgcolor="#ffffff">
                                                    <
input type="text" name="title" value="<!--{$arrForm.title|escape}-->" size="<!--{$smarty.const.STEXT_LEN}-->" maxlength="<!--{$smarty.const.STEXT_LEN}-->"><!--{$arrErr.title}-->
                                                <
/td>
                                            <
/tr>
                                            <tr class=
"fs12n">
                                                <td bgcolor=
"#f2f1ec" width="110">
                                                    本文
                                                <
/td>
                                                <
td bgcolor="#ffffff">
                                                    <
!--{$arrErr.content}--><textarea name="content" cols="72" rows="10"><!--{$arrForm.content|escape}--></textarea>
                                                <
/td>
                                            <
/tr>
                                            <
tr class="fs12n">
                                                <
td bgcolor="#f2f1ec" width="110">
                                                    お名前
                                                <
/td>
                                                <
td bgcolor="#ffffff">
                                                    <
!--{$contact_data[0].name|escape}--><!--{$contact_data[0].name_f|escape}--> 様
                                                <
/td>
                                            <
/tr>
                                            <
tr class="fs12n">
                                                <
td bgcolor="#f2f1ec" width="110">
                                                    お問合せ内容
                                                <
/td>
                                                <
td bgcolor="#ffffff">
                                                    <
!--{$contact_data[0].message|escape|nl2br}-->
                                                <
/td>
                                            <
/tr>
                                        <
/table>
                                        <
table width="678" border="0" cellspacing="0" cellpadding="0">
                                            <
tr>
                                                <
td bgcolor="#cccccc">
                                                    <
img src="<!--{$TPL_DIR}-->img/common/_.gif" width="1" height="5" alt="">
                                                <
/td>
                                                <
td>
                                                    <
img src="<!--{$TPL_DIR}-->img/contents/tbl_top.gif" width="676" height="7" alt="">
                                                <
/td>
                                                <
td bgcolor="#cccccc">
                                                    <
img src="<!--{$TPL_DIR}-->img/common/_.gif" width="1" height="5" alt="">
                                                <
/td>
                                            <
/tr>
                                            <
tr>
                                                <
td bgcolor="#cccccc">
                                                    <
img src="<!--{$TPL_DIR}-->img/common/_.gif" width="1" height="10" alt="">
                                                <
/td>
                                                <
td bgcolor="#e9e7de" align="center">
                                                    <
table border="0" cellspacing="0" cellpadding="0">
                                                        <
tr>
                                                            <
td class="fs12n">
                                                                <
input type="button" name="send" value="送信する" onclick="return confirm_send();">
                                                            <
/td>
                                                        <
/tr>
                                                    <
/table>
                                                <
/td>
                                                <
td bgcolor="#cccccc">
                                                    <
img src="<!--{$TPL_DIR}-->img/common/_.gif" width="1" height="10" alt="">
                                                <
/td>
                                            <
/tr>
                                            <
tr>
                                                <
td colspan="3">
                                                    <
img src="<!--{$TPL_DIR}-->img/contents/tbl_bottom.gif" width="678" height="8" alt="">
                                                <
/td>
                                            <
/tr>
                                        <
/table>
                                        
                                        <
table width="678" border="0" cellspacing="0" cellpadding="0">
                                            <
tr>
                                                <
td colspan="3">
                                                    <
img src="<!--{$TPL_DIR}-->img/contents/main_bar.jpg" width="678" height="10" alt="">
                                                <
/td>
                                            <
/tr>
                                            <
tr>
                                                <
td colspan="3">
                                                    <
img src="<!--{$TPL_DIR}-->img/contents/contents_title_top.gif" width="678" height="7" alt="">
                                                <
/td>
                                            <
/tr>
                                            <
tr>
                                                <
td background="<!--{$TPL_DIR}-->img/contents/contents_title_left_bg.gif">
                                                    <
img src="<!--{$TPL_DIR}-->img/contents/contents_title_left.gif" width="22" height="12" alt="">
                                                <
/td>
                                                <
td bgcolor="#636469" width="638" class="fs14n">
                                                    <
span class="white">
                                                        返信履歴
                                                    <
/span>
                                                <
/td>
                                                <
td background="<!--{$TPL_DIR}-->img/contents/contents_title_right_bg.gif">
                                                    <
img src="<!--{$TPL_DIR}-->img/common/_.gif" width="18" height="1" alt="">
                                                <
/td>
                                            <
/tr>
                                            <
tr>
                                                <
td colspan="3">
                                                    <
img src="<!--{$TPL_DIR}-->img/contents/contents_title_bottom.gif" width="678" height="7" alt="">
                                                <
/td>
                                            <
/tr>
                                            <
tr>
                                                <
td colspan="3">
                                                    <
img src="<!--{$TPL_DIR}-->img/contents/main_bar.jpg" width="678" height="10" alt="">
                                                <
/td>
                                            <
/tr>
                                        <
/table>
                                        
                                        <
!--{foreach from=$arrReply key="key" item="value"}-->
                                        <
table width="678" border="0" cellspacing="1" cellpadding="8">
                                            <
tr class="fs12n">
                                                <
td bgcolor="#f2f1ec" width="110">
                                                    送信日時
                                                <
/td>
                                                <
td bgcolor="#ffffff">
                                                    <
!--{$value.create_date|sfDispDBDate}-->
                                                <
/td>
                                            <
/tr>
                                            <
tr class="fs12n">
                                                <
td bgcolor="#f2f1ec" width="110">
                                                    タイトル
                                                <
/td>
                                                <
td bgcolor="#ffffff">
                                                    <
!--{$value.title|escape}-->
                                                <
/td>
                                            <
/tr>
                                            <
tr class="fs12n">
                                                <
td bgcolor="#f2f1ec" width="110">
                                                    本文
                                                <
/td>
                                                <
td bgcolor="#ffffff">
                                                    <
!--{$value.content|escape|nl2br}-->
                                                <
/td>
                                            <
/tr>
                                        <
/table>
                                        <
table width="678" border="0" cellspacing="0" cellpadding="0">
                                            <
tr>
                                                <
td colspan="3">
                                                    <
img src="<!--{$TPL_DIR}-->img/contents/main_bar.jpg" width="678" height="10" alt="">
                                                <
/td>
                                            <
/tr>
                                        <
/table>
                                        <
!--{/foreach}-->
                                        
                                    <
/td>
                                    <
td background="<!--{$TPL_DIR}-->img/contents/main_right.jpg">
                                        <
img src="<!--{$TPL_DIR}-->img/common/_.gif" width="14" height="1" alt="">
                                    <
/td>
                                <
/tr>
                                <
tr>
                                    <
td colspan="3">
                                        <
img src="<!--{$TPL_DIR}-->img/contents/main_bottom.jpg" width="706" height="14" alt="">
                                    <
/td>
                                <
/tr>
                                <
tr>
                                    <
td colspan="3" height="30">
                                    <
/td>
                                <
/tr>
                            <
/table>
                        <
/td>
                    <
/tr>
                <
/table>
            <
/td>
        <
/tr>
    <
/table>
<
/form>

EC-CUBE_お問い合わせ返信機能



EC-CUBEのカスタマイズや、ECサイトの開発・構築でお困りなら、
ネットショップ構築パッケージEC-Orangeにお問い合わせください!