2015/05/06
ECCUBE2.4
すでにカスタムがされている問合せフォームに
さらに項目「配送希望日・納期」「配送先の都道府県名」を追加しました。
LC_Page_Contact_Ex.phpに項目追加
/** * Page のプロセス. * * @return void */ function process() { global $objCampaignSess; $conn = new SC_DBConn(); $this->objView = new SC_SiteView(); $objCampaignSess = new SC_CampaignSession(); $objDb = new SC_Helper_DB_Ex(); $CONF = $objDb->sf_getBasisData(); // 店舗基本情報 SC_Utils_Ex::sfDomainSessionStart(); $objCustomer = new SC_Customer(); $this->arrData = isset($_SESSION['customer']) ? $_SESSION['customer'] : ""; // レイアウトデザインを取得 $layout = new SC_Helper_PageLayout_Ex(); $layout->sfGetPageLayout($this, false, DEF_LAYOUT); //フォーム値変換用カラム $arrConvertColumn = array( /*#お問い合わせに対象商品名# ADD BEGIN*/ array( "column" => "target_name", "convert" => "aKV" ), /*#お問い合わせに対象商品名# ADD END*/ /*#お問い合わせに法人項目# ADD BEGIN*/ array( "column" => "company_name", "convert" => "aKV" ), array( "column" => "company_name_kana", "convert" => "CKV" ), /*#お問い合わせに法人項目# ADD END*/ array( "column" => "name01", "convert" => "aKV" ), array( "column" => "name02", "convert" => "aKV" ), array( "column" => "kana01", "convert" => "CKV" ), array( "column" => "kana02", "convert" => "CKV" ), array( "column" => "zip01", "convert" => "n" ), array( "column" => "zip02", "convert" => "n" ), array( "column" => "pref", "convert" => "n" ), array( "column" => "addr01", "convert" => "aKV" ), array( "column" => "addr02", "convert" => "aKV" ), array( "column" => "email", "convert" => "a" ), array( "column" => "email02", "convert" => "a" ), array( "column" => "tel01", "convert" => "n" ), array( "column" => "tel02", "convert" => "n" ), array( "column" => "tel03", "convert" => "n" ), /*#お問い合わせに項目追加# ADD BEGIN*/ array( "column" => "date", "convert" => "aKV" ), array( "column" => "pref2", "convert" => "aKV" ), /*#お問い合わせに項目追加# ADD END*/ array( "column" => "contents", "convert" => "aKV") ); if (!isset($_POST['mode'])) $_POST['mode'] = ""; switch ($_POST['mode']) { case 'confirm': // エラーチェック $this->arrForm = $_POST; $this->arrForm['email'] = isset($_POST['email']) ? strtolower($_POST['email']) : ''; $this->arrForm['email02'] = isset($_POST['email02']) ? strtolower($_POST['email02']) : ''; $this->arrForm = $this->lfConvertParam($this->arrForm,$arrConvertColumn); $this->arrErr = $this->lfErrorCheck($this->arrForm); if ( ! $this->arrErr ){ // エラー無しで完了画面 $this->tpl_mainpage = 'contact/confirm.tpl'; $this->tpl_title = 'お問い合わせ(確認ページ)'; } else { foreach ($arrConvertColumn as $key) { $this->$key['column'] = $this->arrForm[$key['column']]; } } break; case 'return': foreach ($arrConvertColumn as $key) { $this->$key['column'] = $_POST[$key['column']]; } break; case 'complete': $this->arrForm = $_POST; $this->arrForm['email'] = strtolower($_POST['email']); $this->arrForm = $this->lfConvertParam($this->arrForm,$arrConvertColumn); $this->arrErr = $this->lfErrorCheck($this->arrForm); if(!$this->arrErr) { $this->lfSendMail($CONF, $this); // 完了ページへ移動する $this->sendRedirect($this->getLocation("./complete.php", array(), true)); exit; } else { SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); } break; default: break; } //---- ページ表示 $this->objView->assignobj($this); // フレームを選択(キャンペーンページから遷移なら変更) $objCampaignSess->pageView($this->objView); }
/** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } // }}} // {{{ protected functions //エラーチェック処理部 function lfErrorCheck($array) { $objErr = new SC_CheckError($array); /*#お問い合わせに法人項目# ADD BEGIN*/ $objErr->doFunc(array("法人名", 'company_name', STEXT_LEN), array("SPTAB_CHECK","MAX_LENGTH_CHECK")); $objErr->doFunc(array("法人フリガナ", 'company_name_kana', STEXT_LEN), array("SPTAB_CHECK","MAX_LENGTH_CHECK", "KANA_CHECK")); /*#お問い合わせに法人項目# ADD END*/ $objErr->doFunc(array("お名前(姓)", 'name01', STEXT_LEN), array("SPTAB_CHECK","MAX_LENGTH_CHECK")); $objErr->doFunc(array("お名前(名)", 'name02', STEXT_LEN), array("SPTAB_CHECK","MAX_LENGTH_CHECK")); $objErr->doFunc(array("フリガナ(セイ)", 'kana01', STEXT_LEN), array("SPTAB_CHECK","MAX_LENGTH_CHECK", "KANA_CHECK")); $objErr->doFunc(array("フリガナ(メイ)", 'kana02', STEXT_LEN), array("SPTAB_CHECK","MAX_LENGTH_CHECK", "KANA_CHECK")); $objErr->doFunc(array("郵便番号1", "zip01", ZIP01_LEN ) ,array("SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK")); $objErr->doFunc(array("郵便番号2", "zip02", ZIP02_LEN ) ,array("SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK")); $objErr->doFunc(array("ご住所1", "addr01", MTEXT_LEN), array("SPTAB_CHECK" ,"MAX_LENGTH_CHECK")); $objErr->doFunc(array("ご住所2", "addr02", MTEXT_LEN), array("SPTAB_CHECK" ,"MAX_LENGTH_CHECK")); $objErr->doFunc(array("お問い合わせ内容", "contents", MLTEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK")); $objErr->doFunc(array('メールアドレス', "email", MTEXT_LEN) ,array("EXIST_CHECK", "EMAIL_CHECK", "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK")); $objErr->doFunc(array('メールアドレス(確認)', "email02", MTEXT_LEN) ,array("EXIST_CHECK", "EMAIL_CHECK", "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK")); $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', "email", "email02") ,array("EQUAL_CHECK")); $objErr->doFunc(array("お電話番号1", 'tel01', TEL_ITEM_LEN), array("NUM_CHECK", "MAX_LENGTH_CHECK")); $objErr->doFunc(array("お電話番号2", 'tel02', TEL_ITEM_LEN), array("NUM_CHECK", "MAX_LENGTH_CHECK")); $objErr->doFunc(array("お電話番号3", 'tel03', TEL_ITEM_LEN), array("NUM_CHECK", "MAX_LENGTH_CHECK")); /*#お問い合わせに項目追加# ADD BEGIN*/ $objErr->doFunc(array("配送希望日", 'date', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK")); $objErr->doFunc(array("配送先の県名", 'pref2', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK")); /*#お問い合わせに項目追加# ADD END*/ if (REVIEW_ALLOW_URL == false) { // URLの入力を禁止 $masterData = new SC_DB_MasterData_Ex(); $objErr->doFunc(array("URL", "contents", $masterData->getMasterData("mtb_review_deny_url")), array("PROHIBITED_STR_CHECK")); } return $objErr->arrErr; }
フロントの表示
contact/index.tpl
<!--{*#お問い合わせに項目追加# ADD BEGIN*}--> <th>配送希望日・納期<span class="attention">※</span></th> <td> <span class="attention"><!--{$arrErr.date}--></span> <input type="text" class="box120" name="date" value="<!--{$date|escape}-->" maxlength="50" style="<!--{$arrErr.date|sfGetErrorColor}-->" /> </td> </tr> <th>配送先の都道府県名<span class="attention">※</span></th> <td> <p>例:埼玉県</p> <span class="attention"><!--{$arrErr.pref2}--></span> <input type="text" class="box60" name="pref2" value="<!--{$pref2|escape}-->" maxlength="50" style="<!--{$arrErr.pref2|sfGetErrorColor}-->" /> </td> </tr> <!--{*#お問い合わせに項目追加# ADD END*}-->
contact/confirm.tpl
<!--{*#お問い合わせに項目追加# ADD BEGIN*}--> <tr> <th>配送希望日・納期<span class="attention">※</span></th> <td><!--{$arrForm.date|escape}--></td> </tr> <tr> <th>配送先の都道府県名<span class="attention">※</span></th> <td><!--{$arrForm.pref2|escape}--></td> </tr> <!--{*#お問い合わせに項目追加# ADD END*}-->
ゼヒトモ内でのプロフィール: ROCKSTREAM, ゼヒトモのホームページ作成・制作サービス, 仕事をお願いしたい依頼者と様々な「プロ」をつなぐサービス
2024/08/20
神社
御朱印
2024/07/06
神社
御朱印
2024/07/06
神社
御朱印
2024/02/09
神社
2024/02/09
神社