バージョン選択

フォーラム

メニュー

オンライン状況

76 人のユーザが現在オンラインです。 (69 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 76
もっと...

サイト内検索

 > フロント機能 > 最近チェックした商品の履歴表示

フロント機能

新規スレッドを追加する

| 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
ゲスト
投稿日時: 2008/3/26 20:48
対応状況: −−−
Re: 最近チェックした商品の履歴表示
2.0.1を使用しています。赤字の部分を消して試してみたのですが
画像が表示されません。

是非使いたい機能なのですが解決策はありますでしょうか?
ゲスト
投稿日時: 2008/3/28 2:34
対応状況: −−−
Re: 最近チェックした商品の履歴表示
引用:

データをセッションに保持するのではなくクッキーにも持とうかと思ってます。

必要であれば、作成後にアップしましょうか?


クッキーで出来るのでしたら、是非アップお願いします。
ゲスト
投稿日時: 2008/3/28 11:53
対応状況: −−−
Re: 最近チェックした商品の履歴表示
クッキーの方が楽そうですね。ぜひお願いいたします。
ゲスト
投稿日時: 2008/3/28 22:01
対応状況: −−−
Re: 最近チェックした商品の履歴表示
お金出してもいいので買いたいぐらいですよ。
高額すぎるとあれですが。。。
SHIGE
投稿日時: 2008/4/12 4:19
対応状況: −−−
半人前
登録日: 2007/7/5
居住地: JAPAN
投稿: 15
Re: 最近チェックした商品の履歴表示
以前クッキーに履歴を持たせるバージョン作ると
言ってたのですが仕事が忙しくまったく触っていませんでした。

今回ECCUBEのバージョンも2.1.2の正式版が出ていたのでテストをかねて
このバージョンで、クッキーに履歴を保存するものを作成しました。

仕様としてこんな感じです。
・4件まで履歴を残せる
・重複した商品は追加しない。
・保存期間は1ヶ月間
・デザインはデフォルトテンプレートのオススメ商品のレイアウトをコピー

引用:

追加手順


閲覧履歴情報取得処理
===========================================================================
data/class/pages/products/LC_Page_Products_Detail.php

1.閲覧履歴情報処理用Function呼び出し
function process() {
$objView = new SC_SiteView();
$objCustomer = new SC_Customer();
$objQuery = new SC_Query();
$objDb = new SC_Helper_DB_Ex();

// レイアウトデザインを取得
$helper = new SC_Helper_PageLayout_Ex();
$helper->sfGetPageLayout($this, false, "products/detail.php");

// パラメータ管理クラス
$this->objFormParam = new SC_FormParam();
// パラメータ情報の初期化
$this->lfInitParam();
// POST値の取得
$this->objFormParam->setParam($_POST);

// ファイル管理クラス
$this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
// ファイル情報の初期化
$this->lfInitFile();

//2008.04.11 商品閲覧履歴取得
$this->Get_ItemHistory();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
追加

// 管理ページからの確認の場合は、非公開の商品も表示する。
if(isset($_GET['admin']) && $_GET['admin'] == 'on') {
SC_Utils_Ex::sfIsSuccess(new SC_Session());
$status = true;


2.閲覧履歴情報処理部


function lfConvertParam() {
if (!isset($this->arrForm['quantity']['value'])) $this->arrForm['quantity']['value'] = "";
$value = $this->arrForm['quantity']['value'];
$this->arrForm['quantity']['value'] = htmlspecialchars($value, ENT_QUOTES, CHAR_CODE);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
このfunction の下に追加

//2008.04.11 商品詳細閲覧履歴取得、表示データ取得処理
function Get_ItemHistory() {
$cnt = 0;
// ページを再読み込み後に表示
if (isset($_COOKIE['product'])) {
foreach ($_COOKIE['product'] as $name => $value) {
$objQuery = new SC_Query();
// DBから一覧表示用商品情報取得
$arrRet = $objQuery->select("*", "vw_products_allclass AS alldtl", "product_id =".$value);
$this->arrItemHistory[$cnt] = $arrRet[0];
$cnt = $cnt+1;
}
}

//クッキーに重複項目がないか判定処理
$duplicateFlg = true;
foreach ($_COOKIE['product'] as $name => $value) {
if($value == $_GET['product_id']){
$duplicateFlg = false;
}
}

//重複がない場合クッキーに設定
if($duplicateFlg){
if($cnt < 4){
$cnt = $cnt + 1;
setcookie("product[".$cnt."]", $_GET['product_id'],time()+60*60*24*30 );
}else{
$reNum = 1;
foreach ($_COOKIE['product'] as $name => $value) {
if($reNum > 1){
$setNum = $reNum -1;
setcookie("product[".$setNum."]", $value, time()+60*60*24*30 );
}
$reNum = $reNum + 1;
}
setcookie("product[4]", $_GET['product_id'], time()+60*60*24*30 );
}
}
}




表示部分(おすすめ商品情報を流用)
===========================================================================
data/Smarty/templates/default/detail.tpl


<!--▼閲覧履歴ここから-->
<!--{if $arrItemHistory}-->
<div id="whoboughtarea">
<h2><img src="<!--{$TPL_DIR}-->img/products/title_history.jpg" width="580" height="30" alt="閲覧履歴" /></h2>
<div class="whoboughtblock">
<!--{section name=cnt loop=$arrItemHistory}-->
<!--{if ($smarty.section.cnt.index % 2) == 0}-->
<!--{if $arrItemHistory[cnt].product_id}-->
<!-- 左列 -->
<div class="whoboughtleft">
<!--{if $arrItemHistory[cnt].main_list_image != ""}-->
<!--{assign var=image_path value="`$arrItemHistory[cnt].main_list_image`"}-->
<!--{else}-->
<!--{assign var=image_path value="`$smarty.const.NO_IMAGE_DIR`"}-->
<!--{/if}-->
<a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->">
<img src="<!--{$smarty.const.SITE_URL}-->resize_image.php?image=<!--{$image_path|sfRmDupSlash}-->&width=65&height=65" alt="<!--{$arrItemHistory[cnt].name|escape}-->" />
</a>

<!--{assign var=price02_min value=`$arrItemHistory[cnt].price02_min`}-->
<!--{assign var=price02_max value=`$arrItemHistory[cnt].price02_max`}-->
<h3><a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->"><!--{$arrItemHistory[cnt].name|escape}--></a></h3>

<p>価格<span class="mini">(税込)</span>:<span class="price">
<!--{if $price02_min == $price02_max}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{else}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->〜<!--{$price02_max|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{/if}-->円</span></p>
<p class="mini"><!--{$arrItemHistory[cnt].comment|escape|nl2br}--></p>
</div>
<!-- /左列 -->
<!--{/if}-->
<!--{/if}-->

<!--{if ($smarty.section.cnt.index % 2) != 0}-->
<!--{* assign var=nextCnt value=$smarty.section.cnt.index+1 *}-->
<!--{if $arrItemHistory[cnt].product_id}-->
<!-- 右列 -->
<div class="whoboughtright">
<a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->">
<!--{if $arrItemHistory[cnt].main_list_image != ""}-->
<!--{assign var=image_path value="`$arrItemHistory[cnt].main_list_image`"}-->
<!--{else}-->
<!--{assign var=image_path value="`$smarty.const.NO_IMAGE_DIR`"}-->
<!--{/if}-->
<img src="<!--{$smarty.const.SITE_URL}-->resize_image.php?image=<!--{$image_path|sfRmDupSlash}-->&width=65&height=65" alt="<!--{$arrItemHistory[cnt].name|escape}-->" />
</a>
<!--{assign var=price02_min value=`$arrItemHistory[cnt].price02_min`}-->
<!--{assign var=price02_max value=`$arrItemHistory[cnt].price02_max`}-->
<h3><a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->"><!--{$arrItemHistory[cnt].name|escape}--></a></h3>

<p>価格<span class="mini">(税込)</span>:<span class="price">

<!--{if $price02_min == $price02_max}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{else}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->〜<!--{$price02_max|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{/if}-->円</span></p>
<p class="mini"><!--{$arrItemHistory[cnt].comment|escape|nl2br}--></p>
</div>
<!-- /右列 -->
<!--{/if}-->
<!--{/if}-->
<!--{/section}-->
</div>
</div>
<!--{/if}-->



QUOTEタグで囲むとインデント消えてしまうんですね^^;
見ずらいかもしれませんが。。。

また、正常系の確認のみしかしておりません。
PHPはECCUBEで初めて触ったのでおかしな処理してるかもしれないので何か指摘があったら教えてください。
変数とかも適当なので。。。。
ゲスト
投稿日時: 2008/4/12 22:11
対応状況: −−−
Re: 最近チェックした商品の履歴表示
表示用のソースにごみがついてません?
確認ように掃除してみました。
エラーは出ないようになりました。

<!--▼閲覧履歴ここから-->
<!--{if $arrItemHistory}-->
<div id="whoboughtarea">
<h2><img src="<!--{$TPL_DIR}-->img/products/title_recommend.jpg" width="580" height="30" alt="閲覧履歴" /></h2>
<div class="whoboughtblock">

<!--{section name=cnt loop=$arrItemHistory}-->
<!--{if ($smarty.section.cnt.index % 2) == 0}-->
<!--{if $arrItemHistory[cnt].product_id}-->
<!-- 左列 -->
<div class="whoboughtleft">
<!--{if $arrItemHistory[cnt].main_list_image != ""}-->
<!--{assign var=image_path value="`$arrItemHistory[cnt].main_list_image`"}-->
<!--{else}-->
<!--{assign var=image_path value="`$smarty.const.NO_IMAGE_DIR`"}-->
<!--{/if}-->

<a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->">
<img src="<!--{$smarty.const.SITE_URL}-->resize_image.php?image=<!--{$image_path|sfRmDupSlash}-->&width=65&height=65" alt="<!--{$arrItemHistory[cnt].name|escape}-->" />
</a>

<!--{assign var=price02_min value=`$arrItemHistory[cnt].price02_min`}-->
<!--{assign var=price02_max value=`$arrItemHistory[cnt].price02_max`}-->
<h3><a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->"><!--{$arrItemHistory[cnt].name|escape}--></a></h3>

<p>価格<span class="mini">(税込)</span>:<span class="price">
<!--{if $price02_min == $price02_max}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{else}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->〜<!--{$price02_max|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{/if}-->円</span></p>
<p class="mini"><!--{$arrItemHistory[cnt].comment|escape|nl2br}--></p>
</div>
<!-- 左列 -->

<!--{/if}-->

<!--{if ($smarty.section.cnt.index % 2) != 0}-->
<!--{* assign var=nextCnt value=$smarty.section.cnt.index+1 *}-->
<!--{if $arrItemHistory[cnt].product_id}-->
<!-- 右列 -->
<div class="whoboughtright">
<a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->">
<!--{if $arrItemHistory[cnt].main_list_image != ""}-->
<!--{assign var=image_path value="`$arrItemHistory[cnt].main_list_image`"}-->
<!--{else}-->
<!--{assign var=image_path value="`$smarty.const.NO_IMAGE_DIR`"}-->
<!--{/if}-->
<img src="<!--{$smarty.const.SITE_URL}-->resize_image.php?image=<!--{$image_path|sfRmDupSlash}-->&width=65&height=65" alt="<!--{$arrItemHistory[cnt].name|escape}-->" />
</a>
<!--{assign var=price02_min value=`$arrItemHistory[cnt].price02_min`}-->
<!--{assign var=price02_max value=`$arrItemHistory[cnt].price02_max`}-->
<h3><a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->"><!--{$arrItemHistory[cnt].name|escape}--></a></h3>

<p>価格<span class="mini">(税込)</span>:<span class="price">

<!--{if $price02_min == $price02_max}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{else}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->〜<!--{$price02_max|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{/if}-->円</span></p>
<p class="mini"><!--{$arrItemHistory[cnt].comment|escape|nl2br}--></p>
</div>
<!-- 右列 -->
<!--{/if}-->
<!--{/if}-->


</div>
<!--{/if}-->
<!--{/section}-->

</div>
<!--{/if}-->
ゲスト
投稿日時: 2008/4/12 22:25
対応状況: −−−
Re: 最近チェックした商品の履歴表示
これのブロック化はソースをいじればできるのかな
SHIGE
投稿日時: 2008/4/13 2:16
対応状況: −−−
半人前
登録日: 2007/7/5
居住地: JAPAN
投稿: 15
Re: 最近チェックした商品の履歴表示
ご指摘ありがとうございます。

しかし、当方の環境で表示すると履歴が2個までしか表示されなくなってしまいました。
ロジック上は4個出るはずなのでデザイン上の問題でしょうか?
EC-CUBE2.1.2のHTMLをそのまま使ってます。

当方ではこんな感じで表示されてますよ。


あと、商品コメント取得できていなかったので修正しました。

data/Smarty/templates/default/detail.tpl

<p class="mini"><!--{$arrItemHistory[cnt].comment|escape|nl2br}--></p>
           ↓↓↓↓↓↓↓↓↓↓
<p class="mini"><!--{$arrItemHistory[cnt].main_list_comment|escape|nl2br}--></p>


PHPは後置加算子とか使えるんですね
当たり前か。。。
ゲスト
投稿日時: 2008/4/13 21:34
対応状況: −−−
Re: 最近チェックした商品の履歴表示
SHIGEさんのとおりに試したところエラーはないのですが
履歴が表示されません・・・

試しに/data/Smarty/templates/defaultのtop.tplなどにも
表示箇所を記述してみたのですが結果は変わらずでした。

なにかアドバイスを頂けますと幸いなのですが宜しくお願い致します。
V2.0.1を使っています。
ゲスト
投稿日時: 2008/4/13 22:17
対応状況: −−−
Re: 最近チェックした商品の履歴表示
初回選択時、クッキーがない為エラーがでますね。
phpのエラーを表示しなければ問題ないですが
« 1 (2) 3 4 5 6 »
| 新しいものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,300名です
総投稿数は109,692件です

投稿数ランキング

1
seasoft
7365
2
468
3217
3
AMUAMU
2712
4
nanasess
2303
5
umebius
2085
6
yuh
1818
7
h_tanaka
1610
8
red
1568
9
mcontact
1240
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
796
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.