売り切れのときのみ「売切れ」を表示するのであれば、
'売切れ' == usces_the_itemZaiko('return')
という条件分岐を入れればOKです。
esc_html(usces_the_itemZaiko('return'))
のところを、
( '売切れ' == usces_the_itemZaiko('return') ? usces_the_itemZaiko('return') : '' )
に書き換えればよいと思います。
何度かご説明いたしておりますが、$list に代入している部分で '”>ID) . ‘”>’ の部分が直っておりません。
まずは、コードが正常にならなければ次へ進む事はできません。
恐らくこうされたいのではないですか?現在のコードと見比べてみてください。
$list = '<li id="ill_li" class="item_list_layout_li" style="text-align: center; overflow: hidden; display: block; float: left; padding:'.$lipadding.'px; width:'.$liwidth.'px; height:'.$liheight.'px; margin-right:'.$limargin.'px; margin-bottom:'.$limargin.'px; '.$border.'">'. usces_the_itemImage(0, $imgwidth, $imgheight, $post, 'return' ) . '<div class="thumtitle">' . esc_html(usces_the_itemName('return')) . '</div><div class="price">' . __('$', 'usces') . number_format(usces_the_firstPrice('return')) . $usces->getGuidTax() . '</div><div class="exp">' . $excerpt . '</div><div class="zaiko">' . esc_html(usces_the_itemZaiko('return'));
これでよければ、次の問題の在庫の表示となります。
そもそも、商品一覧は商品単位の表示となります。しかし在庫はSKU単位となっており、1商品の中にSKUが複数あった場合は、どのSKUの在庫を表示して良いのかWelcart は判断できません。
とりあえず、最初のSKUの情報を取得するのであれば、$border = $liborder ? '' : 'border:0px';
の下に、usces_have_skus();
と追加してください。
SKUが1つだけの場合は問題ありません。複数ある場合は最初のSKUが適用されます。
文字色についてはスタイルシートの問題です。class=”price” と有りますので適宜CSSを調整してください。
nanbu様ありがとうございます!!
下記の様に書いたら完璧でした!、ですが売り切れになっている商品も在庫ありの表示になってしまいます…どうしてでしょうか?…これはフィルターフックの問題では有りませんよね…
文字も赤にできません…
質問ばかりで申し訳有りません。
<?php
add_filter(‘item_list_layout_filter_list’, ‘my_item_list_layout_filter_list’, 10, 3);
function my_item_list_layout_filter_list(){
global $usces;
$args = func_get_args();
$post = $args[1];
$opts = $args[2];
$width = $opts;
$colum = $opts;
$limargin = $opts;
$lipadding = $opts;
$liborder = $opts;
$liwidth = ($width + $limargin) / $colum – $limargin – ($lipadding * 2) – ($liborder * 2);
$liheight = $opts – $lipadding * 2;
$txtheight = $opts;
$imgwidth = $liwidth;
$imgheight = $liheight – $txtheight;
$border = $liborder ? ” : ‘border:0px’;
$list = ‘<li id=”ill_li” class=”item_list_layout_li” style=”text-align: center; overflow: hidden; display: block; float: left; padding:’.$lipadding.’px; width:’.$liwidth.’px; height:’.$liheight.’px; margin-right:’.$limargin.’px; margin-bottom:’.$limargin.’px; ‘.$border.'”>ID) . ‘”>’ . usces_the_itemImage(0, $imgwidth, $imgheight, $post, ‘return’ ) . ‘<div class=”thumtitle”>’ . esc_html(usces_the_itemName(‘return’)) . ‘</div><div class=”price”>’ . __(‘$’, ‘usces’) . number_format(usces_the_firstPrice(‘return’)) . $usces->getGuidTax() . ‘</div><div class=”exp”>’ . $excerpt . ‘</div><div class=”zaiko”>’ . esc_html(usces_the_itemZaiko(‘return’)) . ” . “”;
return $list;
}
?>
お忙しい所わざわざご教授感謝致します、下記コードに編集致しましたがエラーが出ます…
書き方間違えておりますでしょうか?
コード
<?php
add_filter(‘item_list_layout_filter_list’, ‘my_item_list_layout_filter_list’, 10, 3);
global $usces;function my_item_list_layout_filter_list(){
$args = func_get_args();
$post = $args[1];
$opts = $args[2];
$width = $opts;
$colum = $opts;
$limargin = $opts;
$lipadding = $opts;
$liborder = $opts;
$liwidth = ($width + $limargin) / $colum – $limargin – ($lipadding * 3) – ($liborder * 3);
$liheight = $opts – $lipadding * 3;
$txtheight = $opts;
$imgwidth = $liwidth;
$imgheight = $liheight – $txtheight;
$border = $liborder ? ” : ‘border:0px’;
$list = ‘<li id=”ill_li” class=”item_list_layout_li” style=”text-align: center; overflow: hidden; display: block; float: left; padding:’.$lipadding.’px; width:’.$liwidth.’px; height:’.$liheight.’px; margin-right:’.$limargin.’px; margin-bottom:’.$limargin.’px; ‘.$border.’ “>ID) . ‘ “>’. usces_the_itemImage(0, $imgwidth, $imgheight, $post, ‘return’ ) . ‘<div class=”thumtitle”>’ . esc_html(usces_the_itemName(‘return’)) . ‘</div><div class=”zaiko”>’ . esc_html(usces_the_itemZaiko(‘return’)) . ‘</div><div class=”price”>’ . __(‘$’, ‘usces’) . number_format(usces_the_firstPrice(‘return’)) . $usces->getGuidTax() . ‘</div><div class=”exp”>’ . $excerpt . ‘</div>’ ;
return $list;
}
?>
エラーコード
Parse error: syntax error, unexpected ‘”‘ in /export/sd203/www/jp/r/e/gmoserver/7/9/sd0211679/imperial-designworks.com/blog/wp-content/themes/gents-company/functions.php on line 19
申し訳ありません、function.phpに下記コードを追加致しました。
<?php
add_filter(‘item_list_layout_filter_list’, ‘my_item_list_layout_filter_list’, 10, 3);
function my_item_list_layout_filter_list(){
$args = func_get_args();
$post = $args[1];
$opts = $args[2];
$opts = $args[3];
$width = $opts;
$colum = $opts;
$limargin = $opts;
$lipadding = $opts;
$liborder = $opts;
$liwidth = ($width + $limargin) / $colum – $limargin – ($lipadding * 3) – ($liborder * 3);
$liheight = $opts – $lipadding * 3;
$txtheight = $opts;
$imgwidth = $liwidth;
$imgheight = $liheight – $txtheight;
$border = $liborder ? ” : ‘border:0px’;
$list = ‘<li id=”ill_li” class=”item_list_layout_li” style=”text-align: center; overflow: hidden; display: block; float: left; padding:’.$lipadding.’px; width:’.$liwidth.’px; height:’.$liheight.’px; margin-right:’.$limargin.’px; margin-bottom:’.$limargin.’px; ‘.$border.'”>ID) . ‘”>’ . usces_the_itemImage(0, $imgwidth, $imgheight, $post, ‘return’ ) . ‘<div class=”thumtitle”>’ . esc_html(usces_the_itemName(‘return’)) . ‘</div><div class=”zaiko”>’ . esc_html(usces_the_itemZaiko(‘return’)) . ‘</div><div class=”price”>’ . __(‘$’, ‘usces’) . number_format(usces_the_firstPrice(‘return’)) . $usces->getGuidTax() . ‘</div><div class=”exp”>’ . $excerpt . ‘</div>’ ;
return $list;
}
?>
するとエラーで下記コードが出てしまいます。
Warning: Division by zero in /export/sd203/www/jp/r/e/gmoserver/7/9/sd0211679/imperial-designworks.com/blog/wp-content/themes/gents-company/functions.php on line 13
Fatal error: Call to a member function getGuidTax() on a non-object in /export/sd203/www/jp/r/e/gmoserver/7/9/sd0211679/imperial-designworks.com/blog/wp-content/themes/gents-company/functions.php on line 20
どうか宜しくお願い致します。
こんにちは。
トップページのイメージはあくまでサンプルとして利用いたしておりますので、残念ながらショップのイメージとしてはご利用いただけません。
新着商品のグリッドを追加したい場合は、テーマ内のhome.php を編集します。
まず以下の行をそっくりそのままコピーしてすぐ下にペーストします。
<div id="top_reco">
<h3 class="title"><img src="<?php bloginfo('template_url'); ? />/images/osusume.png" alt="<?php _e('Items recommended','usces') ?>" /><?php _e('Items recommended','usces') ?></h3>
<ul class="clearfix">
<?php $reco_ob = new wp_query(array('category_name'=>'itemreco', 'posts_per_page'=>10, 'post_status'=>'publish')); ?>
<?php if ($reco_ob->have_posts()) : while ($reco_ob->have_posts()) : $reco_ob->the_post(); usces_the_item(); ?>
<li class="thumbnail_box">
<div class="thumimg"><a href="<?php the_permalink() ?>"><?php usces_the_itemImage($number = 0, $width = 108, $height = 108 ); ?></a></div>
<div class="thumtitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php usces_the_itemName(); ?> (<?php usces_the_itemCode(); ?>)</a></div>
<?php if (usces_is_skus()) : ?>
<div class="price"><?php _e('$', 'usces'); ?><?php usces_the_firstPrice(); ?><?php usces_guid_tax(); ?></div>
<?php endif; ?>
</li>
<?php endwhile; else: ?>
<li id="nothing"><?php _e('Sorry, no posts matched your criteria.'); ?></li>
<?php endif; wp_reset_query(); ?>
</ul>
</div>
そうすることでお勧め商品が2回表示されることになります。後は下のグリッドを新商品に変更します。
<h3 class="title">****</h3>
をお好みに修正してください。
次に、
**** new wp_query(array('category_name'=>'itemreco', ****
の部分を
**** new wp_query(array('category_name'=>'itemnew', ****
に変更してください。
これでたぶんOKです。
早速の返信ありがとうございます。
wc_templates/wc_item_single.php
を修正したのですが、うまく反映されず・・・
しかし、下記のファイルを修正したところ「通常価格」という文字を
削除することができました。
wp-content/plugins/usc-e-shop/templates/single_item.php
20行目~21行目の文
$usces_sellingprice, __(‘selling price’, ‘usces’),
を削除
↓
$html .= ‘<div class=”field_name”>’ . apply_filters(‘usces_filter_sellingprice_label’, usces_guid_tax(‘return’)) . ‘</div>’.”n”;
$html .= ‘<div class=”field_price”>’ . usces_the_itemPriceCr(‘return’) . ‘</div>’.”n”;
single_item.phpはバージョンアップの上書き防止のため退避する場所におきました。
大変ありがとうございました。
こんにちは。
「もし商品画像があったら」の記述はこの様になります。
<?php if (usces_the_itemImageURL(0, 'return')): ?>
はじめまして。
もしかすると初歩的なことかもしれませんが、
ご教示いただけましたら幸いです。
独自テンプレートのカテゴリーアーカイブのページに、
タイトル(商品名)と商品画像を表示させたく思っています。
その際に、もしWelcartの商品画像があればusces_the_itemImageURL(0)を出力、
なければダミー画像を表示、と下記みたくしたいと思っております。
<?php if (//もし商品画像があったら): ?>
<img src=”<?php usces_the_itemImageURL(0); ?>” />
<?php else: ?>
<img src=”(NO IMAGE画像)” />
<?php endif ?>
もしかすると、この先elseifなどの条件分岐が発生するかもしれないので、
if内で処理できたら。
また、できればCSSの小技を使わず解決したいです。
この場合、商品画像がある場合は、どういった記述になるでしょうか?
お世話になります。
デフォルトのテンプレートを少しカスタマイズして利用しているのですが、1.04にアップデートしたところTOPの画像と個別の商品ページの画像が表示されなくなってしまいました。
具体的には
・各商品の最初の商品が見られなくなっている
・ソースを見ると
<div class=”thumimg”></div>というようにリンクで囲まれているべき画像部分がすべてなくなっている状態
(TOPや個別ページの<?php usces_the_itemImage…の部分が動作していないのでしょうか…)
という感じです。
カスタマイズに関しては、TOPに関してはサムネイルのサイズを変えている程度なので、大きな変更はしていない気がするのですが…。
カスタマイズしたものなのでサポート外とは存じますが、ヒントだけでもいただけたらと思います。
よろしくお願い致します。
Welcart のバージョン:1.04
症状を確認したブラウザ:すべて
サーバー(会社名、サービス名):さくらインターネット
SSLの利用: 無し
WordPress のパーマリンク設定:数字ベース
こんにちは。
商品詳細ページであるならば、計算用の値として定価は usces_the_itemCpriceCr(‘return’)、売価はusces_the_itemPriceCr(‘return’)で取得できます。
こんにちは。
テンプレート内の以下の部分を削除してしまってください。Welcart 数量フィールドが無い場合、数量1として扱いますので、削除しても問題はありません。
<?php _e('Quantity', 'usces'); ?><?php usces_the_itemQuant(); ?>
こんにちは。
価格を表示するためには、以下のテンプレートタグが実行されていなくてはいけません。
have_posts()、the_post()、usces_the_item()、usces_have_skus()
どこに設置されていても構いませんが、実行される順はこの通りです。一度、確認してみてください。
いつもお世話になっております。
デフォルトのテンプレートにあるsearch.phpに
価格の表示をしたいなと考えていますが、
下記の様に他のテンプレートファイルでは表示される
価格の部分を貼り付けても検索結果に反映されません。
(商品名などは表示されます。)
<?php if (usces_is_skus()) : usces_have_skus()?>
<?php if ( '売切れ' == usces_the_itemZaiko('return')): ?>
<div class="price"><span class="urikire">売切れました</span></div>
<?php else: ?>
<div class="price"><?php _e('$', 'usces'); ?><?php usces_the_firstPrice(); ?><?php usces_guid_tax(); ?></div>
<?php endif; ?>
<?php endif; ?>
何が原因と考えられますでしょうか。
こんにちは。
上記のトピックに出てくるコードの中の<?php usces_the_itemZaiko(); ?>
をsold out とすれば良いかと思います。