{#
This file is part of EC-CUBE
Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
http://www.ec-cube.co.jp/
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'default_frame.twig' %}
{% set recommend_products = repository('Plugin\\Recommend42\\Entity\\RecommendProduct').getRecommendProduct %}
{% set body_class = 'product_page' %}
{% 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 () {
$('.product-detail__slide-item').height('');
$('.product-detail__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;
$('.product-detail__slide-item').height(baseHeight * rate); // 余白を削除する
// transform を使用することでCLSの影響を受けないようにする
$('.product-detail__slide-item img')
.css(
{
'transform-origin': 'top left',
'transform': 'scaleY(' + rate + ')',
'transition': 'transform .1s'
}
);
// 正しいサイズに近くなったら属性を解除する
setTimeout(removeSize, 500);
};
});
</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);
});
});
$('.line').each(function () {
const rating = parseInt($(this).data('rating'), 10);
if (rating >= 1 && rating <= 7) {
$(this).find('span').removeClass('select'); // 念のため初期化
$(this).find('span').eq(rating - 1).addClass('select');
}
});
});
$('.ec-modal-wrap').on('click', function(e) {
// モーダル内の処理は外側にバブリングさせない
e.stopPropagation();
});
$('.ec-modal-overlay, .ec-modal, .ec-modal-close, .product-detail__button--return').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 %}
<section class="product-detail">
<div class="inner product-detail__inner">
<div class="l-breadcrumb">
<ul itemscope itemtype="https://schema.org/BreadcrumbList" class="l-breadcrumb__list">
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="l-breadcrumb__item">
<a itemprop="item" href="{{ url('homepage') }}" class="l-breadcrumb__link">
<span class="freight-neo-pro" itemprop="name">TOP</span>
</a>
<meta itemprop="position" content="1" />
</li>
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="l-breadcrumb__item">
<a itemprop="item" href="{{ url('product_list') }}" class="l-breadcrumb__link">
<span class="freight-neo-pro" itemprop="name">商品一覧</span>
</a>
<meta itemprop="position" content="2" />
</li>
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="l-breadcrumb__item">
<a itemprop="item" class="l-breadcrumb__link">
<span class="freight-neo-pro" itemprop="name">{{ Product.name }}</span>
</a>
<meta itemprop="position" content="3" />
</li>
</ul>
</div>
<div class="product-detail__container">
<div class="product-detail__slider">
<div class="product-detail__splide splide" role="group" aria-label="商品詳細のサムネイルスライド">
<div class="splide__track">
<ul class="product-detail__slide-list splide__list">
{% for ProductImage in Product.ProductImage %}
<li class="product-detail__slide-item splide__slide">
<img src="{{ asset(ProductImage, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}"
width="550" height="550" {% if loop.index> 1 %} loading="lazy"{% endif %}>
</li>
{% else %}
<li class="product-detail__slide-item splide__slide"><img
src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}"
width="550" height="550"></li>
{% endfor %}
</ul>
</div>
</div>
<div class="product-detail__thumb">
<ul class="product-detail__thumb-list">
{% for ProductImage in Product.ProductImage %}
<li class="product-detail__thumb-item" data-index="{{ loop.index0 }}"><img
src="{{ asset(ProductImage, 'save_image') }}" alt="" width="133" height="133" loading="lazy"></li>
{% endfor %}
</ul>
</div>
</div>
<div class="product-detail__profile">
{# 商品名 #}
<h2 class="product-detail__title">{{ Product.name }}</h2>
{# タグ #}
<ul class="p-tags product__tags">
{% for Tag in Product.Tags %}
<li class="p-tag">{{Tag.name}}</li>
{% endfor %}
</ul>
{# キャッチコピー(見出し) #}
<p class="product-detail__text--free">{{ Product.sub_heading|raw|nl2br }}</p>
{# 商品説明 #}
<p class="product-detail__text">{{ Product.description_detail|raw|nl2br }}</p>
{# レート #}
<div class="product-detail__rating">
<ul class="product-detail__rating-list">
<li class="product-detail__rating-item">
<div class="kinds">香り</div>
<div class="line" data-rating="{{ aroma }}"><span></span><span></span><span></span><span></span><span></span><span></span><span></span>
</div>
</li>
<li class="product-detail__rating-item">
<div class="kinds">甘み</div>
<div class="line" data-rating="{{ bitter }}"><span></span><span></span><span></span><span></span><span></span><span></span><span></span>
</div>
</li>
<li class="product-detail__rating-item">
<div class="kinds">香ばしさ</div>
<div class="line" data-rating="{{ roasting }}"><span></span><span></span><span></span><span></span><span></span><span></span><span></span>
</div>
</li>
<li class="product-detail__rating-item">
<div class="kinds">コク</div>
<div class="line" data-rating="{{ rich }}"><span></span><span></span><span></span><span></span><span></span><span></span><span></span>
</div>
</li>
<li class="product-detail__rating-item">
<div class="kinds">旨み</div>
<div class="line" data-rating="{{ deliciousness }}"><span></span><span></span><span></span><span></span><span></span><span></span><span></span>
</div>
</li>
<li class="product-detail__rating-item">
<div class="kinds">余韻</div>
<div class="line" data-rating="{{ aftertaste }}"><span></span><span></span><span></span><span></span><span></span><span></span><span></span>
</div>
</li>
</ul>
</div>
{# 通常価格 #}
{% if Product.hasProductClass -%}
<div class="product-detail__price">
{% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
<span class="product-detail__price-text">{{ '通常価格'|trans }}:<span class="product-detail__price-num">{{
Product.getPrice01IncTaxMin|price }}</span></span>{{ '(税込)'|trans }}
{% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
<span class="product-detail__price-text">{{ '通常価格'|trans }}:<span class="product-detail__price-num">{{
Product.getPrice01IncTaxMin|price }}~ {{ Product.getPrice01IncTaxMax|price }}</span></span>{{ '(税込)'|trans
}}
{% endif %}
</div>
{% else %}
{% if Product.getPrice01Max is not null %}
<span class="product-detail__price-text">{{ '通常価格'|trans }}:{{ Product.getPrice01IncTaxMin|price }}</span>{{
'(税込)'|trans }}
{% endif %}
{% endif %}
{# 販売価格 #}
<div class="product-detail__price">
{% if Product.hasProductClass -%}
{% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
<span class="product-detail__price-num">{{ Product.getPrice02IncTaxMin|price }}</span>{{ '(税込)'|trans }}
{% else %}
<span class="product-detail__price-num">{{ Product.getPrice02IncTaxMin|price }} ~ {{
Product.getPrice02IncTaxMax|price }}</span>{{ '(税込)'|trans }}
{% endif %}
{% else %}
<span class="product-detail__price-num">{{ Product.getPrice02IncTaxMin|price }}</span>{{ '(税込)'|trans }}
{% endif %}
</div>
<p class="product-detail__navi">※送料別途<a href="{{ url('help_guide')}}">詳しくはこちら</a></p>
<form class="product-detail__action" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
{% if Product.stock_find %}
<div class="ec-productRole__actions">
<!-- {% if form.classcategory_id1 is defined %}
<div class="ec-select">
{{ form_row(form.classcategory_id1) }}
{{ form_errors(form.classcategory_id1) }}
</div>
{% if form.classcategory_id2 is defined %}
<div class="ec-select">
{{ form_row(form.classcategory_id2) }}
{{ form_errors(form.classcategory_id2) }}
</div>
{% endif %}
{% endif %} -->
<div class="product-detail__action-num"><span>{{ '数量'|trans }}</span>
{{ form_widget(form.quantity) }}
{{ form_errors(form.quantity) }}
</div>
</div>
<button type="submit" class="product-detail__button product-detail__button--cart add-cart">
<svg class="product-detail__button--icon">
<use xlink:href="/html/user_data/assets/img/symbol-defs.svg#icon-cart"></use>
</svg>
<span class="product-detail__button-text">{{ 'カートに入れる'|trans }}</span>
</button>
{% else %}
<button type="button" class="product-detail__button product-detail__button--disabled" disabled="disabled">
{{ 'ただいま品切れ中です。'|trans }}
</button>
{% endif %}
{{ form_rest(form) }}
</form>
<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="modal-button-wrap">
<span class="product-detail__button product-detail__button--return">{{ 'お買い物を続ける'|trans }}</span>
<a href="{{ url('cart') }}" class="product-detail__button product-detail__button--cart">{{ 'カートへ進む'|trans }}</a>
</div>
</div>
</div>
</div>
{% if BaseInfo.option_favorite_product %}
<form class="product-detail__favorite" action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
{% if is_favorite == false %}
<button type="submit" id="favorite" class="product-detail__button product-detail__button--favorite">
<span class="product-detail__button-text--favorite">{{ 'お気に入りに追加'|trans }}</span>
</button>
{% else %}
<button type="submit" id="favorite" class="product-detail__button product-detail__button--favorite" disabled="disabled">
<span class="product-detail__button-text--favorite is-disabled">
{{ 'お気に入りに追加済み'|trans }}
</span>
</button>
{% endif %}
</form>
{% endif %}
</div>
</div>
<div class="product-detail__container">
<div class="product-detail__box--video">
<h3 class="product-detail__box-heading product-detail__box-heading--video">お茶の淹れ方</h3>
<div class="product-detail__box-video">
<video src="{{ asset('assets/img/sample.mp4#t=0.001', 'user_data') }}" controls webkit-playsinline playsinline></video>
</div>
</div>
{% if Product.ProductSpecs|length > 0 %}
<div class="product-detail__box--info">
<h3 class="product-detail__box-heading product-detail__box-heading--info">商品情報</h3>
<dl class="product-detail__info-list">
{% for spec in Product.ProductSpecs %}
<div class="product-detail__info-item">
<dt class="product-detail__info-title">{{ spec.title|raw|nl2br }}</dt>
<dt class="product-detail__info-desc">{{ spec.content|raw|nl2br }}</dt>
</div>
{% endfor %}
</dl>
</div>
{% endif %}
</div>
</div>
</section>
{% set features = [
{
'heading': Product.salesHeading01,
'content': Product.salesContent01,
'image': Product.salesImagePath01
},
{
'heading': Product.salesHeading02,
'content': Product.salesContent02,
'image': Product.salesImagePath02
},
{
'heading': Product.salesHeading03,
'content': Product.salesContent03,
'image': Product.salesImagePath03
},
{
'heading': Product.salesHeading04,
'content': Product.salesContent04,
'image': Product.salesImagePath04
}
] %}
{# featuresのうち1つでも何か値があるかチェック #}
{% set has_feature = features|filter(f => f.heading or f.content or f.image)|length > 0 %}
{% if has_feature %}
<div class="product-detail-bg">
<div class="product-detail-bg__wrap">
<p class="product-detail-bg__text">Characteristics of Tea Characteristics of Tea</p>
<p class="product-detail-bg__text">Characteristics of Tea Characteristics of Tea</p>
</div>
<div class="product-detail-bg__wrap">
<p class="product-detail-bg__text">Characteristics of Tea Characteristics of Tea</p>
<p class="product-detail-bg__text">Characteristics of Tea Characteristics of Tea</p>
</div>
</div>
<section class="product-detail-feature">
{% for feature in features if feature.heading or feature.content or feature.image %}
<div class="product-detail-feature__wrapper {% if loop.index is even %} --even{% endif %}">
<div class="product-detail-feature__info">
<h2 class="product-detail-feature__heading"><span class="sub">Feature{{ '%02d'|format(loop.index) }}</span>{{ feature.heading|raw|nl2br }}</h2>
<p class="product-detail-feature__text">{{ feature.content|raw|nl2br }}</p>
</div>
<div class="product-detail-feature__image">
<img src="{{ asset('/html/upload/save_image/' ~ feature.image) }}" alt="">
</div>
</div>
{% endfor %}
</section>
{% endif %}
{% if howto_glass|length or howto_pot|length %}
<section class="product-detail-howto">
<div class="inner product-detail-howto__inner">
<h2 class="product-detail-howto__heading">おいしい召し上がり方</h2>
{% if (howto_glass|length > 0) %}
<div class="product-detail-howto__container">
<h3 class="product-detail-howto__subheading --glass">グラスで召しあがる</h3>
<ol class="product-detail-howto__list">
{% for item in howto_glass %}
<li class="product-detail-howto__item"><span class="number">{{ loop.index }}</span>{{ item.howto_glass_item }}</li>
{% endfor %}
</ol>
</div>
{% endif %}
{% if (howto_pot|length > 0) %}
<div class="product-detail-howto__container">
<h3 class="product-detail-howto__subheading --pot">蓋碗や急須を用いて召しあがる</h3>
<ol class="product-detail-howto__list">
{% for item in howto_pot %}
<li class="product-detail-howto__item"><span class="number">{{ loop.index }}</span>{{ item.howto_pot_item }}</li>
{% endfor %}
</ol>
</div>
{% endif %}
</div>
</section>
{% endif %}
<section class="recommend">
<div class="inner recommend__inner">
<h2 class="recommend__heading">Recommend<span class="recommend__subheading">おすすめ商品</span></h2>
<ul class="recommend__list">
{% for RecommendProduct in recommend_products %}
<li class="recommend__item">
<a href="{{ url('product_detail', {'id': RecommendProduct.Product.id}) }}">
<div class="recommend__thumb">
<img src="{{ asset(RecommendProduct.Product.mainFileName|no_image_product, "save_image") }}">
</div>
<div class="recommend__body">
<p class="recommend__name">{{ RecommendProduct.Product.name }}</p>
<p class="recommend__price">{{ RecommendProduct.Product.getPrice02IncTaxMax|price }}<span>(税込)</span></p>
<ul class="p-tags pickup__tags">
{% for Tag in RecommendProduct.Product.Tags %}
<li class="p-tag">{{Tag.name}}</li>
{% endfor %}
</ul>
</div>
</a>
</li>
{% endfor %}
</ul>
<div class="p-button recommend__button">
<a href="{{ url('product_list' )}}" class="p-button__link">
<span class="p-button__arrow">
<svg class="p-button__icon --before">
<use xlink:href="/html/user_data/assets/img/symbol-defs.svg#icon-arrow_link"></use>
</svg>
<svg class="p-button__icon --after">
<use xlink:href="/html/user_data/assets/img/symbol-defs.svg#icon-arrow_link"></use>
</svg>
</span>
<span class="p-button__text">商品一覧</span>
</a>
</div>
</div>
</section>
<!-- /.recommend -->
<section class="checked">
<div class="inner checked__inner">
<h2 class="checked__heading">Checked items<span class="checked__subheading">最近チェックした商品</span></h2>
<ul class="checked__list">
{% for Product in app.session.get('product_history') %}
<li class="checked__item">
<a href="{{ url('product_detail', {id:Product.id}) }}" class="checked__link">
<picture class="checked__image"><img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt=""></picture>
<h3 class="checked__title">{{ Product.name }}</h3>
<p class="checked__price">
{% if Product.hasProductClass %}
{% if Product.getPrice02Min == Product.getPrice02Max %}
{{ Product.getPrice02IncTaxMin|price }}<span>(税込)</span>
{% else %}
{{ Product.getPrice02IncTaxMin|price }}
~
{{ Product.getPrice02IncTaxMax|price }}<span>(税込)</span>
{% endif %}
{% else %}
{{ Product.getPrice02IncTaxMin|price }}<span>(税込)</span>
{% endif %}
</p>
<ul class="p-tags pickup__tags">
{% for Tag in Product.Tags %}
<li class="p-tag">{{ Tag.name }}</li>
{% endfor %}
</ul>
</a>
</li>
{% endfor %}
</ul>
</div>
</section>
<!-- /.checked -->
{% endblock %}