{#
This file is part of Refine
Copyright(c) 2024 Refine Co.,Ltd. All Rights Reserved.
https://www.re-fine.jp/
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if Page.url == 'product_list' and Product is defined %}
{% if BaseInfo.option_favorite_product %}
{% set is_favorite = false %}
{% if is_granted('ROLE_USER') %}
{% set CustomerFavoriteProducts = repository('Eccube\\Entity\\CustomerFavoriteProduct').findBy({ Customer: app.user.id }) %}
{% for CustomerFavoriteProduct in CustomerFavoriteProducts if CustomerFavoriteProduct.Product.id == Product.id %}
{% set is_favorite = true %}
{% endfor %}
{% endif %}
{# {% if is_favorite == false %}
<form action="{{ url('product_list_add_favorite', {id:Product.id}) }}{% for key, id in app.request.query %}&{{ key }}={{ id }}{% endfor %}" method="post">
<div class="ec-productRole__btn">
<button type="submit" id="favorite" class="ec-blockBtn--cancel">
{{ 'お気に入りに追加'|trans }}
</button>
</div>
</form>
{% else %}
<form action="{{ url('product_list_delete_favorite', {id:Product.id}) }}{% for key, id in app.request.query %}&{{ key }}={{ id }}{% endfor %}" method="post">
<div class="ec-productRole__btn">
<button type="submit" id="favorite" class="ec-blockBtn--cancel">
{{ 'お気に入りから削除'|trans }}
</button>
</div>
</form>
{% endif %} #}
{% if is_favorite == false %}
<div class="product_list-favoriteBtn">
<form action="{{ url('product_list_add_favorite', {id:Product.id}) }}{% for key, id in app.request.query %}&{{ key }}={{ id }}{% endfor %}" method="post">
<div class="ec-productRole__btn">
<button type="submit" id="favorite" class="ec-blockBtn--cancel ec-blockBtn--favorite">
<img src="{{ asset('assets/img/Icon-heart.svg') }}" alt="お気に入りに追加">
</button>
</div>
</form>
</div
{% else %}
<div class="product_list-favoriteBtn">
<form action="{{ url('product_list_delete_favorite', {id:Product.id}) }}{% for key, id in app.request.query %}&{{ key }}={{ id }}{% endfor %}" method="post">
<div class="ec-productRole__btn">
<button type="submit" id="favorite" class="ec-blockBtn--cancel ec-blockBtn--favorite">
<img src="{{ asset('assets/img/Icon-heart-remove.svg') }}" alt="お気に入りから削除">
</button>
</div>
</form>
</div>
{% endif %}
{% endif %}
{% else %}
{#<div>#}
{# 正しい場所にタグを配置してください。#}
{# <b>{<b>{ include('Block/product_list_favorite_block.twig') }</b>}</b>#}
{#</div>#}
{% endif %}