{#
This file is part of EC-CUBE
Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
http://www.lockon.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 %}
{% endblock %}
{% block javascript %}
<script src="{{ asset('assets/js/eccube.js') }}"></script>
<script src="https://cdn.jsdelivr.net/npm/swiper@5.3.6/js/swiper.min.js" integrity="sha256-dwAIpWA5jmq1E3AHBeJDH86emZuOEMKZrZxNr9DJAQs=" crossorigin="anonymous"></script>
<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 bgHeight(elem){
var elemOffsetTop = elem.offset().top,
elemHeight = elem.outerHeight();
$('#js-layout__body-bg').height(elemOffsetTop + elemHeight);
}
$(function() {
// bfcache無効化
$(window).bind('pageshow', function(event) {
if (event.originalEvent.persisted) {
location.reload(true);
}
});
var galleryThumbs = new Swiper('#js-detail-product__gallery-thumbs', {
slidesPerView: 4,
spaceBetween: 16,
freeMode: true,
watchSlidesVisibility: true,
watchSlidesProgress: true
});
var galleryTop = new Swiper('#js-product__detail-gallery-slide', {
slidesPerView: 1,
spaceBetween: 20,
thumbs: {
swiper: galleryThumbs
},
pagination: {
el: '#js-detail-product__gallery-pager-contents',
clickable: true
},
breakpoints: {
479: {
slidesPerView: 1,
spaceBetween: 16
}
}
});
bgHeight($('#js-detail-product__price'));
var resizeTimer = null;
$(window).on('resize', function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
bgHeight($('#js-detail-product__price'));
}, 200);
});
});
</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() {
$('#js-product__modal-message').html(this);
});
$('.js-product__modal-checkbox').prop('checked', true);
// カートブロックを更新する
$.ajax({
url: "{{ url('block_cart') }}",
type: 'GET',
dataType: 'html'
}).done(function(html) {
$('#js-header__utility-cart').html(html);
});
}).fail(function(data) {
alert('{{ 'カートへの追加に失敗しました。'|trans }}');
}).always(function(data) {
// Buttonを有効にする
$('.add-cart').prop('disabled', false);
});
});
});
</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="p-product">
<div class="p-product__contents" id="js-product__contents">
<div class="p-product__detail" id="js-product__detail">
<article class="c-detail-product">
<div class="c-detail-product__gallery">
<div class="c-detail-product__gallery-slide" id="js-product__detail-gallery-slide">
<div class="c-detail-product__gallery-slide-contents swiper-wrapper">
{% for ProductImage in Product.ProductImage %}
<div class="c-detail-product__gallery-slide-item swiper-slide">
<div class="c-detail-product__image">
<img class="c-detail-product__image-pic" src="{{ asset(ProductImage, 'save_image') }}" alt="{{ Product.name }}">
</div>
</div>
{% else %}
<div class="c-detail-product__gallery-slide-item swiper-slide">
<div class="c-detail-product__image">
<img class="c-detail-product__image-pic" src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ Product.name }}">
</div>
</div>
{% endfor %}
</div>
</div>
<div class="c-detail-product__gallery-thumbs" id="js-detail-product__gallery-thumbs">
<div class="c-detail-product__gallery-thumbs-contents swiper-wrapper">
{% for ProductImage in Product.ProductImage %}
<div class="c-detail-product__gallery-thumbs-item swiper-slide">
<div class="c-detail-product__image">
<img class="c-detail-product__image-pic" src="{{ asset(ProductImage, 'save_image') }}" alt="{{ Product.name }}">
</div>
</div>
{% endfor %}
</div>
</div>
<div class="c-detail-product__gallery-pager">
<div class="c-detail-product__gallery-pager-contents" id="js-detail-product__gallery-pager-contents"></div>
</div>
</div>
<div class="c-detail-product__profile">
<div class="c-detail-product__profile-layout">
{# タグ #}
{% if Product.Tags is not empty %}
<div class="c-detail-product__profile-layout-item">
<div class="c-detail-product__tag">
<ul class="c-detail-product__tag-list">
{% for Tag in Product.Tags %}
<li class="c-detail-product__tag-list-item" id="c-detail-product__tag-list-item--{{ Tag.id }}">
<span class="c-detail-product__tag-text">{{ Tag }}</span>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
<div class="c-detail-product__profile-layout-item">
<div class="c-detail-product__favorite">
{# お気に入り #}
{% if BaseInfo.option_favorite_product %}
<form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
{% if is_favorite == false %}
<button class="c-detail-product__favorite-button c-ripple-surface mdc-ripple-surface" type="submit" id="favorite">
<i class="c-detail-product__favorite-button-icon material-icons">favorite_border</i>
</button>
{% else %}
<button class="c-detail-product__favorite-button is-disabled c-ripple-surface mdc-ripple-surface" type="submit" id="favorite" disabled="disabled">
<i class="c-detail-product__favorite-button-icon material-icons">favorite</i>
</button>
{% endif %}
</form>
{% endif %}
</div>
</div>
</div>
{# 商品名 #}
<h1 class="c-detail-product__title">{{ Product.name }}</h1>
{# 商品コード #}
{% if Product.code_min is not empty %}
<div class="c-detail-product__code">
<span class="c-detail-product__code--label">{{ '商品コード'|trans }}</span>
<span class="c-detail-product__code--number product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
</div>
{% endif %}
<div class="c-detail-product__price" id="js-detail-product__price">
{# 通常価格 #}
<div class="c-detail-product__price-normal">
{% if Product.hasProductClass -%}
{% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
<span class="c-detail-product__price-normal--label">{{ '通常価格'|trans }}</span>
<span class="c-detail-product__price-normal--number price01-default">{{ Product.getPrice01IncTaxMin|price }}</span>
<span class="c-detail-product__price-normal--tax">{{ '(税込)'|trans }}</span>
{% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
<span class="c-detail-product__price-normal--label">{{ '通常価格'|trans }}</span>
<span class="c-detail-product__price-normal--number price01-default">{{ Product.getPrice01IncTaxMin|price }} ~ {{ Product.getPrice01IncTaxMax|price }}</span>
<span class="c-detail-product__price-normal--tax">{{ '(税込)'|trans }}</span>
{% endif %}
{% else %}
{% if Product.getPrice01Max is not null %}
<span class="c-detail-product__price-normal--label">{{ '通常価格'|trans }}</span>
<span class="c-detail-product__price-normal--number">{{ Product.getPrice01IncTaxMin|price }}</span>
<span class="c-detail-product__price-normal--tax">{{ '(税込)'|trans }}</span>
{% endif %}
{% endif %}
</div>
{# 販売価格 #}
<div class="c-detail-product__price-selling">
{% if Product.hasProductClass -%}
{% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
<span class="c-detail-product__price-selling--number price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
<span class="c-detail-product__price-selling--tax">{{ '(税込)'|trans }}</span>
{% else %}
<span class="c-detail-product__price-selling--number price02-default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span>
<span class="c-detail-product__price-selling--tax">{{ '(税込)'|trans }}</span>
{% endif %}
{% else %}
<span class="c-detail-product__price-selling--number">{{ Product.getPrice02IncTaxMin|price }}</span>
<span class="c-detail-product__price-selling--tax">{{ '(税込)'|trans }}</span>
{% endif %}
</div>
</div>
{# 関連カテゴリ #}
{% if Product.ProductCategories is not empty %}
<dl class="c-detail-product__category">
<dt class="c-detail-product__category-label">{{ '関連カテゴリ'|trans }}</dt>
<dd class="c-detail-product__category-detail">
{% for ProductCategory in Product.ProductCategories %}
<ul class="c-detail-product__category-list u-list-sanitize">
{% for Category in ProductCategory.Category.path %}
<li class="c-detail-product__category-list-item">
<a class="c-detail-product__category-link" href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a>
</li>
{% endfor %}
</ul>
{% endfor %}
</dd>
</dl>
{% 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="c-detail-product__form-box">
<div class="c-detail-product__form-box-item">
<div class="c-select mdc-select mdc-select--outlined">
<i class="mdc-select__dropdown-icon"></i>
{{ form_widget(form.classcategory_id1, {'attr': { 'class': 'c-select__native-control mdc-select__native-control' }}) }}
<div class="mdc-notched-outline">
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch"></div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
{{ form_errors(form.classcategory_id1, {'label_attr': {'class': 'mdc-select-helper-text mdc-select-helper-text--validation-msg'}}) }}
</div>
</div>
{% if form.classcategory_id2 is defined %}
<div class="c-detail-product__form-box">
<div class="c-detail-product__form-box-item">
<div class="c-select mdc-select mdc-select--outlined">
<i class="mdc-select__dropdown-icon"></i>
{{ form_widget(form.classcategory_id2, {'attr': { 'class': 'c-select__native-control mdc-select__native-control' }}) }}
<div class="mdc-notched-outline">
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch"></div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
{{ form_errors(form.classcategory_id2, {'label_attr': {'class': 'mdc-select-helper-text mdc-select-helper-text--validation-msg'}}) }}
</div>
</div>
{% endif %}
{% endif %}
<div class="c-detail-product__form-box">
<div class="c-detail-product__form-box-item">
<div class="c-text-field mdc-text-field mdc-text-field--outlined{{ has_errors(form.quantity) ? ' mdc-text-field--invalid' }}">
{{ form_widget(form.quantity, {'attr': { 'class': 'c-text-field__input mdc-text-field__input' }}) }}
<div class="mdc-notched-outline">
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label class="c-floating-label mdc-floating-label" for="quantity">{{ '数量'|trans }}</label>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
{{ form_errors(form.quantity, {'label_attr': {'class': 'mdc-text-field-helper-text mdc-text-field-helper-text--validation-msg'}}) }}
</div>
</div>
<div class="c-detail-product__actions">
<div class="c-detail-product__actions-item">
<button class="c-button is-secondary c-button--unelevated mdc-button mdc-button--unelevated add-cart" type="submit">
<span class="c-detail-product__button-label">{{ 'カートに入れる'|trans }}</span>
</button>
</div>
</div>
{% else %}
<div class="c-detail-product__actions">
<div class="c-detail-product__actions-item">
<button class="c-button c-button--unelevated mdc-button mdc-button--unelevated" type="button" disabled="disabled">
<span class="c-detail-product__button-label">{{ 'SOLD OUT'|trans }}</span>
</button>
</div>
</div>
{% endif %}
{{ form_rest(form) }}
</form>
<div class="p-product__modal">
<input class="p-product__modal-checkbox js-product__modal-checkbox" id="p-product__modal-checkbox" type="checkbox">
<div class="p-product__modal-overlay">
<label class="p-product__modal-overlay-close" for="p-product__modal-checkbox"></label>
<div class="p-product__modal-contents">
<label class="p-product__modal-close" for="p-product__modal-checkbox">
<i class="p-product__modal-close-icon material-icons">close</i>
</label>
<div class="p-product__modal-header">
<p class="p-product__modal-message" id="js-product__modal-message">{{ 'カートに追加しました。'|trans }}</p>
</div>
<div class="p-product__modal-actions">
<div class="p-product__modal-actions-item">
<a class="p-product__modal-button c-button c-button--unelevated is-secondary mdc-button mdc-button--unelevated" href="{{ url('cart') }}">
<span class="c-button__label mdc-button__label">{{ 'カートへ進む'|trans }}</span>
</a>
</div>
<div class="p-product__modal-actions-item">
<label class="p-product__modal-button c-button c-button--unelevated is-primary mdc-button mdc-button--unelevated" for="p-product__modal-checkbox">
<span class="c-button__label mdc-button__label">{{ 'お買い物を続ける'|trans }}</span>
</label>
</div>
</div>
</div>
</div>
</div>
{% if Product.description_detail %}
<div class="c-detail-product__comment">{{ Product.description_detail|raw|nl2br }}</div>
{% endif %}
{% if Product.freearea %}
{{ include(template_from_string(Product.freearea)) }}
{% endif %}
</div>
</article>
{# プラグイン要素(ProductReview4/RelatedProduct4)追加箇所 #}
<div class="ec-layoutRole__main">
</div>
</div>
</div>
</div>
{% endblock %}