EC-CUBE2.12:割引クーポンを追加する

このページには、すべてのコードが記されていません。
下記よりダウンロードしてください。

▼ここでのカスタマイズファイルをすべてダウンロードできます。
必要な箇所だけコピーしてご利用ください。
他のカスタマイズも含まれている場合がありますので、ファイルの上書きは絶対におやめください。
こちらから(facebookユーザーのみ)

「クーポン情報」ブロックを作成し、トップページなどでクーポン情報をお知らせできるようにする。

1 データベースに新規テーブルを登録する。

(1)テーブル(dtb_coupon)を作成する

【MySQL】

CREATE TABLE dtb_coupon (
coupon_id int NOT NULL auto_increment,
title text,
discount decimal NOT NULL DEFAULT 0,
exp_start_date datetime,
exp_end_date datetime,
create_date datetime,
update_date datetime,
del_flg int NOT NULL DEFAULT 0,
PRIMARY KEY (coupon_id)
);

【PostgreSQL】

CREATE TABLE dtb_coupon (
coupon_id serial NOT NULL,
title text,
discount decimal NOT NULL DEFAULT 0,
exp_start_date timestamp,
exp_end_date timestamp,
create_date timestamp,
update_date timestamp,
del_flg int NOT NULL DEFAULT 0,
PRIMARY KEY (coupon_id)
);

(2)テーブル(dtb_customer_coupon)を作成する

【MySQL】

CREATE TABLE dtb_customer_coupon (
customer_coupon_id int NOT NULL auto_increment,
customer_id int NOT NULL,
coupon_id int NOT NULL,
order_id int NOT NULL,
create_date datetime,
update_date datetime,
del_flg int NOT NULL DEFAULT 0,
PRIMARY KEY (customer_coupon_id)
);

【PostgreSQL】

CREATE TABLE dtb_customer_coupon (
customer_coupon_id serial NOT NULL,
customer_id int NOT NULL,
coupon_id int NOT NULL,
order_id int NOT NULL,
create_date timestamp,
update_date timestamp,
del_flg int NOT NULL DEFAULT 0,
PRIMARY KEY (customer_coupon_id)
);

(3)クーポン情報のカラムをdtb_orderとdtb_order_tempに追加する。

ALTER TABLE dtb_order ADD coupon text
ALTER TABLE dtb_order_temp ADD coupon text

2 管理画面の作成

(1)下記ファイルを新規作成

 ■html/admin/contents/coupon.php

<?php
// {{{ requires
require_once '../require.php';
require_once CLASS_EX_REALDIR . 'page_extends/admin/contents/LC_Page_Admin_Contents_Coupon_Ex.php';

// }}}
// {{{ generate page

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

 ■data/class_extends/page_extends/admin\contents/LC_Page_Admin_Contents_Coupon_Ex.php

<?php
// {{{ requires
require_once CLASS_REALDIR . 'pages/admin/contents/LC_Page_Admin_Contents_Coupon.php';

class LC_Page_Admin_Contents_Coupon_Ex extends LC_Page_Admin_Contents_Coupon {

// }}}
// {{{ functions

/**
* Page を初期化する.
*
* @return void
*/
function init() {
parent::init();
}

/**
* Page のプロセス.
*
* @return void
*/
function process() {
parent::process();
}

/**
* デストラクタ.
*
* @return void
*/
function destroy() {
parent::destroy();
}
}
?>

 ■data/class/pages/admin/contents/LC_Page_Admin_Contents_Coupon.php

// {{{ requires
require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* コンテンツ管理 のページクラス.
*
* @package Page
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Admin_Contents.php 20825 2011-04-08 08:28:06Z no61 $
*/
class LC_Page_Admin_Contents_Coupon extends LC_Page_Admin_Ex {

// }}}
// {{{ functions

/**
* Page を初期化する.
*
* @return void
*/
function init() {
parent::init();
$this->tpl_mainpage = 'contents/coupon.tpl';
$this->tpl_subnavi = 'contents/subnavi.tpl';
$this->tpl_subno = 'coupon';
$this->tpl_mainno = 'contents';
$this->arrForm = array(
'year' => date('Y'),
'month' => date('n'),
'day' => date('j'),
);
$this->tpl_subtitle = 'クーポン管理';
//---- 日付プルダウン設定
$objDate = new SC_Date_Ex(ADMIN_NEWS_STARTYEAR);
$this->arrYear = $objDate->getYear();
$this->arrMonth = $objDate->getMonth();
$this->arrDay = $objDate->getDay();
}

/**
* Page のプロセス.
*
* @return void
*/
function process() {
$this->action();
$this->sendResponse();
}

/**
* Page のアクション.
*
* @return void
*/
function action() {
$objDb = new SC_Helper_DB_Ex();
$objFormParam = new SC_FormParam_Ex();
//パラメータの設定
$this->lfInitParam($objFormParam);
//POSTされた値をパラメータに設定
$objFormParam->setParam($_POST);
//パラメータを変換
$objFormParam->convParam();
//クーポンIDを取得
$coupon_id = $objFormParam->getValue('coupon_id');

//新規登録/編集登録
switch ($this->getMode()) {
case 'regist':
//登録
//パラメータの取得
$arrPost = $objFormParam->getHashArray();
//エラーチェック
$this->arrErr = $this->lfCheckError($objFormParam);
if (SC_Utils_Ex::isBlank($this->arrErr)) {
//クーポンIDの値がPOSTされて来た場合は既存データの編集とみなし、
//更新メソッドを呼び出す。
//クーポンIDが存在しない場合は新規登録を行う。
if (strlen($coupon_id) > 0 && is_numeric($coupon_id)) {
//新規登録
$this->lfCouponUpdate($arrPost);
} else {
//更新
$this->lfCouponInsert($arrPost);
}
$coupon_id = "";
$this->tpl_onload = "window.alert('編集が完了しました');";
} else {
//表示用の変数代入
$this->arrForm = $arrPost;
}
break;
case 'search':
if (is_numeric($coupon_id)) {
list($this->arrForm) = $this->getCoupon($coupon_id);
list($this->arrForm['startyear'],$this->arrForm['startmonth'],$this->arrForm['startday']) = $this->splitCouponDate($this->arrForm['cast_start_date']);
list($this->arrForm['endyear'],$this->arrForm['endmonth'],$this->arrForm['endday']) = $this->splitCouponDate($this->arrForm['cast_end_date']);
$this->edit_mode = 'on';
}
break;
case 'delete':
//---- データ削除
if (is_numeric($coupon_id)) {
$this->deleteCoupon($coupon_id);
SC_Response_Ex::reload();             //自分にリダイレクト(再読込による誤動作防止)
}
break;
default:
break;
}

//クーポン情報の取得
$this->arrCoupon = $this->getCoupon();
//表示用にクーポンIDの代入
$this->tpl_coupon_id = $coupon_id;
//クーポンの数取得
$this->line_max = count($this->arrCoupon);
}

/**
* デストラクタ.
*
* @return void
*/
function destroy() {
parent::destroy();
}

/**
* 入力されたパラメータのエラーチェックを行う。
* @param Object $objFormParam
* @return Array エラー内容
*/
function lfCheckError(&$objFormParam){
$objErr = new SC_CheckError_Ex($objFormParam->getHashArray());
//パラメータのエラーチェック
$objErr->arrErr = $objFormParam->checkError();
//利用期間の入力チェック
$objErr->doFunc(array("利用開始日", 'startyear', 'startmonth', 'startday'), array("CHECK_DATE"));
$objErr->doFunc(array("利用終了日", 'endyear', 'endmonth', 'endday'), array("CHECK_DATE"));
return $objErr->arrErr;
}

/**
* パラメータの初期化を行う
* @param Object $objFormParam
*/
function lfInitParam(&$objFormParam){
$objFormParam->addParam("coupon_id", 'coupon_id', INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("クーポン名", 'title', STEXT_LEN, '', array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("割引額", 'discount', INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("日付(年)", 'startyear', INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("日付(月)", 'startmonth', INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("日付(日)", 'startday', INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("日付(年)", 'endyear', INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("日付(月)", 'endmonth', INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("日付(日)", 'endday', INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
}

/**
* クーポンのデータの登録を行う
* @param Array $arrPost POSTデータの配列
*/
function lfCouponInsert($arrPost){
$objQuery = $objQuery =& SC_Query_Ex::getSingletonInstance();

$table = 'dtb_coupon';//登録テーブル
$sqlval = array();//登録用の配列
$sqlval['title'] = $arrPost['title'];//クーポン名
$sqlval['discount'] = $arrPost['discount'];//割引額
$sqlval['exp_start_date'] = $this->getRegistDate(array($_POST['startyear'],$_POST['startmonth'],$_POST['startday']));//利用開始日
$sqlval['exp_end_date'] = $this->getRegistDate(array($_POST['endyear'],$_POST['endmonth'],$_POST['endday']));//利用終了日
$sqlval['create_date'] = 'now()';//作成日
$sqlval['update_date'] = 'now()';//更新日
$objQuery->insert($table, $sqlval);

}

/**
* クーポンの日付の値をフロントでの表示形式に合わせるために分割
* @param String $news_date
*/
function splitCouponDate($coupon_date){
return explode("-", $coupon_date);
}

//クーポンの更新
function lfCouponUpdate($arrPost){
$objQuery = $objQuery =& SC_Query_Ex::getSingletonInstance();

$table = 'dtb_coupon';//登録テーブル
$sqlval = array();//登録用の配列
$sqlval['title'] = $arrPost['title'];//クーポン名
$sqlval['discount'] = $arrPost['discount'];//割引額
$sqlval['exp_start_date'] = $this->getRegistDate(array($_POST['startyear'],$_POST['startmonth'],$_POST['startday']));//利用開始日
$sqlval['exp_end_date'] = $this->getRegistDate(array($_POST['endyear'],$_POST['endmonth'],$_POST['endday']));//利用終了日
$sqlval['update_date'] = 'now()';//更新日
$where = 'coupon_id = ?';
$arrValIn = array($arrPost['coupon_id']);//対象のクーポンID
$objQuery->update($table, $sqlval, $where, $arrValIn);
}

/**
* データの登録日を返す。
* @param Array $arrPost POSTのグローバル変数
* @return string 登録日を示す文字列
*/
function getRegistDate($arrPost){
//ばらばらのデータをスラッシュ区切りの文字列に変換
$registDate = $arrPost[0] ."/". $arrPost[1] ."/". $arrPost[2];
return $registDate;
}

/**
* クーポンを取得する。
* @param Integer coupon_id クーポンID
*/
function getCoupon($coupon_id = ''){
$objQuery = $objQuery =& SC_Query_Ex::getSingletonInstance();
//取得カラム
$col = '* ,cast(exp_start_date as date) as cast_start_date , cast(exp_end_date as date) as cast_end_date';
//取得テーブル
$table = 'dtb_coupon';
//表示順序
$order = 'update_date DESC';
if(strlen($coupon_id) == 0){
//クーポンIDの指定がないならば
$where = 'del_flg = 0';
$arrval = array();
}else{
//クーポンIDの指定があるならば
$where = 'del_flg = 0 AND coupon_id = ?';
$arrval = array($coupon_id);
}
//表示順序の設定
$objQuery->setOrder($order);
return $objQuery->select($col, $table, $where,$arrval);
}

/**
* クーポンを削除する。
* @param Integer copupon_id クーポンID
*/
function deleteCoupon($coupon_id){
$objQuery = $objQuery =& SC_Query_Ex::getSingletonInstance();
$objQuery->begin();
//対象テーブル
$table = 'dtb_coupon';
$sqlval = array();
//削除フラグの設定
$sqlval['del_flg'] = 1;
//更新日の設定
$sqlval['update_date'] = 'NOW()';
//削除判定
$where = 'coupon_id = ?';
//削除対象のクーポンID
$arrValIn = array($coupon_id);
$objQuery->update($table, $sqlval, $where, $arrValIn);
$objQuery->commit();
}

}
?>

 ■data/Smarty/templates/admin/contents/coupon.tpl

(2)■data/Smarty/templates/admin/contents/subnavi.tplに追加する。

<!--▼クーポン管理-->
<li<!--{if $tpl_subno == 'coupon'}--><!--{/if}--> id="navi-contents-coupon"><a href="<!--{$smarty.const.ROOT_URLPATH}--><!--{$smarty.const.ADMIN_DIR}-->contents/coupon.php"><span>クーポン管理</span></a></li>
<!--▲クーポン管理-->

3 class/内のデータベース関連ファイルに追加

(1)■data/class/helper/SC_Helper_DB.phpの最下部sfHasProductClassの後に追加する。

/* 「クーポン」カスタム START */
function getCustomerCoupon($customer_id) {
$objQuery   = new SC_Query();

// 使用可能なクーポンを取得する
// dtb_customer_couponに使用された(del_flg=0)クーポンが登録されていないか
// 削除されたクーポンでないか
$col = "dtb_coupon.*";
$from = "dtb_coupon";
$where = "";
$where .= SC_Utils_Ex::sfCouponExpDate('dtb_coupon.',1);
$where .= " ";
$where .= "AND ";
$where .= "dtb_coupon.del_flg = 0 ";
$where .= "AND ";
$where .= "dtb_coupon.coupon_id ";
$where .= "NOT IN ";
$where .= "( ";
$where .=   "SELECT ";
$where .=   "coupon_id ";
$where .=   "FROM ";
$where .=   "dtb_customer_coupon ";
$where .=   "inner join ";
$where .=   "dtb_customer ";
$where .=   "on dtb_customer.customer_id = dtb_customer_coupon.customer_id ";
$where .=   "WHERE ";
$where .=   "dtb_customer.customer_id = ? and dtb_customer_coupon.del_flg = 0";
$where .= ") ";
$arrval = array($customer_id);
$where_all = $where;
$arrAll = $objQuery->select($col, $from, $where_all, $arrval);
return $arrAll;
}

//クーポンの情報を取得する
function getCoupon($coupon_id){
$objQuery   = new SC_Query();
$coupon = $objQuery->select("title,discount","dtb_coupon","coupon_id = ? and del_flg = 0",array($coupon_id));
return $coupon[0];

}
/* 「クーポン」カスタム END */

(2)■data/class/helper/SC_Helper_Purchase.php
911行目あたり 「新規受付の場合は対応状況 null で insert し,」の前に追加

/* 「クーポン」カスタム START */
// 使用したクーポンをdtb_customer_couponテーブルに登録する
// POSTされるクーポンIDはカンマ区切りの文字列なので、カンマで分割
$coupon = explode(',',$arrParams['coupon']);
foreach($coupon as $val){
if($val != ""){
$sqlval['customer_id'] =
SC_Utils_Ex::isBlank($arrValues['customer_id'])
? 0 : $arrValues['customer_id'];
$sqlval['coupon_id'] = $val;
$sqlval['order_id'] = $order_id;
$sqlval['create_date'] = "now()";
$sqlval['update_date'] = "now()";
$objQuery->insert("dtb_customer_coupon",$sqlval);
}
}
/* 「クーポン」カスタム END */

(3)■data/class/util/SC_Utils.php
717行目あたり /* 規格分類の件数取得 */function sfGetClassCatCountメソッドの後に追加

/* 「クーポン」カスタム START */
/*
* クーポンが使用できる期間内にあるか判定
*
*/
public static function sfCouponExpDate($prefix = 'dtb_coupon.',$check = 0) {
//check == 0 ならnow()判定
//check == 1 ならcurrent_date判定
if($check == 0){
return " CASE WHEN {$prefix}exp_start_date IS NOT NULL AND {$prefix}exp_end_date IS NOT NULL THEN now() BETWEEN {$prefix}exp_start_date AND {$prefix}exp_end_date ELSE 1=1 END ";
}else{
return " CASE WHEN {$prefix}exp_start_date IS NOT NULL AND {$prefix}exp_end_date IS NOT NULL THEN current_date BETWEEN {$prefix}exp_start_date AND {$prefix}exp_end_date ELSE 1=1 END ";
}
}
/* 「クーポン」カスタム END */

4 お支払い方法・お届け時間等の指定画面でクーポンを利用できるようにする。
下記ファイルにクーポン関連のコードを追加する
 ■data/class/pages/shopping/LC_Page_Shopping_Payment.php(5カ所)
 ■data/class/pages/shopping/LC_Page_Shopping_Confirm.php(2カ所)
 ■data/Smarty/templates/default/shopping/payment.tpl(PC)(1カ所)
 ■data/Smarty/templates/default/shopping/confirm.tpl(PC)(2カ所)
 ■data/Smarty/templates/mobile/shopping/payment.tpl(携帯)(1カ所)
 ■data/Smarty/templates/mobile/shopping/confirm.tpl(携帯)(1カ所)
 ■data/Smarty/templates/sphone/shopping/payment.tpl(スマートフォン)(1カ所)
 ■data/Smarty/templates/sphone/shopping/confirm.tpl(スマートフォン)(1カ所)

5 割引後の合計金額の計算。クーポンを使用したことで0円になる場合、合計金額を強制的に0円にする。手数料と送料を割引の対象にしない。
■data/class/SC_CartSession.php (function calculate内)

// 合計を計算
$results['total'] = $results['subtotal'];
$results['total'] += $results['deliv_fee'];
$results['total'] += $charge;
$results['total'] -= $discount;

↓(変更)

// 合計を計算
// 割引後の金額が0円以下になった場合0に修正(■クーポン追加による修正)
$results['total'] = $results['subtotal'];
$results['total'] -= $discount;
if($results['total'] < 0) $results['total'] = 0;
$results['total'] += $results['deliv_fee'];
$results['total'] += $charge;

6 MYページでクーポンを表示する。
下記ファイルにクーポン関連のコードを追加する
 ■data/class/pages/mypage/LC_Page_Mypage.php(1カ所)
 ■data/Smarty/templates/default/mypage/index.tpl(PC)(1カ所)
 ■data/Smarty/templates/mobile/mypage/index.tpl(携帯)(1カ所)
 ■data/Smarty/templates/sphone/mypage/index.tpl(スマートフォン)(1カ所)

7 受注管理で金額表示。キャンセル時にクーポンの履歴を戻す。
(1)■data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php

lfCheckError内の、「小計」と「合計」の間に下記を追加

// 割引(■クーポンに関わるカスタマイズ)
$arrValues['total'] = $subtotal - $arrValues['discount'];
//割引後の金額がマイナスになった場合0に戻す(■クーポンに関わるカスタマイズ)
if($arrValues['total'] < 0) $arrValues['total'] = 0;

 「// 受注テーブルの更新 $order_id = $objPurchase->registerOrder($order_id, $arrValues);」の次に追加

// 受注テーブルの更新
$order_id = $objPurchase->registerOrder($order_id, $arrValues);

//■クーポンに関わるカスタマイズ▼
if($arrValues['status']==3){
$sqlVal['del_flg'] = 1;
$where = 'order_id = ?';
$objQuery->update('dtb_customer_coupon',$sqlVal,$where,array($arrValues['order_id']));
}
//■クーポンに関わるカスタマイズ▲

$arrDetail = $objFormParam->getSwapArray(array(
'product_id',
'product_class_id',
'product_code',
'product_name',
'price', 'quantity',
'point_rate',
'classcategory_name1',
'classcategory_name2',
));

(2)■data/class/pages/admin/order/LC_Page_Admin_Order_Status.php
function lfStatusMove内

foreach ($arrOrderId as $orderId) {
$objPurchase->sfUpdateOrderStatus($orderId, $statusId);
//■クーポン
if($statusId == 3){
//同じorder_idのクーポン履歴を削除
$sqlVal['del_flg'] = 1;
$where = 'order_id = ?';
$objQuery->update('dtb_customer_coupon',$sqlVal,$where,array($orderId));
}
}

8 クーポン情報をお知らせするブロックを作成する

(1)拡張ファイル等の作成
 ■html/frontparts/bloc/coupon.php

<?php

// {{{ requires
require_once realpath(dirname(__FILE__)) . '/../../require.php';
require_once CLASS_EX_REALDIR . 'page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_Coupon_Ex.php';

// }}}
// {{{ generate page

$objPage = new LC_Page_FrontParts_BLoc_Coupon_Ex();
$objPage->blocItems = $params['items'];
register_shutdown_function(array($objPage, "destroy"));
$objPage->init();
$objPage->process();
?>

 ■data/class_extends/page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_Coupon_Ex.php

<?php

// {{{ requires
require_once CLASS_REALDIR . 'pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Coupon.php';

class LC_Page_FrontParts_Bloc_Coupon_Ex extends LC_Page_FrontParts_Bloc_Coupon {

// }}}
// {{{ functions

/**
* Page を初期化する.
*
* @return void
*/
function init() {
parent::init();
}

/**
* Page のプロセス.
*
* @return void
*/
function process() {
parent::process();
}

/**
* デストラクタ.
*
* @return void
*/
function destroy() {
parent::destroy();
}
}
?>

 ■data/class/page/frontparts/bloc/LC_Page_FrontParts_Bloc_Coupon.php

<?php

// {{{ requires
require_once CLASS_REALDIR . 'pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php';

class LC_Page_FrontParts_Bloc_Coupon extends LC_Page_FrontParts_Bloc {

// }}}
// {{{ functions

/**
* Page を初期化する.
*
* @return void
*/
function init() {
parent::init();
}

/**
* Page のプロセス.
*
* @return void
*/
function process() {
$this->action();
$this->sendResponse();
}

/**
* Page のアクション.
*
* @return void
*/
function action() {

// データベースから取得
$objQuery = SC_Query_Ex::getSingletonInstance();
$this->arrRet = array();

//クーポン情報を取得
$arrRet = $objQuery->select('*','dtb_coupon','del_flg = 0 && exp_end_date >= current_date');

//データベースから取得できたか
if(isset($arrRet)){
$this->arrRet = $arrRet;
}
}

/**
* デストラクタ.
*
* @return void
*/
function destroy() {
parent::destroy();
}
}
?>

(2)テンプレートの作成

PC用 ■data/Smarty/templates/default/frontparts/bloc/coupon.tpl
携帯用 ■data/Smarty/templates/mobile/frontparts/bloc/coupon.tpl
スマートフォン用 ■data/Smarty/templates/sphone/frontparts/bloc/coupon.tpl

(3)CSSに追加

PC用 ■html/user_data/packages/default/css/bloc.css

/* ===============================================
▼クーポン情報
=============================================== */
#coupon_area {
margin-bottom:20px;
}
#coupon_area h2 {
color:#E75019;
padding:4px 10px;
border-top:#F90 1px solid;
border-left:#F90 10px solid;
border-right:#ccc 1px solid;
background-color:#FEE39E;
}
#coupon_area .bloc_body {
padding:10px;
}
#coupon_area .title {
color:#FFF;
background-color:#E75019;
padding:2px 4px;
margin-bottom:5px;
}
#coupon_area .discount {
margin-bottom:5px;
}
#coupon_area .date {
margin-bottom:5px;
}
#coupon_area .comment {
background-color: #FFEBD7;
border:#ddd 1px solid;
padding:5px;
margin-bottom:5px;
}

スマートフォン用 ■html/user_data/packages/sphone/css/bloc.css

/*-----------------------------------------------
クーポン情報
----------------------------------------------- */
#coupon_area{
margin-bottom: 20px;
}
#coupon_area ul{
}
#coupon_area li, #coupon_area .comment {
display:block;
clear:both;
padding:10px;
line-height:1.3;
background-color:#FEFEFE;
background: -moz-linear-gradient(center top, #FEFEFE 0%,#EEEEEE 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #FEFEFE),color-stop(1, #EEEEEE));
border-top:#FFF solid 1px;
border-bottom:#CCC solid 1px;
}
#coupon_area .coupon_date{
clear:both;
font-size:12px;
letter-spacing:0.1em;
}

(4)データベースのdtb_blocにPC用(device_type_id=10)、携帯用(device_type_id=1)、スマートフォン用(device_type_id=2)のブロックを登録する。

PC用

INSERT INTO dtb_bloc (device_type_id, bloc_id, bloc_name, tpl_path, filename, create_date, update_date, php_path, deletable_flg) VALUES (10, 13, 'クーポン情報', 'coupon.tpl', 'coupon', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'frontparts/bloc/coupon.php', 0)

携帯用

INSERT INTO dtb_bloc (device_type_id, bloc_id, bloc_name, tpl_path, filename, create_date, update_date, php_path, deletable_flg) VALUES (1, 8, 'クーポン情報', 'coupon.tpl', 'coupon', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'frontparts/bloc/coupon.php', 0);

スマートフォン用

INSERT INTO dtb_bloc (device_type_id, bloc_id, bloc_name, tpl_path, filename, create_date, update_date, php_path, deletable_flg) VALUES (2, 11, 'クーポン情報', 'coupon.tpl', 'coupon', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'frontparts/bloc/coupon.php', 0);