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

Open in your IDE?
  1. {# 
  2. This file is part of Refine
  3. Copyright(c) 2024 Refine Co.,Ltd. All Rights Reserved.
  4. https://www.re-fine.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {% if Page.url == 'product_list' and  Product is defined %}
  9.     {% if BaseInfo.option_favorite_product %}
  10.         {% set is_favorite = false %}
  11.         {% if is_granted('ROLE_USER') %}
  12.             {% set CustomerFavoriteProducts = repository('Eccube\\Entity\\CustomerFavoriteProduct').findBy({ Customer: app.user.id }) %}
  13.             {% for CustomerFavoriteProduct in CustomerFavoriteProducts if CustomerFavoriteProduct.Product.id == Product.id %}
  14.                 {% set is_favorite = true %}
  15.             {% endfor %}
  16.         {% endif %}
  17.         {# {% if is_favorite == false %}
  18.             <form action="{{ url('product_list_add_favorite', {id:Product.id}) }}{% for key, id in app.request.query %}&{{ key }}={{ id }}{% endfor %}" method="post">
  19.                 <div class="ec-productRole__btn">
  20.                     <button type="submit" id="favorite" class="ec-blockBtn--cancel">
  21.                         {{ 'お気に入りに追加'|trans }}
  22.                     </button>
  23.                 </div>
  24.             </form>
  25.         {% else %}
  26.             <form action="{{ url('product_list_delete_favorite', {id:Product.id}) }}{% for key, id in app.request.query %}&{{ key }}={{ id }}{% endfor %}" method="post">
  27.                 <div class="ec-productRole__btn">
  28.                     <button type="submit" id="favorite" class="ec-blockBtn--cancel">
  29.                         {{ 'お気に入りから削除'|trans }}
  30.                     </button>
  31.                 </div>
  32.             </form>
  33.         {% endif %} #}
  34.         {% if is_favorite == false %}
  35.         <div class="product_list-favoriteBtn">
  36.             <form action="{{ url('product_list_add_favorite', {id:Product.id}) }}{% for key, id in app.request.query %}&{{ key }}={{ id }}{% endfor %}" method="post">
  37.                 <div class="ec-productRole__btn">
  38.                     <button type="submit" id="favorite" class="ec-blockBtn--cancel ec-blockBtn--favorite">
  39.                         <img src="{{ asset('assets/img/Icon-heart.svg') }}" alt="お気に入りに追加">
  40.                     </button>
  41.                 </div>
  42.             </form>
  43.             </div
  44.         {% else %}
  45.          <div class="product_list-favoriteBtn">
  46.             <form action="{{ url('product_list_delete_favorite', {id:Product.id}) }}{% for key, id in app.request.query %}&{{ key }}={{ id }}{% endfor %}" method="post">
  47.                 <div class="ec-productRole__btn">
  48.                     <button type="submit" id="favorite" class="ec-blockBtn--cancel ec-blockBtn--favorite">
  49.                          <img src="{{ asset('assets/img/Icon-heart-remove.svg') }}" alt="お気に入りから削除">
  50.                     </button>
  51.                 </div>
  52.             </form>
  53.             </div>
  54.         {% endif %}
  55.     {% endif %}
  56. {% else %}
  57.     {#<div>#}
  58.     {#    正しい場所にタグを配置してください。#}
  59.     {#    <b>{<b>{ include('Block/product_list_favorite_block.twig') }</b>}</b>#}
  60.     {#</div>#}
  61. {% endif %}