LoginSignup
0
1

More than 5 years have passed since last update.

Welcartで関連商品を表示する方法

Posted at

はじめに

WordpressのECサイト化プラグイン「Welcart」を扱った案件をやることになりました。
その上でいろんなことを整理しています。
間違っている点などあれば、是非ご指摘頂ければうれしいです。

なにをもって関連商品とみなす?

どうやって関連商品とみなすのかという方法にはいくつかあります。
1. 同じカテゴリ・タグに属している
2. マスタ登録時に関連商品を設定する
3. 商品(記事)の特徴の関係を抽出
今回は2. マスタ登録時に関連商品を設定する方法について説明します。

関連記事の設定方法

  1. 2つ以上の商品を用意
  2. 商品詳細ページを表示
    image
  3. タグに関連する商品の商品コードを設定
    関連する商品コードをタグに設定し、追加します。
    image
  4. 表示されているか確認する
    image

該当部のソース

商品詳細ページ
/wp-content/themes/welcart_default/wc_templates/wc_item_single.php

wc_item_single.php(155行目付近)
    </div><!-- end of itemsubimg -->

<?php usces_assistance_item( $post->ID, __('An article concerned', 'usces') ); ?>

</div><!-- end of itemspage -->

関連商品部分出力関数
/wp-content/plugins/usc-e-shop/functions/template_func.php

template_func.php(2748行目付近)
function usces_assistance_item($post_id, $title ){
    if (usces_get_assistance_id_list($post_id)) :
        global $post;
        $r = new WP_Query( array('post__in'=>usces_get_assistance_ids($post_id), 'ignore_sticky_posts'=>1) );
        if($r->have_posts()) :
        add_filter( 'excerpt_length', 'welcart_assistance_excerpt_length' );
        add_filter( 'excerpt_mblength', 'welcart_assistance_excerpt_mblength' );
        $width = apply_filters( 'usces_filter_assistance_item_width', 100 );
        $height = apply_filters( 'usces_filter_assistance_item_height', 100 );
?>
    <div class="assistance_item">
        <h3><?php echo $title; ?></h3>
        <ul class="clearfix">
<?php

参考リンク

g. タグ @ Welcart オンライン・マニュアル
https://www.welcart.com/documents/manual-2/%E6%96%B0%E8%A6%8F%E5%95%86%E5%93%81%E8%BF%BD%E5%8A%A0/g%E3%80%80%E3%82%BF%E3%82%B0

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1