<script>
$(function () {
$('#RelatedProduct-product_area').appendTo($('.ec-layoutRole__main, .ec-layoutRole__mainWithColumn, .ec-layoutRole__mainBetweenColumn'));
});
</script>
<div id="RelatedProduct-product_area" class="ec-shelfRole">
<div class="detailSubTitle">
<h2>その他おすすめ商品</h2>
</div>
<ul class="ec-shelfGrid">
{% for RelatedProduct in Product.RelatedProducts %}
{% set ChildProduct = RelatedProduct.ChildProduct %}
{% if ChildProduct.Status.id == constant("Eccube\\Entity\\Master\\ProductStatus::DISPLAY_SHOW") %}
<li class="ec-shelfGrid__item">
<a href="{{ url('product_detail', {id : ChildProduct.id}) }}">
<div class="ec-shelfGrid__item-wrap">
<div class="ec-shelfGrid__item-imageWrap">
<p class="ec-shelfGrid__item-image">
<img src="{{ asset(RelatedProduct.ChildProduct.main_list_image|no_image_product, 'save_image') }}">
{# タグの表示 #}
{% if ChildProduct.Tags|length > 0 %}
<ul class="ec-shelfGrid__item-tags">
{% for Tag in ChildProduct.Tags %}
<li class="ec-shelfGrid__item-tag tag_{{ Tag.id }}"></li>
{% endfor %}
</ul>
{% endif %}
</p>
</div>
<div class="ec-shelfGrid__item-textWrap">
<p class="ec-shelfGrid__item-title">{{ RelatedProduct.ChildProduct.name }}</p>
{# 一覧説明文(description_list)を表示 #}
{% if ChildProduct.description_list %}
<div class="ec-shelfGrid__item-description">
<p lang="en">{{ ChildProduct.description_list|raw|nl2br }}</p>
</div>
{% endif %}
<p class="ec-shelfGrid__item-price">
{% if RelatedProduct.ChildProduct.hasProductClass %}
{% if RelatedProduct.ChildProduct.getPrice02Min == RelatedProduct.ChildProduct.getPrice02Max %}
{{ RelatedProduct.ChildProduct.getPrice02IncTaxMin|number_format }}円(税込)
{% else %}
{{ RelatedProduct.ChildProduct.getPrice02IncTaxMin|number_format }} ~ {{ RelatedProduct.ChildProduct.getPrice02IncTaxMax|number_format }}円(税込)
{% endif %}
{% else %}
{{ RelatedProduct.ChildProduct.getPrice02IncTaxMin|number_format }}円(税込)
{% endif %}
</p>
{# カートボタンとお気に入りボタンを追加 #}
<div class="ec-shelfGrid__item-buttons">
{% if ChildProduct.stock_find %}
{% if ChildProduct.hasProductClass %}
{# 規格あり商品は詳細ページへのリンク #}
<a href="{{ url('product_detail', {id: ChildProduct.id}) }}" class="ec-inlineBtn--action">
{{ '商品を見る'|trans }}
</a>
{% else %}
{# 規格なし商品はカートに直接追加可能 #}
<form action="{{ url('product_add_cart', {id: ChildProduct.id}) }}" method="post" class="related-product-form">
<input type="hidden" name="product_id" value="{{ ChildProduct.id }}">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="_token" value="{{ csrf_token('_token') }}">
<button type="submit" class="ec-blockBtn--action add-cart">
{{ 'カートに入れる'|trans }}
</button>
</form>
{% endif %}
{% else %}
<button type="button" class="ec-inlineBtn" disabled="disabled">
{{ 'ただいま品切れ中です'|trans }}
</button>
{% endif %}
{% if BaseInfo.option_favorite_product is defined and BaseInfo.option_favorite_product %}
{# お気に入り登録状態を確認 #}
{% set is_favorite = false %}
{% if is_granted('ROLE_USER') %}
{% set Customer = app.user %}
{% for CustomerFavoriteProduct in Customer.CustomerFavoriteProducts %}
{% if CustomerFavoriteProduct.Product.id == ChildProduct.id %}
{% set is_favorite = true %}
{% endif %}
{% endfor %}
{% endif %}
<form action="{{ url('product_add_favorite', {id: ChildProduct.id}) }}" method="post" class="related-product-favorite">
<input type="hidden" name="_token" value="{{ csrf_token('_token') }}">
{% if is_favorite %}
<button type="button" class="favoriteBtn--done" disabled="disabled">
{{ 'お気に入り登録済'|trans }}
</button>
{% else %}
<button type="submit" class="favoriteBtn--add">
{{ 'お気に入り'|trans }}
</button>
{% endif %}
</form>
{% endif %}
</div>
</div>
</div>
</a>
{#<span>{{ RelatedProduct.content|raw|purify }}</span>#}
{# カートボタンとお気に入りボタンを追加 #}
<div class="ec-shelfGrid__item-buttons sp_none">
{% if ChildProduct.stock_find %}
{% if ChildProduct.hasProductClass %}
{# 規格あり商品は詳細ページへのリンク #}
<a href="{{ url('product_detail', {id: ChildProduct.id}) }}" class="ec-inlineBtn--action">
{{ '商品を見る'|trans }}
</a>
{% else %}
{# 規格なし商品はカートに直接追加可能 #}
<form action="{{ url('product_add_cart', {id: ChildProduct.id}) }}" method="post" class="related-product-form">
<input type="hidden" name="product_id" value="{{ ChildProduct.id }}">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="_token" value="{{ csrf_token('_token') }}">
<button type="submit" class="ec-blockBtn--action add-cart">
{{ 'カートに入れる'|trans }}
</button>
</form>
{% endif %}
{% else %}
<button type="button" class="ec-inlineBtn" disabled="disabled">
{{ 'ただいま品切れ中です'|trans }}
</button>
{% endif %}
{% if BaseInfo.option_favorite_product is defined and BaseInfo.option_favorite_product %}
{# お気に入り登録状態を確認 #}
{% set is_favorite = false %}
{% if is_granted('ROLE_USER') %}
{% set Customer = app.user %}
{% for CustomerFavoriteProduct in Customer.CustomerFavoriteProducts %}
{% if CustomerFavoriteProduct.Product.id == ChildProduct.id %}
{% set is_favorite = true %}
{% endif %}
{% endfor %}
{% endif %}
<form action="{{ url('product_add_favorite', {id: ChildProduct.id}) }}" method="post" class="related-product-favorite">
<input type="hidden" name="_token" value="{{ csrf_token('_token') }}">
{% if is_favorite %}
<button type="button" class="favoriteBtn--done" disabled="disabled">
{{ 'お気に入り登録済'|trans }}
</button>
{% else %}
<button type="submit" class="favoriteBtn--add">
{{ 'お気に入り'|trans }}
</button>
{% endif %}
</form>
{% endif %}
</div>
</li>
{% endif %}
{% endfor %}
</ul>
</div>