{% extends 'default_frame.twig' %}
{% set body_class = 'product_page' %}
{% import _self as stars %}
{# 星テキスト生成用マクロ #}
{% macro stars(positive, negative) %}
{% set positive_stars = ["", "★", "★★", "★★★", "★★★★", "★★★★★"] %}
{% set negative_stars = ["", "☆", "☆☆", "☆☆☆", "☆☆☆☆", "☆☆☆☆☆"] %}
{{ positive_stars[positive] }}{{ negative_stars[negative] }}
{% endmacro %}
{% block stylesheet %}
<link rel="stylesheet" href="{{ asset('assets/css/product-details.css', 'user_data') }}" />
<style>
.slick-slider {
margin-bottom: 30px;
}
.slick-dots {
position: absolute;
bottom: -45px;
display: block;
width: 100%;
padding: 0;
list-style: none;
text-align: center;
}
.slick-dots li {
position: relative;
display: inline-block;
width: 20px;
height: 20px;
margin: 0 5px;
padding: 0;
cursor: pointer;
}
.slick-dots li button {
font-size: 0;
line-height: 0;
display: block;
width: 20px;
height: 20px;
padding: 5px;
cursor: pointer;
color: transparent;
border: 0;
outline: none;
background: transparent;
}
.slick-dots li button:hover,
.slick-dots li button:focus {
outline: none;
}
.slick-dots li button:hover:before,
.slick-dots li button:focus:before {
opacity: 1;
}
.slick-dots li button:before {
content: " ";
line-height: 20px;
position: absolute;
top: 0;
left: 0;
width: 12px;
height: 12px;
text-align: center;
opacity: .25;
background-color: black;
border-radius: 50%;
}
.slick-dots li.slick-active button:before {
opacity: .75;
background-color: black;
}
.slick-dots li button.thumbnail img {
width: 0;
height: 0;
}
</style>
{% endblock %}
{% block javascript %}
<script>
eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
// 規格2に選択肢を割り当てる。
function fnSetClassCategories(form, classcat_id2_selected) {
var $form = $(form);
var product_id = $form.find('input[name=product_id]').val();
var $sele1 = $form.find('select[name=classcategory_id1]');
var $sele2 = $form.find('select[name=classcategory_id2]');
eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
}
{% if form.classcategory_id2 is defined %}
fnSetClassCategories(
$('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
);
{% elseif form.classcategory_id1 is defined %}
eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
{% endif %}
</script>
<script>
$(function() {
// bfcache無効化
$(window).bind('pageshow', function(event) {
if (event.originalEvent.persisted) {
location.reload(true);
}
});
// Core Web Vital の Cumulative Layout Shift(CLS)対策のため
// img タグに width, height が付与されている.
// 630px 未満の画面サイズでは縦横比が壊れるための対策
// see https://github.com/EC-CUBE/ec-cube/pull/5023
$('.ec-grid2__cell').hide();
var removeSize = function () {
$('.slide-item').height('');
$('.slide-item img')
.removeAttr('width')
.removeAttr('height')
.removeAttr('style');
};
var slickInitial = function(slick) {
$('.ec-grid2__cell').fadeIn(1500);
var baseHeight = $(slick.target).height();
var baseWidth = $(slick.target).width();
var rate = baseWidth / baseHeight;
$('.slide-item').height(baseHeight * rate); // 余白を削除する
// transform を使用することでCLSの影響を受けないようにする
$('.slide-item img')
.css(
{
'transform-origin': 'top left',
'transform': 'scaleY(' + rate + ')',
'transition': 'transform .1s'
}
);
// 正しいサイズに近くなったら属性を解除する
setTimeout(removeSize, 500);
};
$('.item_visual').on('init', slickInitial);
// リサイズ時は CLS の影響を受けないため属性を解除する
$(window).resize(removeSize);
$('.item_visual').slick({
dots: false,
arrows: false,
responsive: [{
breakpoint: 768,
settings: {
dots: true
}
}]
});
$('.slideThumb').on('click', function() {
var index = $(this).attr('data-index');
$('.item_visual').slick('slickGoTo', index, false);
})
});
</script>
<script>
$(function() {
$('.add-cart').on('click', function(event) {
{% if form.classcategory_id1 is defined %}
// 規格1フォームの必須チェック
if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
$('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
return true;
} else {
$('#classcategory_id1')[0].setCustomValidity('');
}
{% endif %}
{% if form.classcategory_id2 is defined %}
// 規格2フォームの必須チェック
if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
$('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
return true;
} else {
$('#classcategory_id2')[0].setCustomValidity('');
}
{% endif %}
// 個数フォームのチェック
if ($('#quantity').val() < 1) {
$('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
return true;
} else {
$('#quantity')[0].setCustomValidity('');
}
event.preventDefault();
$form = $('#form1');
$.ajax({
url: $form.attr('action'),
type: $form.attr('method'),
data: $form.serialize(),
dataType: 'json',
beforeSend: function(xhr, settings) {
// Buttonを無効にする
$('.add-cart').prop('disabled', true);
}
}).done(function(data) {
// レスポンス内のメッセージをalertで表示
$.each(data.messages, function() {
$('#ec-modal-header').text(this);
});
$('.ec-modal').show()
// カートブロックを更新する
$.ajax({
url: "{{ url('block_cart') }}",
type: 'GET',
dataType: 'html'
}).done(function(html) {
$('.ec-headerRole__cart').html(html);
});
}).fail(function(data) {
alert('{{ 'カートへの追加に失敗しました。'|trans }}');
}).always(function(data) {
// Buttonを有効にする
$('.add-cart').prop('disabled', false);
});
});
});
$('.ec-modal-wrap').on('click', function(e) {
// モーダル内の処理は外側にバブリングさせない
e.stopPropagation();
});
$('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
$('.ec-modal').hide()
});
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "{{ Product.name }}",
"image": [
{% for img in Product.ProductImage %}
"{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
{% else %}
"{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
{% endfor %}
],
"description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
{% if Product.code_min %}
"sku": "{{ Product.code_min }}",
{% endif %}
"offers": {
"@type": "Offer",
"url": "{{ url('product_detail', {'id': Product.id}) }}",
"priceCurrency": "{{ eccube_config.currency }}",
"price": {{ Product.getPrice02IncTaxMin ? Product.getPrice02IncTaxMin : 0}},
"availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
}
}
</script>
{% endblock %}
{% block main %}
<div class="common-bg">
{{ include('Block/pankuzu.twig') }}
<div class="content__wrapper">
<section class="product-detail__content">
<div class="slide__change-sp">
<div class="slide__change__img active">
{% for ProductImage in Product.ProductImage %}
<img src="{{ asset(ProductImage, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" {% if loop.index > 1 %} loading="lazy"{% endif %}>
{% else %}
<img src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}">
{% endfor %}
</div>
<div class="slide__change__img__list__wrap slide__change__img__list__wrap-sp">
<ul class="slide__change__img__list" id="slide__change__img__list01">
{% for ProductImage in Product.ProductImage %}
<li class="slide__change__img__list-item">
<img src="{{ asset(ProductImage, 'save_image') }}" alt=""
class="slide__change__img__list-item__img" loading="lazy">
</li>
{% endfor %}
</ul>
</div>
<div class="explanation explanation-pc">
<ul class="explanation__info">
<li>
<span class="explanation__info__txt">
{{ Product.description_detail|raw|nl2br }}
</span>
</li>
</ul>
</div>
</div>
<div class="product-details__info__wrap">
<h1 class="product-details__info__name product-details__line">{{ Product.name }}</h1>
<div class="product-details__info__price product-details__line">
{# 通常価格 #}
<div class="product-details__info__price01">
{{ '通常価格'|trans }}:
{% if Product.hasProductClass -%}
{% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
{{ Product.getPrice01IncTaxMin|price }}
{% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
{{ Product.getPrice01IncTaxMin|price }}~ {{ Product.getPrice01IncTaxMax|price }}
{% endif %}
{% else %}
{% if Product.getPrice01Max is not null %}
{{ Product.getPrice01IncTaxMin|price }}
{% endif %}
{% endif %}
({{ '税込'|trans }})</div>
{# 販売価格 #}
<div class="product-details__info__price02">
{% if Product.hasProductClass -%}
{% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
{{ Product.getPrice02IncTaxMin|price }}
{% else %}
{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
{% endif %}
{% else %}
{{ Product.getPrice02IncTaxMin|price }}
{% endif %}
<span>({{ '税込'|trans }})</span>
</div>
</div>
{% if Product.code_min is not empty %}
<div class="product-details__info__content03 product-details__line">{{ '商品コード'|trans }}:{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</div>
{% endif %}
<div class="product-details__info__content04 product-details__line">
※こちらの価格には消費税が含まれています。<br>※送料は別途発生いたします。詳細はこちら
</div>
{% if Product.ProductCategories is not empty %}
<div class="product-details__info__content05 product-details__line">
{{ '関連カテゴリ'|trans }}<br>
{% for ProductCategory in Product.ProductCategories %}
{% for Category in ProductCategory.Category.path %}
<a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> {%- if loop.last == false %}
<span>></span>{% endif -%}
{% endfor %}
{% endfor %}
</div>
{% endif %}
<form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
{% if Product.stock_find %}
{% if form.classcategory_id1 is defined %}
<div class="product-details__info__color product-details__info__item">
<div class="product-details__info__dt">規格</div>
<div class="form__input quantity">
{{ form_row(form.classcategory_id1) }}
{{ form_errors(form.classcategory_id1) }}
</div>
</div>
{% if form.classcategory_id2 is defined %}
<div class="product-details__info__color product-details__info__item">
<div class="product-details__info__dt">規格</div>
<div class="form__input quantity">
{{ form_row(form.classcategory_id2) }}
{{ form_errors(form.classcategory_id2) }}
</div>
</div>
{% endif %}
{% endif %}
<div class="product-details__info__quantity product-details__info__item">
<div class="product-details__info__dt">{{ '数量'|trans }}</div>
<label class="number-spinner-wrap">
{{ form_widget(form.quantity) }}
{{ form_errors(form.quantity) }}
<div class="spinner__num-wrap">
<span class="spinner spinner-down">-</span>
<span class="spinner spinner-up">+</span>
</div>
</label>
</div>
<div class="product-details__btn__wrap">
<div class="common__btn__wrap">
<div class="common__btn">
<button type="submit" class="add-cart common__btn__inner common__btn__inner__cart">{{ 'カートに入れる'|trans }}</button>
</div>
</div>
</div>
{% else %}
<button type="button" class="ec-blockBtn--action" disabled="disabled">
{{ 'ただいま品切れ中です。'|trans }}
</button>
{% endif %}
{{ form_rest(form) }}
</form>
{% if BaseInfo.option_favorite_product %}
<form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
{% if is_favorite == false %}
<div class="common__btn__wrap">
<div class="common__btn">
<button type="submit" id="favorite" class="common__btn__inner">{{ 'お気に入りに追加'|trans }}</button>
</div>
</div>
{% else %}
<div class="common__btn__wrap">
<div class="common__btn">
<button type="submit" id="favorite" class="common__btn__inner" disabled="disabled">{{ 'お気に入りに追加済です。'|trans }}</button>
</div>
</div>
{% endif %}
</form>
{% endif %}
<div class="ec-modal">
<div class="ec-modal-overlay">
<div class="ec-modal-wrap">
<span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
<div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
<div class="ec-modal-box">
<div class="ec-role">
<span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
<a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<div class="explanation explanation-sp">
<ul class="explanation__info">
<li>
<span class="explanation__info__ttl"></span>
<span class="explanation__info__txt">
{{ Product.description_detail|raw|nl2br }}
</span>
</li>
</ul>
</div>
{% set positive_avg_star = ProductReviewAvg %}
{% set negative_avg_star = 5 - positive_avg_star %}
<div class="review">
<div class="review__mv__wrap">
<div class="review__mv">{{ 'product_review.front.product_detail.title'|trans }}</div>
<div class="review__mv__star__wrap">
<div class="review__mv__star"><span class="star-w">{{ stars.stars(positive_avg_star, negative_avg_star) }}</span>
</div>
<div class="review__mv__star__num">({{ ProductReviewCount }})</div>
</div>
</div>
{% if ProductReviews %}
{% for ProductReview in ProductReviews %}
<div class="review__time__wrap">
<div class="review__time">・{{ ProductReview.create_date|date_day }}</div>
{% if ProductReview.reviewer_url %}
<div class="review__name">
<a href="{{ ProductReview.reviewer_url }}" rel="ugc nofollow"
target="_blank">{{ 'product_review.front.product_detail.name'|trans({ '%name%': ProductReview.reviewer_name }) }}</a>
</div>
{% else %}
<div class="review__name">
{{ 'product_review.front.product_detail.name'|trans({ '%name%': ProductReview.reviewer_name }) }}
</div>
{% endif %}
{% set positive_star = ProductReview.recommend_level %}
{% set negative_star = 5 - positive_star %}
<div class="review__time__star"><span class="star-b">★★★★</span><span class="star-b-n">{{ stars.stars(positive_star, negative_star) }}</span>
</div>
</div>
<div class="review__ttl">{{ ProductReview.title }}</div>
<div class="review__txt">
{{ ProductReview.comment|nl2br }}
</div>
{% endfor %}
{% else %}
<p style="margin-top: 2rem;">{{ 'product_review.front.product_detail.no_review'|trans }}</p>
{% endif %}
</div>
<div class="review__btn" style="margin-bottom: 2rem;"><a href="{{ url('product_review_index', { id: Product.id }) }}">{{ 'product_review.front.product_detail.post_review'|trans }}</a></div>
</div>
</div>
{% endblock %}