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

Open in your IDE?
  1. <script>
  2.     $(function () {
  3.         let related = $('#js-related-container');
  4.         if(related.find('.p-product-related__slide').length){
  5.             related.appendTo($('#js-related-area'));
  6.         } else {
  7.             related.remove();
  8.         }
  9.         if (window.matchMedia( '(max-width: 767px)' ).matches) {
  10.             if($('#js-related-slider').find('.p-product-related__slide').length<=1){
  11.                 $('#js-related-slider').addClass('no-slide');
  12.             } else {
  13.                 $('#js-related-slider').slick({
  14.                   autoplay: false,
  15.                   arrows: false,
  16.                   dots:false,
  17.                   centerMode: true,
  18.                   centerPadding: '10%',
  19.                 });
  20.             }
  21.         }
  22.     });
  23. </script>
  24. <div class="p-product-related__container" id="js-related-container">
  25.     <h2 class="p-product-related__ttl c-ttl-sec">
  26.         <span class="jp">関連商品</span>
  27.         <span class="en">RELATED PRODUCTS</span>
  28.     </h2>
  29.     <div class="p-product-related__slider" id="js-related-slider">
  30.         {% for RelatedProduct in Product.RelatedProducts %}
  31.             {% set ChildProduct = RelatedProduct.ChildProduct %}
  32.             {% if ChildProduct.Status.id == constant("Eccube\\Entity\\Master\\ProductStatus::DISPLAY_SHOW") %}
  33.                 {% set group1 = repository("Plugin\\CustomerGroup42\\Entity\\Group").find(1) %}
  34.                 {% set group2 = repository("Plugin\\CustomerGroup42\\Entity\\Group").find(2) %}
  35.                 {% set group3 = repository("Plugin\\CustomerGroup42\\Entity\\Group").find(3) %}
  36.                 {% set group4 = repository("Plugin\\CustomerGroup42\\Entity\\Group").find(4) %}
  37.                 {% if group1 is not null and is_granted('view', group1) or group2 is not null and is_granted('view', group2) or group3 is not null and is_granted('view', group3) or group4 is not null and is_granted('view', group4) %} {# ヒートセラピー会員 ログイン時 #}
  38.                     <div class="p-product-related__slide">
  39.                         <a href="{{ url('product_detail', {id : ChildProduct.id}) }}" class="p-product-related__slide-link">
  40.                             <div class="p-product-related__slide-img-wrap">
  41.                                 <img src="{{ asset(RelatedProduct.ChildProduct.main_list_image|no_image_product, 'save_image') }}">
  42.                             </div>
  43.                             <h3 class="p-product-related__slide-ttl">{{ RelatedProduct.ChildProduct.name }}</h3>
  44.                         </a>
  45.                     </div>
  46.                 {% else %} {# ヒートセラピー会員 非ログイン時 #}
  47.                     {% if ChildProduct.ProductCategories[0] is not defined or ChildProduct.ProductCategories[0] is defined and ChildProduct.ProductCategories[0].category_id != 10 %}
  48.                         <div class="p-product-related__slide">
  49.                             <a href="{{ url('product_detail', {id : ChildProduct.id}) }}" class="p-product-related__slide-link">
  50.                                 <div class="p-product-related__slide-img-wrap">
  51.                                     <img src="{{ asset(RelatedProduct.ChildProduct.main_list_image|no_image_product, 'save_image') }}">
  52.                                 </div>
  53.                                 <h3 class="p-product-related__slide-ttl">{{ RelatedProduct.ChildProduct.name }}</h3>
  54.                             </a>
  55.                         </div>
  56.                     {% endif %}
  57.                 {% endif %}
  58.             {% endif %}
  59.         {% endfor %}
  60.     </div>
  61. </div>