▼ここでのカスタマイズファイルをすべてダウンロードできます。
必要な箇所だけコピーしてご利用ください。
他のカスタマイズも含まれている場合がありますので、ファイルの上書きは絶対におやめください。
こちらから(facebookユーザーのみ)
1 データベース、dtb_productsテーブルに販売終了日と販売開始日のカラムを追加する。
【MySQL】
ALTER TABLE dtb_products ADD endsell_date datetime
ALTER TABLE dtb_products ADD arrival_date datetime
【PostgreSQL】
ALTER TABLE dtb_products ADD endsell_date timestamp
ALTER TABLE dtb_products ADD arrival_date timestamp
2 カートセッションの管理のためのクラス変更
■data/class/SC_CartSession.phpに追加する場合は、function checkProductsメソッド内の最後に追加。
/* * 販売開始、販売終了チェック */ if($item['productsClass']["arrival"] == "0") { $tpl_message .= "※「" . $product['name'] . "」は販売開始前のため購入はできません。\n"; } else if($item['productsClass']["endsell"] == "0") { $tpl_message .= "※「" . $product['name'] . "」は販売終了のため購入はできません。\n"; }
3 商品関連処理のためのクラス変更
■data/class/SC_Product.phpに追加
① function listsメソッド内に追加
/* ▼期間限定販売①/② */ ,endsell_date ,arrival_date ,(SELECT CASE WHEN coalesce(endsell_date, NOW()) = NOW() THEN 1 WHEN endsell_date >= NOW() THEN 1 ELSE 0 END) AS endsell, (SELECT CASE WHEN coalesce(arrival_date,NOW()) = NOW() THEN 1 WHEN NOW() >= arrival_date THEN 1 ELSE 0 END) AS arrival /* ▲期間限定販売 */
② function alldtlSQLメソッド内に追加
/* ▼期間限定販売②/② */ ,dtb_products.endsell_date ,dtb_products.arrival_date ,(SELECT CASE WHEN coalesce(dtb_products.endsell_date, NOW()) = NOW() THEN 1 WHEN dtb_products.endsell_date >= NOW() THEN 1 ELSE 0 END) AS endsell ,(SELECT CASE WHEN coalesce(dtb_products.arrival_date,NOW()) = NOW() THEN 1 WHEN NOW() >= dtb_products.arrival_date THEN 1 ELSE 0 END) AS arrival /* ▲期間限定販売 */
4 「販売終了日」と「販売開始日」を登録できるようにする
(1)管理画面の商品登録に「販売終了日」と「販売開始日」項目を追加
■data/class/pages/admin/products/LC_Page_Admin_Products_Product.phpに追加する場合
① function actionメソッド内に追加
$objDate = new SC_Date_Ex();
② 同じくfunction actionメソッド内に追加
$this->arrYear = $objDate->getYear(); $this->arrMonth = $objDate->getMonth(); $this->arrDay = $objDate->getDay();
③ function lfInitFormParamメソッド内に追加
$objFormParam->addParam("販売終了年", "endsell_year", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); $objFormParam->addParam("販売終了月", "endsell_month", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); $objFormParam->addParam("販売終了日", "endsell_day", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); $objFormParam->addParam("販売開始年", "arrival_year", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); $objFormParam->addParam("販売開始月", "arrival_month", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); $objFormParam->addParam("販売開始日", "arrival_day", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
④ function lfCheckError_Editメソッド内に追加
$objErr->doFunc(array("販売開始日","販売終了日", "arrival_year", "arrival_month", "arrival_day", "endsell_year", "endsell_month", "endsell_day"), array("CHECK_SET_TERM"));
⑤ function lfGetProductData_FromDBメソッド内に追加
// 販売終了日 if(isset($arrProduct[0]['endsell_date'])){ $arrProduct[0]['endsell_year'] = substr($arrProduct[0]['endsell_date'], 0,4); $arrProduct[0]['endsell_month'] = substr($arrProduct[0]['endsell_date'], 5,2); $arrProduct[0]['endsell_day'] = substr($arrProduct[0]['endsell_date'], 8,2); } // 販売開始日 if(isset($arrProduct[0]['arrival_date'])){ $arrProduct[0]['arrival_year'] = substr($arrProduct[0]['arrival_date'], 0,4); $arrProduct[0]['arrival_month'] = substr($arrProduct[0]['arrival_date'], 5,2); $arrProduct[0]['arrival_day'] = substr($arrProduct[0]['arrival_date'], 8,2); }
⑥ function lfRegistProductメソッド内に追加
"endsell_date", "arrival_date",
⑦ 同じくfunction lfRegistProductメソッド内に追加
if(!SC_Utils_Ex::isBlank($arrList['endsell_year'])) { $sqlval['endsell_date'] = $arrList['endsell_year'] . '/' . $arrList['endsell_month'] . '/' . $arrList['endsell_day'] . ' 23:59:59'; }else{ $sqlval['endsell_date'] = ""; } if(!SC_Utils_Ex::isBlank($arrList['arrival_year'])) { $sqlval['arrival_date'] = $arrList['arrival_year'] . '/' . $arrList['arrival_month'] . '/' . $arrList['arrival_day'] . ' 00:00:00'; }else{ $sqlval['arrival_date'] = ""; }
(2)テンプレートファイルへ追加
① ■data/Smarty/templates/admin/products/product.tpl
「販売制限数」の後に追加
<tr> <th>販売開始日</th> <td> <span class="attention"><!--{$arrErr.arrival_year}--></span> <select name="arrival_year" style="<!--{if $arrErr.arrival_year != ""}-->background-color: <!--{$smarty.const.ERR_COLOR}-->;<!--{/if}-->"> <option value="">--</option> <!--{html_options options=$arrYear selected=$arrForm.arrival_year}--> </select>年 <select name="arrival_month" style="<!--{if $arrErr.arrival_month != ""}-->background-color: <!--{$smarty.const.ERR_COLOR}-->;<!--{/if}-->"> <option value="">--</option> <!--{html_options options=$arrMonth selected=$arrForm.arrival_month}--> </select>月 <select name="arrival_day" style="<!--{if $arrErr.arrival_day != ""}-->background-color: <!--{$smarty.const.ERR_COLOR}-->;<!--{/if}-->"> <option value="">--</option> <!--{html_options options=$arrDay selected=$arrForm.arrival_day}--> </select>日 </td> </tr> <tr> <th>販売終了日</th> <td> <span class="attention"><!--{$arrErr.endsell_year}--></span> <select name="endsell_year" style="<!--{if $arrErr.endsell_year != ""}-->background-color: <!--{$smarty.const.ERR_COLOR}-->;<!--{/if}-->"> <option value="">--</option> <!--{html_options options=$arrYear selected=$arrForm.endsell_year}--> </select>年 <select name="endsell_month" style="<!--{if $arrErr.endsell_month != ""}-->background-color: <!--{$smarty.const.ERR_COLOR}-->;<!--{/if}-->"> <option value="">--</option> <!--{html_options options=$arrMonth selected=$arrForm.endsell_month}--> </select>月 <select name="endsell_day" style="<!--{if $arrErr.endsell_day != ""}-->background-color: <!--{$smarty.const.ERR_COLOR}-->;<!--{/if}-->"> <option value="">--</option> <!--{html_options options=$arrDay selected=$arrForm.endsell_day}--> </select>日 </td> </tr>
② ■data/Smarty/templates/admin/products/confirm.tpl
「販売制限数」の後に追加
<tr> <th>販売開始日</th> <td> <!--{if strlen($arrForm.arrival_year) > 0 && strlen($arrForm.arrival_month) > 0 && strlen($arrForm.arrival_day) > 0}--><!--{$arrForm.arrival_year|h}-->年<!--{$arrForm.arrival_month|h}-->月<!--{$arrForm.arrival_day|h}-->日<!--{else}-->未登録<!--{/if}--> </td> </tr> <tr> <th>販売終了日</th> <td> <!--{if strlen($arrForm.endsell_year) > 0 && strlen($arrForm.endsell_month) > 0 && strlen($arrForm.endsell_day) > 0}--><!--{$arrForm.endsell_year|h}-->年<!--{$arrForm.endsell_month|h}-->月<!--{$arrForm.endsell_day|h}-->日<!--{else}-->未登録<!--{/if}--> </td> </tr>
5 「販売終了日」と「販売開始日」をフロントページで表示する
(1)商品一覧ページ
① PC ■data/Smarty/templates/default/products/list.tpl
<!--▼買い物かご--> <input type="hidden" name="product_id" value="<!--{$id|h}-->" /> <input type="hidden" name="product_class_id" id="product_class_id<!--{$id|h}-->" value="<!--{$tpl_product_class_id[$id]}-->" /> <!--▼期間限定販売①/②--> <!--{if $arrProduct.arrival == 1 && $arrProduct.endsell == 1}--><!--◆販売期間中であれば「買い物かご」が表示される--> <!--▲期間限定販売--> ・ ・ ・ <!--▼期間限定販売②/②--> <!--{elseif $arrProduct.arrival == 0 && $arrProduct.arrival_date }--><!--◆販売期間前であれば買い物かごは表示されず、「販売開始日」が表示される--> <div class="arrival_endsell">販売開始日: <br /><span><!--{$arrProduct.arrival_date|sfDispDBDate:false|date_format:"%x"}--></span></div> <!--{/if}--> <!--{if $arrProduct.endsell_date }--><!--◆販売期間終了であれば買い物かごと販売開始日は表示されず、「販売期間終了」が表示される--> <div class="arrival_endsell">販売期間終了:<br /><span><!--{$arrProduct.endsell_date|sfDispDBDate:false|date_format:"%x"}-->まで</span></div> <!--{/if}--> <!--▲期間限定販売--> <!--▲買い物かご-->
② 携帯 ■data/Smarty/templates/mobile/products/list.tpl
<!--{strip}--> <!--{if $tpl_strnavi != " "}--> <!--{$tpl_strnavi}--> <br><br> <!--{/if}--> <!--{foreach from=$arrProducts key=i item=arrProduct}--> <!-- ▼商品 ここから --> <!-- 商品名 --><!--{$arrProduct.name|h}--><br> <!--{$smarty.const.SALE_PRICE_TITLE}-->: <!--{if $arrProduct.price02_min_inctax == $arrProduct.price02_max_inctax}--> <!--{$arrProduct.price02_min_inctax|number_format}-->円 <!--{else}--> <!--{$arrProduct.price02_min_inctax|number_format}-->円~<!--{$arrProduct.price02_max_inctax|number_format}-->円 <!--{/if}--> <!--★期間限定販売★--> <!--{if $arrProduct.arrival == 1 && $arrProduct.endsell == 1}--> <!--販売期間中--> <!--{if $arrProduct.stock_max == 0 && $arrProduct.stock_unlimited_max != 1}--> <p>申し訳ございませんが、只今品切れ中です。</p> <!--{/if}--> <!--{elseif $arrProduct.arrival == 0 && $arrProduct.arrival_date }--> <!--販売期間前--> <br>販売開始日: <!--{$arrProduct.arrival_date|sfDispDBDate:false|date_format:"%x"}--> <!--{/if}--> <!--{if $arrProduct.endsell_date }--> <br>販売期間終了:<!--{$arrProduct.endsell_date|sfDispDBDate:false|date_format:"%x"}-->まで <!--{/if}--> <br> <div align="right"> <a href="<!--{$smarty.const.MOBILE_P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->">商品詳細へ→</a> </div> <br> <!-- ▲商品 ここまで --> <!--{foreachelse}--> 該当商品がありません。<br> <!--{/foreach}--> <!--{if $tpl_strnavi != " "}--> <!--{$tpl_strnavi}--> <br><br> <!--{/if}--> <!--{/strip}-->
③ スマートフォン ■data/Smarty/templates/sphone/products/list.tpl
「商品価格」と「商品コメント」の間に
<!--★期間限定販売★--> <!--{if $arrProduct.arrival == 1 && $arrProduct.endsell == 1}--> <!--販売期間中--> <!--{if $arrProduct.stock_max == 0 && $arrProduct.stock_unlimited_max != 1}--> <p class="soldout"><em>申し訳ございませんが、只今品切れ中です。</em></p> <!--{/if}--> <!--{elseif $arrProduct.arrival == 0 && $arrProduct.arrival_date }--> <!--販売期間前--> <p><em>販売開始日:<!--{$arrProduct.arrival_date|sfDispDBDate:false|date_format:"%x"}--></em></p> <!--{/if}--> <!--{if $arrProduct.endsell_date }--> <p><em>販売期間終了:<!--{$arrProduct.endsell_date|sfDispDBDate:false|date_format:"%x"}-->まで</em></p> <!--{/if}-->
(2)商品詳細ページ
① PC ■data/Smarty/templates/default/products/detail.tpl
<!--▼買い物かご--> <!--▼期間限定販売①/③--> <!--{if $arrProduct.arrival != 1 && $arrProduct.arrival_date }--> <!--販売期間前--> <div class="arrival_endsell">販売開始日:<span><!--{$arrProduct.arrival_date|sfDispDBDate:false|date_format:"%x"}--></span></div> <!--{/if}--> <!--{if $arrProduct.endsell_date }--> <div class="arrival_endsell">販売期間終了:<span><!--{$arrProduct.endsell_date|sfDispDBDate:false|date_format:"%x"}-->まで</span></div> <!--{/if}--> <!--▲期間限定販売--> <div class="cart_area clearfix"> <input type="hidden" name="mode" value="cart" /> <input type="hidden" name="product_id" value="<!--{$tpl_product_id}-->" /> <input type="hidden" name="product_class_id" value="<!--{$tpl_product_class_id}-->" id="product_class_id" /> <input type="hidden" name="favorite_product_id" value="" /> <!--▼期間限定販売②/③--> <!--{if $arrProduct.arrival == 1 && $arrProduct.endsell == 1}--><!--◆販売期間中であれば「買い物かご」を表示する条件分岐~ここから--> <!--▲期間限定販売--> ・ ・ ・ <!--{else}--> <div class="attention">申し訳ございませんが、只今品切れ中です。</div> <!--{/if}--> <!--▼期間限定販売③/③--> <!--{elseif $arrProduct.arrival != 1}--><!--◆販売期間前のコメント--> <div class="alignC attentionSt">販売開始までしばらくお待ちください。</div> <!--{elseif $arrProduct.endsell != 1}--><!--◆販売終了後のコメント--> <div class="alignC attentionSt">販売期間は終了いたしました。</div> <!--{/if}--><!--◆販売期間中であれば「買い物かご」を表示する条件分岐~ここまで--> <!--▲期間限定販売--> <!--★お気に入り登録★-->
② 携帯 ■data/Smarty/templates/mobile/products/detail.tpl
★関連カテゴリ★の後に
<!--★関連カテゴリ★--> 関連カテゴリ:<br> <!--{section name=r loop=$arrRelativeCat}--> <!--{section name=s loop=$arrRelativeCat[r]}--> <a href="<!--{$smarty.const.ROOT_URLPATH}-->products/list.php?category_id=<!--{$arrRelativeCat[r][s].category_id}-->"><!--{$arrRelativeCat[r][s].category_name}--></a> <!--{if !$smarty.section.s.last}--><!--{$smarty.const.SEPA_CATNAVI}--><!--{/if}--> <!--{/section}--> <br> <!--{/section}--> <br> <!--{if $arrProduct.arrival != 1 && $arrProduct.arrival_date }--> <!--販売期間前--> <div>販売開始日: <!--{$arrProduct.arrival_date|sfDispDBDate:false|date_format:"%x"}--></div> <!--{/if}--> <!--{if $arrProduct.endsell_date }--> <div>販売期間終了:<!--{$arrProduct.endsell_date|sfDispDBDate:false|date_format:"%x"}-->まで</div> <!--{/if}--> <form name="form1" method="post" action="?"> <input type="hidden" name="mode" value="select"> <input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->"> <input type="hidden" name="product_id" value="<!--{$tpl_product_id}-->"> <!--{if $arrProduct.arrival == 1 && $arrProduct.endsell == 1}--><!--▼販売期間中条件分岐--> <!--{if $tpl_stock_find}--> <!--★商品を選ぶ★--> <center><input type="submit" name="select" id="cart" value="この商品を選ぶ"></center> <!--{else}--> <font color="#FF0000">申し訳ございませんが、只今品切れ中です。</font> <!--{/if}--> <!--{/if}--><!--▲販売期間中条件分岐--> </form>
③ スマートフォン ■data/Smarty/templates/sphone/products/detail.tpl
「販売価格」と「ポイント」の間に
<!--▼期間限定販売①/③--> <!--{if $arrProduct.arrival != 1 && $arrProduct.arrival_date }--> <!--販売期間前--> <p class=""><span class="mini">販売開始日:</span><em><!--{$arrProduct.arrival_date|sfDispDBDate:false|date_format:"%x"}--></em></p> <!--{/if}--> <!--{if $arrProduct.endsell_date }--> <p class=""><span class="mini">販売期間終了:</span><em><!--{$arrProduct.endsell_date|sfDispDBDate:false|date_format:"%x"}-->まで</em></p> <!--{/if}--> <!--▲期間限定販売-->
「メーカーURL」と「買い物かご」の間に
<input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->" /> <input type="hidden" name="mode" value="cart" /> <input type="hidden" name="product_id" value="<!--{$tpl_product_id}-->" /> <input type="hidden" name="product_class_id" value="<!--{$tpl_product_class_id}-->" id="product_class_id" /> <input type="hidden" name="favorite_product_id" value="" /> <!--▼期間限定販売②/③--> <!--{if $arrProduct.arrival == 1 && $arrProduct.endsell == 1}--> <!--▲期間限定販売-->
「買い物かご」の後に
<!--▼期間限定販売③/③--> <!--{elseif $arrProduct.arrival != 1}--><!--◆販売期間前のコメント--> <div class="cartin_btn attentionSt">販売開始までしばらくお待ちください。</div> <!--{elseif $arrProduct.endsell != 1}--><!--◆販売終了後のコメント--> <div class="cartin_btn attentionSt">販売期間は終了いたしました。</div> <!--{/if}--><!--◆販売期間中であれば「買い物かご」を表示する条件分岐~ここまで--> <!--▲期間限定販売-->
(3)CSS
■html/user_data/packages/default/css/contents.css
商品一覧の箇所へ
/* 期間限定販売 */ div.listrightbloc .arrival_endsell { padding:3px; background-color: #F3F3F3; font-weight:bold; } div.listrightbloc .arrival_endsell span { color:#F00; }
商品詳細の箇所へ
/* 期間限定販売 */ div#detailrightbloc .arrival_endsell { font-weight:bold; } div#detailrightbloc .arrival_endsell span { color:#F00; }