app/Plugin/RelatedProduct42/Resource/template/front/related_product.twig line 1

Open in your IDE?
  1. <script>
  2.     $(function () {
  3.         $('#RelatedProduct-product_area').appendTo($('.ec-layoutRole__main, .ec-layoutRole__mainWithColumn, .ec-layoutRole__mainBetweenColumn'));
  4.     });
  5. </script>
  6. <div id="RelatedProduct-product_area" class="ec-shelfRole">
  7.     <div class="detailSubTitle">
  8.         <h2>その他おすすめ商品</h2>
  9.     </div>
  10.     <ul class="ec-shelfGrid">
  11.         {% for RelatedProduct in Product.RelatedProducts %}
  12.         {% set ChildProduct = RelatedProduct.ChildProduct %}
  13.         {% if ChildProduct.Status.id == constant("Eccube\\Entity\\Master\\ProductStatus::DISPLAY_SHOW") %}
  14.         <li class="ec-shelfGrid__item">
  15.             <a href="{{ url('product_detail', {id : ChildProduct.id}) }}">
  16.                 <div class="ec-shelfGrid__item-wrap">
  17.                     <div class="ec-shelfGrid__item-imageWrap">
  18.                     <p class="ec-shelfGrid__item-image">
  19.                         <img src="{{ asset(RelatedProduct.ChildProduct.main_list_image|no_image_product, 'save_image') }}">
  20.                         {# タグの表示 #}
  21.                         {% if ChildProduct.Tags|length > 0 %}
  22.                         <ul class="ec-shelfGrid__item-tags">
  23.                             {% for Tag in ChildProduct.Tags %}
  24.                             <li class="ec-shelfGrid__item-tag tag_{{ Tag.id }}"></li>
  25.                             {% endfor %}
  26.                         </ul>
  27.                         {% endif %}
  28.                     </p>
  29.                     </div>
  30.                     <div class="ec-shelfGrid__item-textWrap">
  31.                         <p class="ec-shelfGrid__item-title">{{ RelatedProduct.ChildProduct.name }}</p>
  32.                         {# 一覧説明文(description_list)を表示 #}
  33.                         {% if ChildProduct.description_list %}
  34.                         <div class="ec-shelfGrid__item-description">
  35.                             <p lang="en">{{ ChildProduct.description_list|raw|nl2br }}</p>
  36.                         </div>
  37.                         {% endif %}
  38.                         <p class="ec-shelfGrid__item-price">
  39.                             {% if RelatedProduct.ChildProduct.hasProductClass %}
  40.                                 {% if RelatedProduct.ChildProduct.getPrice02Min == RelatedProduct.ChildProduct.getPrice02Max %}
  41.                                     {{ RelatedProduct.ChildProduct.getPrice02IncTaxMin|number_format }}円(税込)
  42.                                 {% else %}
  43.                                     {{ RelatedProduct.ChildProduct.getPrice02IncTaxMin|number_format }} ~ {{ RelatedProduct.ChildProduct.getPrice02IncTaxMax|number_format }}円(税込)
  44.                                 {% endif %}
  45.                             {% else %}
  46.                                 {{ RelatedProduct.ChildProduct.getPrice02IncTaxMin|number_format }}円(税込)
  47.                             {% endif %}
  48.                         </p>
  49.                         {# カートボタンとお気に入りボタンを追加 #}
  50.                         <div class="ec-shelfGrid__item-buttons">
  51.                             {% if ChildProduct.stock_find %}
  52.                             {% if ChildProduct.hasProductClass %}
  53.                             {# 規格あり商品は詳細ページへのリンク #}
  54.                             <a href="{{ url('product_detail', {id: ChildProduct.id}) }}" class="ec-inlineBtn--action">
  55.                                 {{ '商品を見る'|trans }}
  56.                             </a>
  57.                             {% else %}
  58.                             {# 規格なし商品はカートに直接追加可能 #}
  59.                             <form action="{{ url('product_add_cart', {id: ChildProduct.id}) }}" method="post" class="related-product-form">
  60.                                 <input type="hidden" name="product_id" value="{{ ChildProduct.id }}">
  61.                                 <input type="hidden" name="quantity" value="1">
  62.                                 <input type="hidden" name="_token" value="{{ csrf_token('_token') }}">
  63.                                 <button type="submit" class="ec-blockBtn--action add-cart">
  64.                                     {{ 'カートに入れる'|trans }}
  65.                                 </button>
  66.                             </form>
  67.                             {% endif %}
  68.                             {% else %}
  69.                             <button type="button" class="ec-inlineBtn" disabled="disabled">
  70.                                 {{ 'ただいま品切れ中です'|trans }}
  71.                             </button>
  72.                             {% endif %}
  73.                             {% if BaseInfo.option_favorite_product is defined and BaseInfo.option_favorite_product %}
  74.                             {# お気に入り登録状態を確認 #}
  75.                             {% set is_favorite = false %}
  76.                             {% if is_granted('ROLE_USER') %}
  77.                             {% set Customer = app.user %}
  78.                             {% for CustomerFavoriteProduct in Customer.CustomerFavoriteProducts %}
  79.                             {% if CustomerFavoriteProduct.Product.id == ChildProduct.id %}
  80.                             {% set is_favorite = true %}
  81.                             {% endif %}
  82.                             {% endfor %}
  83.                             {% endif %}
  84.                             <form action="{{ url('product_add_favorite', {id: ChildProduct.id}) }}" method="post" class="related-product-favorite">
  85.                                 <input type="hidden" name="_token" value="{{ csrf_token('_token') }}">
  86.                                 {% if is_favorite %}
  87.                                 <button type="button" class="favoriteBtn--done" disabled="disabled">
  88.                                     {{ 'お気に入り登録済'|trans }}
  89.                                 </button>
  90.                                 {% else %}
  91.                                 <button type="submit" class="favoriteBtn--add">
  92.                                     {{ 'お気に入り'|trans }}
  93.                                 </button>
  94.                                 {% endif %}
  95.                             </form>
  96.                             {% endif %}
  97.                         </div>
  98.                     </div>
  99.                 </div>
  100.             </a>
  101.             {#<span>{{ RelatedProduct.content|raw|purify }}</span>#}
  102.             {# カートボタンとお気に入りボタンを追加 #}
  103.             <div class="ec-shelfGrid__item-buttons sp_none">
  104.                 {% if ChildProduct.stock_find %}
  105.                 {% if ChildProduct.hasProductClass %}
  106.                 {# 規格あり商品は詳細ページへのリンク #}
  107.                 <a href="{{ url('product_detail', {id: ChildProduct.id}) }}" class="ec-inlineBtn--action">
  108.                     {{ '商品を見る'|trans }}
  109.                 </a>
  110.                 {% else %}
  111.                 {# 規格なし商品はカートに直接追加可能 #}
  112.                 <form action="{{ url('product_add_cart', {id: ChildProduct.id}) }}" method="post" class="related-product-form">
  113.                     <input type="hidden" name="product_id" value="{{ ChildProduct.id }}">
  114.                     <input type="hidden" name="quantity" value="1">
  115.                     <input type="hidden" name="_token" value="{{ csrf_token('_token') }}">
  116.                     <button type="submit" class="ec-blockBtn--action add-cart">
  117.                         {{ 'カートに入れる'|trans }}
  118.                     </button>
  119.                 </form>
  120.                 {% endif %}
  121.                 {% else %}
  122.                 <button type="button" class="ec-inlineBtn" disabled="disabled">
  123.                     {{ 'ただいま品切れ中です'|trans }}
  124.                 </button>
  125.                 {% endif %}
  126.                 {% if BaseInfo.option_favorite_product is defined and BaseInfo.option_favorite_product %}
  127.                 {# お気に入り登録状態を確認 #}
  128.                 {% set is_favorite = false %}
  129.                 {% if is_granted('ROLE_USER') %}
  130.                 {% set Customer = app.user %}
  131.                 {% for CustomerFavoriteProduct in Customer.CustomerFavoriteProducts %}
  132.                 {% if CustomerFavoriteProduct.Product.id == ChildProduct.id %}
  133.                 {% set is_favorite = true %}
  134.                 {% endif %}
  135.                 {% endfor %}
  136.                 {% endif %}
  137.                 <form action="{{ url('product_add_favorite', {id: ChildProduct.id}) }}" method="post" class="related-product-favorite">
  138.                     <input type="hidden" name="_token" value="{{ csrf_token('_token') }}">
  139.                     {% if is_favorite %}
  140.                     <button type="button" class="favoriteBtn--done" disabled="disabled">
  141.                         {{ 'お気に入り登録済'|trans }}
  142.                     </button>
  143.                     {% else %}
  144.                     <button type="submit" class="favoriteBtn--add">
  145.                         {{ 'お気に入り'|trans }}
  146.                     </button>
  147.                     {% endif %}
  148.                 </form>
  149.                 {% endif %}
  150.             </div>
  151.         </li>
  152.         {% endif %}
  153.         {% endfor %}
  154.     </ul>
  155. </div>