app/template/default/Block/recommend_product_block.twig line 1

Open in your IDE?
  1. {#
  2. * This file is part of the Recommend Product plugin
  3. *
  4. * Copyright (C) EC-CUBE CO.,LTD. All Rights Reserved.
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. #}
  9. {# 親テンプレートにスライダーが実装されていれば読み込まない #}
  10. {% set include_slide_js = include_slide_js is not defined or include_slide_js %}
  11. {% block stylesheet %}
  12.     {% if include_slide_js %}
  13.         <link rel="stylesheet" href="{{ asset('assets/css/splide.min.css') }}">
  14.         <link rel="stylesheet" href="{{ asset('assets/css/slide.css') }}">
  15.     {% endif %}
  16. {% endblock %}
  17. {% block javascript %}
  18.     {% if include_slide_js %}
  19.         <script src="{{ asset('assets/js/vendor/splide.min.js') }}"></script>
  20.         <script src="{{ asset('assets/js/slide.js') }}"></script>
  21.     {% endif %}
  22. {% endblock %}
  23. {% set recommend_products = repository('Plugin\\Recommend42\\Entity\\RecommendProduct').getRecommendProduct %}
  24. {% if recommend_products is not empty %}
  25.     {% if recommend_product is same as (true) %}
  26.         <!-- ▼item_list▼ -->
  27.         <article class="m-article width-full">
  28.             <div id="recently-viewed_splide" class="m-article_inner splide" aria-labelledby="recently-viewd_carousel-heading">
  29.                 <header id="recently-viewd_carousel-heading" class="m-header h-2 space-wide">
  30.                     <h2 class="title">おすすめ商品</h2>
  31.                 </header>
  32.                 <section class="carousel splide__track">
  33.                     <ul class="carousel_list splide__list">
  34.                         {% for RecommendProduct in recommend_products %}
  35.                             <li class="carousel_list_item splide__slide">
  36.                                 <section class="m-product_label">
  37.                                     {% if is_granted('ROLE_USER') %}
  38.                                         {% if customer is not defined %}
  39.                                             {% if repository('Eccube\\Entity\\CustomerFavoriteProduct').isFavorite(Customer, RecommendProduct.Product) %}
  40.                                                 <button class="label-favorite active favorite_product" data-customer="{{ Customer.id }}" data-product="{{ RecommendProduct.Product.id }}"></button>
  41.                                             {% else %}
  42.                                                 <button class="label-favorite favorite_product" data-customer="{{ Customer.id }}" data-product="{{ RecommendProduct.Product.id }}"></button>
  43.                                             {% endif %}
  44.                                         {% else %}
  45.                                             {% if repository('Eccube\\Entity\\CustomerFavoriteProduct').isFavorite(customer, RecommendProduct.Product) %}
  46.                                                 <button class="label-favorite active favorite_product" data-customer="{{ customer.id }}" data-product="{{ RecommendProduct.Product.id }}"></button>
  47.                                             {% else %}
  48.                                                 <button class="label-favorite favorite_product" data-customer="{{ customer.id }}" data-product="{{ RecommendProduct.Product.id }}"></button>
  49.                                             {% endif %}
  50.                                         {% endif %}
  51.                                     {% else %}
  52.                                         <button class="modal-favorite label-favorite" data-product="{{ RecommendProduct.Product.id }}"></button>
  53.                                     {% endif %}
  54.                                 </section>
  55.                                 {% if RecommendProduct.Product.ProductClasses.0.NormalProduct is not null %}
  56.                                 <section class="m-product_label">
  57.                                     <p class="label-subscription">定期購入</p>
  58.                                 </section>
  59.                                 <a href="{{ path('product_detail', {'id': RecommendProduct.Product.id}) }}">
  60.                                     <p class="carousel_list_item_image">
  61.                                         <img src="{{ asset(RecommendProduct.Product.ProductClasses.0.NormalProduct.mainFileName|no_image_product, "save_image") }}"
  62.                                              alt="{{ RecommendProduct.Product.getName }}">
  63.                                         {% else %}
  64.                                         <a href="{{ path('product_detail', {'id': RecommendProduct.Product.id}) }}">
  65.                                             <p class="carousel_list_item_image">
  66.                                                 <img src="{{ asset(RecommendProduct.Product.mainFileName|no_image_product, "save_image") }}"
  67.                                                      alt="{{ RecommendProduct.Product.getName }}">
  68.                                                 {% endif %}
  69.                                             </p>
  70.                                             {% if RecommendProduct.Product.getProductCategories is not empty %}
  71.                                                 <p class="carousel_list_item_category">{{ RecommendProduct.Product.getProductCategories.0.getCategory.getName }}</p>
  72.                                             {% endif %}
  73.                                             <p class="carousel_list_item_name">{{ RecommendProduct.Product.getName }}</p>
  74.                                             <p class="carousel_list_item_price">
  75.                                                 {% if RecommendProduct.Product.hasProductClass %}
  76.                                                     {% if RecommendProduct.Product.getPrice02Min == RecommendProduct.Product.getPrice02Max %}
  77.                                                         {{ RecommendProduct.Product.getPrice02IncTaxMin|price }}
  78.                                                         <span>税込</span>
  79.                                                     {% else %}
  80.                                                         {{ RecommendProduct.Product.getPrice02IncTaxMin|price }} ~ {{ RecommendProduct.Product.getPrice02IncTaxMax|price }}
  81.                                                         <span>税込</span>
  82.                                                     {% endif %}
  83.                                                 {% else %}
  84.                                                     {{ RecommendProduct.Product.getPrice02IncTaxMin|price }}<span>税込</span>
  85.                                                 {% endif %}
  86.                                             </p>
  87.                                         </a>
  88.                                         {% set avg = repository('Plugin\\ProductReview42Plus\\Entity\\ProductReview').getOpenAvgAll(RecommendProduct.Product) %}
  89.                                         <a href="{{ path('mypage_history', {'order_no': RecommendProduct.id}) }}">
  90.                                             <section class="m-rating small">
  91.                                                 <div class="m-rating_label"
  92.                                                      data-score="{{ avg['recommend_avg']|round(1)|default(0) }}"></div>
  93.                                                 <span>({{ avg['review_count']|default(0) }})</span>
  94.                                             </section>
  95.                                         </a>
  96.                                     </p>
  97.                                 </a>
  98.                             </li>
  99.                         {% endfor %}
  100.                     </ul>
  101.                 </section>
  102.                 <section class="carousel_arrows bottom">
  103.                     <section class="splide__arrows splide__arrows--ltr">
  104.                         <button class="splide__arrow splide__arrow--prev" type="button" aria-label="Previous slide" aria-controls="splide01-track">
  105.                             <img src="{{ asset('assets/img/customize/icon_arrow.svg') }}" alt="prev" width="6" height="12"/>
  106.                         </button>
  107.                         <button class="splide__arrow splide__arrow--next " type="button" aria-label="Next slide" aria-controls="splide01-track">
  108.                             <img src="{{ asset('assets/img/customize/icon_arrow.svg') }}" alt="next" width="6" height="12"/>
  109.                         </button>
  110.                     </section>
  111.                 </section>
  112.             </div>
  113.         </article>
  114.     {% endif %}
  115. {% endif %}
  116. {% if productHistory is defined and productHistory is not empty %}
  117.     {% if recently_viewd is same as (true) %}
  118.         <article class="m-article width-full">
  119.             <div id="recently-viewed_splide" class="m-article_inner splide" aria-labelledby="recently-viewd_carousel-heading">
  120.                 <header id="recently-viewd_carousel-heading" class="m-header h-2 space-wide">
  121.                     {% if recently_viewd_title is same as (false) %}
  122.                         <h2 class="content_header_title">
  123.                             RECENTLY VIEWED
  124.                             <span>最近見た商品</span>
  125.                         </h2>
  126.                     {% else %}
  127.                         <h2 class="title">最近見た商品</h2>
  128.                     {% endif %}
  129.                 </header>
  130.                 <section class="carousel splide__track">
  131.                     <ul class="carousel_list splide__list">
  132.                         {% for ph in productHistory %}
  133.                             {% if ph.ProductClasses.0.NormalProduct is null %}
  134.                                 <li class="carousel_list_item splide__slide">
  135.                                     <section class="m-product_label">
  136.                                         {% if is_granted('ROLE_USER') %}
  137.                                             {% if customer is not defined %}
  138.                                                 {% if repository('Eccube\\Entity\\CustomerFavoriteProduct').isFavorite(Customer, ph) %}
  139.                                                     <button class="label-favorite active favorite_product" data-customer="{{ Customer.id }}" data-product="{{ ph.id }}"></button>
  140.                                                 {% else %}
  141.                                                     <button class="label-favorite favorite_product" data-customer="{{ Customer.id }}" data-product="{{ ph.id }}"></button>
  142.                                                 {% endif %}
  143.                                             {% else %}
  144.                                                 {% if repository('Eccube\\Entity\\CustomerFavoriteProduct').isFavorite(customer, ph) %}
  145.                                                     <button class="label-favorite active favorite_product" data-customer="{{ customer.id }}" data-product="{{ ph.id }}"></button>
  146.                                                 {% else %}
  147.                                                     <button class="label-favorite favorite_product" data-customer="{{ customer.id }}" data-product="{{ ph.id }}"></button>
  148.                                                 {% endif %}
  149.                                             {% endif %}
  150.                                         {% else %}
  151.                                             <button class="modal-favorite label-favorite" data-product="{{ ph.id }}"></button>
  152.                                         {% endif %}
  153.                                     </section>
  154.                                     {% if ph.ProductClasses.0.NormalProduct is not null %}
  155.                                     <section class="m-product_label">
  156.                                         <p class="label-subscription">定期購入</p>
  157.                                     </section>
  158.                                     <a href="{{ path('product_detail', {'id': ph.id}) }}">
  159.                                         <p class="carousel_list_item_image">
  160.                                             <img src="{{ asset(ph.ProductClasses.0.NormalProduct.mainFileName|no_image_product, "save_image") }}" alt="{{ ph.getName }}">
  161.                                         {% else %}
  162.                                     <a href="{{ path('product_detail', {'id': ph.id}) }}">
  163.                                         <p class="carousel_list_item_image">
  164.                                             <img src="{{ asset(ph.mainFileName|no_image_product, "save_image") }}" alt="{{ ph.getName }}">
  165.                                         {% endif %}
  166.                                         </p>
  167.                                         {% if ph.getProductCategories is not empty %}
  168.                                         <p class="carousel_list_item_category">{{ ph.getProductCategories.0.getCategory.getName }}</p>
  169.                                         {% endif %}
  170.                                         <p class="carousel_list_item_name">{{ ph.getName }}</p>
  171.                                         <p class="carousel_list_item_price">
  172.                                             {% if ph.hasProductClass %}
  173.                                                 {% if ph.getPrice02Min == ph.getPrice02Max %}
  174.                                                     {{ ph.getPrice02IncTaxMin|price }}<span>税込</span>
  175.                                                 {% else %}
  176.                                                     {{ ph.getPrice02IncTaxMin|price }} ~ {{ ph.getPrice02IncTaxMax|price }}<span>税込</span>
  177.                                                 {% endif %}
  178.                                             {% else %}
  179.                                                 {{ ph.getPrice02IncTaxMin|price }}<span>税込</span>
  180.                                             {% endif %}
  181.                                         </p>
  182.                                     </a>
  183.                                     {% set avg_ph = repository('Plugin\\ProductReview42Plus\\Entity\\ProductReview').getOpenAvgAll(ph) %}
  184.                                     <a href={{ path('mypage_history', {'order_no': ph.id}) }}>
  185.                                         <section class="m-rating small">
  186.                                             <div class="m-rating_label" data-score="{{ avg_ph['recommend_avg']|round(1)|default(0) }}"></div>
  187.                                             <span>({{ avg_ph['review_count']|default(0) }})</span>
  188.                                         </section>
  189.                                     </a>
  190.                                 </li>
  191.                             {% endif %}
  192.                         {% endfor %}
  193.                     </ul>
  194.                 </section>
  195.                 <section class="carousel_arrows bottom">
  196.                     <section class="splide__arrows splide__arrows--ltr">
  197.                         <button class="splide__arrow splide__arrow--prev" type="button" aria-label="Previous slide" aria-controls="splide01-track">
  198.                             <img src="{{ asset('assets/img/customize/icon_arrow.svg') }}" alt="prev" width="6" height="12"/>
  199.                         </button>
  200.                         <button class="splide__arrow splide__arrow--next " type="button" aria-label="Next slide" aria-controls="splide01-track">
  201.                             <img src="{{ asset('assets/img/customize/icon_arrow.svg') }}" alt="next" width="6" height="12"/>
  202.                         </button>
  203.                     </section>
  204.                 </section>
  205.             </div>
  206.         </article>
  207.     {% endif %}
  208. {% endif %}
  209. <!-- ▲item_list▲ -->