{#
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 body_class = 'product_page' %}
{% block stylesheet %}
<style>
.slick-list {
background: #e0e0e0;
}
.slick-track {
display: flex;
align-items: center;
}
.slick-slider {
margin-bottom: 20px;
}
.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 {
transition: all 0.5s cubic-bezier(0.215, 0.61, 0.355, 1) 0s;
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 %}
function fnUpdateQuantity(value=1) {
var quantity = parseInt($('#quantity').val());
quantity += value;
if(quantity < 1) quantity = 1;
$('#quantity').val(quantity);
}
</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);
})
});
function addFavorite(product_id) {
location.href = '//' + window.location.host + '/products/add_favorite/' + product_id;
}
</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) {
// from cart to login
{#window.location.href = '{{ url('mypage_login') }}'#}
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="ec-productRole">
<div class="ec-grid2">
<div class="ec-blockVSpliter"></div>
<div class="ec-grid2__cell bg-custom-left">
<div class="ec-blockVSpliter__left"></div>
<div class="ec-blockVSpliter__right show-resultSP"></div>
<div class="ec-sliderItemRole">
<div class="item_visual">
{% for ProductImage in Product.ProductImage %}
<div class="slide-item"><img src="{{ asset(ProductImage, 'save_image') }}"
alt="{{ loop.first ? Product.name : '' }}" width="550"
height="550"{% if loop.index > 1 %} loading="lazy"{% endif %}>
</div>
{% else %}
<div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}"
alt="{{ loop.first ? Product.name : '' }}" width="550"
height="550"></div>
{% endfor %}
</div>
<div class="item_nav">
{% for ProductImage in Product.ProductImage %}
<div class="slideThumb" data-index="{{ loop.index0 }}"><img
src="{{ asset(ProductImage, 'save_image') }}" alt="" width="133" height="133"
loading="lazy"></div>
{% endfor %}
</div>
</div>
<div class="ec-productRole__description show-resultPC">{{ Product.description_detail|raw|nl2br }}
</div>
</div>
<div class="ec-blockVSpliter"></div>
<div class="ec-grid2__cell bg-custom-right">
<div class="ec-blockVSpliter__right"></div>
<div class="ec-productRole__profile">
{# 関連カテゴリ #}
{% if Product.ProductCategories is not empty %}
<div class="ec-productRole__categoryName">
{% if Product.ProductCategories %}
{% for Category in Product.ProductCategories[0].Category.path %}
{%- if loop.last == true %}
<div>
<a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a>
</div>
{% endif -%}
{% endfor %}
{% endif %}
{% for ProductCategory in Product.ProductCategories %}
<ul style="display: none">
<li>
{% 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 %}
</li>
</ul>
{% endfor %}
</div>
{% endif %}
{# 商品名 #}
<div class="ec-productRole__detailTitle">
<h2 class="ec-headingTitle">{{ Product.name }}</h2>
</div>
<div class="ec-productRole__detailPrice">
{% if Product.hasProductClass -%}
{% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
<div class="ec-price">
<span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
<span class="ec-price__tax">({{ '税込'|trans }})</span>
</div>
{% else %}
<div class="ec-price">
<span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span>
<span class="ec-price__tax">({{ '税込'|trans }})</span>
</div>
{% endif %}
{% else %}
<div class="ec-price">
<span class="ec-price__price">{{ Product.getPrice02IncTaxMin|price }}</span>
<span class="ec-price__tax">({{ '税込'|trans }})</span>
</div>
{% endif %}
</div>
<div class="ec-productDetails">
{% if Product.new_arrival %}
<span class="ec-productDetails__newitembadge">NEW</span>
{% endif %}
</div>
{# タグ #}
<ul class="ec-productRole__tags">
{% for Tag in Product.Tags %}
<li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
{% endfor %}
</ul>
<div class="ec-productRole__detailCode">
{{ '商品コード'|trans }}: <span
class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
</div>
<form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
{% if Product.stock_find %}
<div class="ec-productRole__actions custom-p">
<div class="ec-numberInput">
<label>{{ '数量'|trans }}</label>
<div class="ec-numberInput__inner">
<div class="ec-numberInput__control">
<a class="ec-blockBtn detailProduct_btn"
onclick="fnUpdateQuantity(-1)"><span class="btn-minus"></span></a>
{{ form_widget(form.quantity) }}
<a class="ec-blockBtn detailProduct_btn" onclick="fnUpdateQuantity(1)"><span
class="btn-plus"></span></a>
</div>
{% if BaseInfo.option_favorite_product %}
<div class="ec-buttonRole_event" style="display: flex;">
{% if is_favorite == false %}
<button type="button" id="favorite" onclick="addFavorite(`{{ Product.id }}`)"
class="ec-blockBtn ec-blockBtn__favorite detailProduct_btn">
<img src="{{ asset('assets/icon/heart-dark.svg') }}">
<span>お気に入り</span>
</button>
{% else %}
<button type="button" id="favorite"
class="ec-blockBtn ec-blockBtn__favorite detailProduct_btn"
disabled="disabled">
<img src="{{ asset('assets/icon/heart-active.svg') }}">
<span>お気に入り</span>
</button>
{% endif %}
</div>
{% endif %}
</div>
{{ form_errors(form.quantity) }}
</div>
{% 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>
<div class="ec-productRole__btn custom-p">
<button type="submit"
class="ec-blockBtn--action add-cart ec-productDetails__btncustom text-white">
<img src="/html/template/default/assets/img/top/cart.svg">
{{ 'カートに入れる'|trans }}
</button>
</div>
{% else %}
<div class="ec-productRole__btn">
<button type="button" class="ec-blockBtn--action" disabled="disabled">
{{ 'ただいま品切れ中です。'|trans }}
</button>
</div>
{% 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 ec-font-bold">{{ 'カートに追加しました。'|trans }}</div>
<div class="ec-modal-box">
<div class="ec-role addCartModal">
<button type="button" class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</button>
<a href="{{ url('cart') }}" >
<button type="button" class="ec-inlineBtn--action" >{{ 'カートへ進む'|trans }}</button>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="ec-grid2__cell bg-custom-left show-resultSP">
<div class="ec-productRole__description">{{ Product.description_detail|raw|nl2br }}
</div>
</div>
<div class="ec-blockVSpliter"></div>
</div>
{% if Product.freearea %}
<div class="ec-productRole__description">
{{ include(template_from_string(Product.freearea)) }}
</div>
{% endif %}
</div>
{% endblock %}