EC-CUBE2.12:「お問い合わせ」の項目に「回答希望」を追加する

使用するかしないかは、パラメータで設定する。

(1)「回答希望」の表示・非表示をmtb_constantsテーブルに登録する。

INSERT INTO mtb_constants (id, name, rank, remarks) VALUES ('CONTACT_KAITO_USE', 'true', 1421, 'お問い合わせの「回答希望」(true:使用する,false:使用しない)')

★システム設定>パラメーター設定を開き、「この内容で登録する」をクリック。

(2)■data\class\pages\contact\LC_Page_Contact.php

172行目あたり、$objFormParam->addParam(‘お電話番号3′, ‘tel03′, TEL_ITEM_LEN, ‘n’, array(‘NUM_CHECK’, ‘MAX_LENGTH_CHECK’));の後に追加する。

$objFormParam->addParam("ご希望の回答方法", 'kaitotel', INT_LEN, 'n', array("MAX_LENGTH_CHECK"));
$objFormParam->addParam("ご希望の回答方法", 'kaitoemail', INT_LEN, 'n', array("MAX_LENGTH_CHECK"));
$objFormParam->addParam("ご希望の時間帯", 'timezone', INT_LEN, 'n', array("MAX_LENGTH_CHECK"));

(3)「お問い合わせ」ページに表示する

 PC用 ■data\Smarty\templates\default\contact\index.tplにラジオボタンとチェックボックスを追加する。
「お問い合わせ内容」の次に挿入する。

<!--{if $smarty.const.CONTACT_KAITO_USE == "true"}-->
<tr>
<th>ご希望の回答方法</th>
<td>
<input type="checkbox" name="kaitotel" value=1>&nbsp;電話<br />
<input type="checkbox" name="kaitoemail" value=1>&nbsp;E-Mail
</td>
</tr>
<tr>
<th>ご希望の時間帯</th>
<td>
<input type="radio" name="timezone" value=1>午前(9:00~10:30)<br />
<input type="radio" name="timezone" value=2>午前(10:30~12:00)<br />
<input type="radio" name="timezone" value=3>お昼(12:00~13:00)<br />
<input type="radio" name="timezone" value=4>午後(13:00~15:00)<br />
<input type="radio" name="timezone" value=5>午後(15:00~17:00)<br />
<input type="radio" name="timezone" value=6 checked="checked">特になし
</td>
</tr>
<!--{/if}-->

 スマートフォン用 ■data\Smarty\templates\sphone\contact\index.tpl
「お問い合わせ内容」の次に挿入する。

<!--{if $smarty.const.CONTACT_KAITO_USE == "true"}-->
<dt>ご希望の回答方法</dt>
<dd data-role="fieldcontain">
<fieldset data-role="controlgroup">
<input type="checkbox" name="kaitotel" value=1 id="checkbox-1" /><label for="checkbox-1">電話</label>
<input type="checkbox" name="kaitoemail" value=1 id="checkbox-2" /<label for="checkbox-2">E-Mail</label>
</fieldset>
</dd>

<dt>ご希望の時間帯</dt>
<dd data-role="fieldcontain">
<fieldset data-role="controlgroup">
<input type="radio" name="timezone" value=1 id="radio-choice-1"><label for="radio-choice-1">午前(9:00~10:30)</label>
<input type="radio" name="timezone" value=2 id="radio-choice-2"><label for="radio-choice-2">午前(10:30~12:00)</label>
<input type="radio" name="timezone" value=3 id="radio-choice-3"><label for="radio-choice-3">お昼(12:00~13:00)</label>
<input type="radio" name="timezone" value=4 id="radio-choice-4"><label for="radio-choice-4">午後(13:00~15:00)</label>
<input type="radio" name="timezone" value=5 id="radio-choice-5"><label for="radio-choice-5">午後(15:00~17:00)</label>
<input type="radio" name="timezone" value=6 id="radio-choice-6" checked="checked"><label for="radio-choice-6">特になし</label>
</fieldset>
</dd>
<!--{/if}-->

(4)「お問い合わせ確認」ページに表示する

 PC用 ■data\Smarty\templates\default\contact\confirm.tpl 確認画面に表示する
「お問い合わせ内容」の次に挿入する。

<!--{if $smarty.const.CONTACT_KAITO_USE == "true"}-->
<tr>
<th>ご希望の回答方法</th>
<td><!--{if $arrForm.kaitotel.value == 1}-->電話で回答&nbsp;<!--{else}--><font color="#999999">電話不要</font>&nbsp;<!--{/if}--><!--{if $arrForm.kaitoemail.value == 1}-->E-mailで回答<!--{else}--><font color="#999999">E-mail不要</font><!--{/if}--></td>
</tr>
<tr>
<th>ご希望の時間帯</th>
<td>
<!--{if $arrForm.timezone.value == 1}-->午前(9:00~10:30)
<!--{elseif $arrForm.timezone.value == 2}-->午前(10:30~12:00)
<!--{elseif $arrForm.timezone.value == 3}-->お昼(12:00~13:00)
<!--{elseif $arrForm.timezone.value == 4}-->午後(13:00~15:00)
<!--{elseif $arrForm.timezone.value == 5}-->午後(15:00~17:00)
<!--{elseif $arrForm.timezone.value == 6}-->特になし
<!--{/if}-->
</td>
</tr>
<!--{/if}-->

 スマートフォン用 ■data\Smarty\templates\sphone\contact\confirm.tpl 確認画面に表示する
「お問い合わせ内容」の次に挿入する。

<!--{if $smarty.const.CONTACT_KAITO_USE == "true"}-->
<dt>ご希望の回答方法</dt>
<dd><!--{if $arrForm.kaitotel.value == 1}-->電話で回答&nbsp;<!--{else}--><font color="#999999">電話不要</font>&nbsp;<!--{/if}--><!--{if $arrForm.kaitoemail.value == 1}-->E-mailで回答<!--{else}--><font color="#999999">E-mail不要</font><!--{/if}--></dd>
<dt>ご希望の時間帯</dt>
<dd>
<!--{if $arrForm.timezone.value == 1}-->午前(9:00~10:30)
<!--{elseif $arrForm.timezone.value == 2}-->午前(10:30~12:00)
<!--{elseif $arrForm.timezone.value == 3}-->お昼(12:00~13:00)
<!--{elseif $arrForm.timezone.value == 4}-->午後(13:00~15:00)
<!--{elseif $arrForm.timezone.value == 5}-->午後(15:00~17:00)
<!--{elseif $arrForm.timezone.value == 6}-->特になし
<!--{/if}-->
</dd>
<!--{/if}-->

(5)■data\Smarty\templates\default\mail_templates\contact_mail.tpl メールに反映させる
の前に追加する。

<!--{if $smarty.const.CONTACT_KAITO_USE == "true"}-->
■ご希望の回答方法:<!--{if $arrForm.kaitotel.value == 1}-->電話で回答、<!--{else}-->電話不要、<!--{/if}--><!--{if $arrForm.kaitoemail.value == 1}-->E-mailで回答、<!--{else}-->E-mail不要<!--{/if}-->

■ご希望の時間帯:<!--{if $arrForm.timezone.value == 1}-->午前(9:00~10:30)<!--{elseif $arrForm.timezone.value == 2}-->午前(10:30~12:00)<!--{elseif $arrForm.timezone.value == 3}-->お昼(12:00~13:00)<!--{elseif $arrForm.timezone.value == 4}-->午後(13:00~15:00)<!--{elseif $arrForm.timezone.value == 5}-->午後(15:00~17:00)<!--{elseif $arrForm.timezone.value == 6}-->特になし<!--{/if}-->
<!--{/if}-->