{#
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 %}
<link rel="stylesheet" type="text/css" href="/html/user_data/assets/css/calendar.css">
{% 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: true,
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>
<script>
const rental_setting = '{{ rental_setting }}';
</script>
<script src="/html/user_data/assets/js/calendar.js"></script>
<script>
$(function() {
let name = $('#product_id').text();
if (name.length == 1) {
name = '0000' + name;
}
else if (name.length == 2) {
name = '000' + name;
}
else if (name.length == 3) {
name = '00' + name;
}
else if (name.length == 4) {
name = '0' + name;
}
$('#product_id').text(name);
if ($('#classcategory_id1').length == 0) {
{# レンタル商品でない場合はカレンダー非表示 #}
$('.ec-periodInput').hide();
}
else {
$('.ec-numberInput').hide();
let class_id = one_class_id;
{% if is_admin == 0 %}
{# 管理者でなければ商品規格から当日を除外 #}
let del = 0;
$('#classcategory_id1 option').each(function(index) {
if ($(this).text().indexOf('当日') > -1) {
del = index;
}
});
$('#classcategory_id1 option').eq(del).remove();
{% else %}
{# 管理者 #}
class_id = admin_class_id;
{% endif %}
$('#classcategory_id1 option').eq(0).remove();
let realsettings = [];
$('#classcategory_id1 option').each(function () {
const id = $(this).val();
for (i = 0; i < settings.length; i++) {
const setting = settings[i];
if (id == setting['id']) {
realsettings.push(setting);
}
}
});
settings = realsettings;
let period = '{{ period }}';
$('.ec-periodInput input').val(period);
if (period) {
if (period.indexOf('~') > -1) {
period = period.split('|')[0];
period = period.split('~');
let start = period[0].split('/');
let end = period[1].split('/');
start = new Date(start[0], start[1], start[2]);
end = new Date(end[0], end[1], end[2]);
let termDay = (end - start) / 86400000;
for (i = 0; i < settings.length; i++) {
const setting = settings[i];
if (termDay == setting['period'] - 1) {
class_id = setting['id'];
}
}
}
}
else {
class_id = settings[0]['id'];
}
$('#classcategory_id1').val(class_id).change();
let label = $('#classcategory_id1').prev();
let number = $('.ec-periodInput .number');
let cart_btn = $('.add-cart');
let period_input = $('#period');
number.hide();
setInterval(function() {
if ($('#classcategory_id1').val() == '__unselected') {
label.text('未選択');
number.text(0);
}
else {
let price = $('.price02-default').text();
if (label.text() != price) {
label.text(price);
}
number.text($('#classcategory_id1').val());
}
if (period_input.val()) {
cart_btn.show();
}
else {
cart_btn.hide();
}
}, 100);
}
$('body').addClass('script_loaded');
});
</script>
{% endblock %}
{% block main %}
<div class="c_inner">
<div class="item_detail">
{% set is_gold = false %}
{% if Product.ProductCategories is not empty %}
<div class="head">
{% for ProductCategory in Product.ProductCategories %}
{% set flag = false %}
{% for Category in ProductCategory.Category.path %}
{% if loop.first == true and Category.id == 131 %} {% set flag = true %} {% endif %}
{% if loop.first == true and Category.id == 193 %} {% set is_gold = true %} {% endif %}
{% endfor %}
{% if flag == true %}{# 表示するカテゴリ指定の場合の分岐処理 #}
<p>HOME >
{% for Category in ProductCategory.Category.path %}
<a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> >
{% endfor %}
{{ Product.name }}
</p>
{% endif %}
{% endfor %}
</div>
{% endif %}
<div class="row2">
<div class="mv">
<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>
<ul class="item_nav">
{% for ProductImage in Product.ProductImage %}
<li class="slideThumb" data-index="{{ loop.index0 }}"><img src="{{ asset(ProductImage, 'save_image') }}" alt="" width="133" height="133" loading="lazy"></li>
{% endfor %}
</ul>
</div>
<div class="desc">
<!--{% if sale_type == '3' %}
<div id="pick_up_only" style="margin-bottom: 1em"><span>ヤマト便配送不可</span></div>
{% endif %}-->
{% if Product.freearea %}
<div id="pick_up_only" style="margin-bottom: 1em"><span>{{Product.freearea}}</span></div>
{% endif %}
{# 商品名 #}
<div class="ec-productRole__title">
{% if Product.brand %}
<p>{{ Product.brand }}</p>
{% endif %}
<h2 class="ec-headingTitle">{{ Product.name }}</h2>
</div>
{# 商品コード #}
{% if Product.code_min is not empty %}
<div class="ec-productRole__code">
{{ '商品コード'|trans }}: <span class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
</div>
{% endif %}
<p class="data">
<i>品番: {{ Product.number }}</i>
<i>ID: <span id="product_id">{{ Product.id }}</span></i>
</p>
<form 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="ec-productRole__price" style="display: none;">
{% 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-numberInput"><span>{{ '数量'|trans }}</span>
{{ form_widget(form.quantity) }}
{{ form_errors(form.quantity) }}
</div>
</div>
{% if is_gold == false or user_status == 3 -%}
<div class="ec-periodInput">
<div class="cal_root" data-period="{{ reserved }}">
{{ form_widget(form.period) }}
{{ form_errors(form.period) }}
<em>レンタル期間を選択する</em>
<div class="cal_wrap"></div>
<div class="number"></div>
</div>
</div>
<div class="ec-productRole__btn">
<button type="submit" class="ec-blockBtn--action add-cart">
{{ 'RESERVE'|trans }}
</button>
</div>
{% else %}
<div style="display:none">{{ form_widget(form.period) }}{{ form_errors(form.period) }}</div>
{% endif %}
{% else %}
<div style="display:none">{{ form_widget(form.period) }}{{ form_errors(form.period) }}</div>
<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">{{ 'カートに追加しました。'|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 class="contact">
<a href="{{ url('contact') }}?product={{ Product.id }}">この商品についてお問い合わせ</a>
</div>
{% if BaseInfo.option_favorite_product %}
<form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
<div class="ec-productRole__btn">
{% if is_favorite == false %}
<button type="submit" id="favorite" class="favorite" title="{{ 'お気に入りに追加'|trans }}"></button>
{% else %}
<button type="submit" id="favorite" class="favorite done" disabled="disabled" title="{{ 'お気に入りに追加済です。'|trans }}"></button>
{% endif %}
</div>
</form>
{% endif %}
<div class="description">
{# 在庫数 #}
{% if Product.stock_min %}
<p><b>在庫数</b>{{ Product.stock_min }}{% if Product.stock_min != Product.stock_max %} ~ {{ Product.stock_max }}{% endif %}</p>
{% endif %}
{% if Product.size %}
<p><b>SIZE</b>{{ Product.size }}</p>
{% endif %}
{% if Product.material %}
<p><b>MATERIAL</b>{{ Product.material }}</p>
{% endif %}
<p><b>DETAILS</b>
{{ Product.description_detail|raw|nl2br }}</p>
</div>
{# タグ #}
<dl class="tag">
<dt class="ft_e">TAG</dt>
<dd>
{% for Tag in Product.Tags %}
<i class="tag_{{ Tag.id }}"><a href="/products/list?category_id=&name=&tag1={{ Tag.id }}">{{ Tag }}</a></i>
{% endfor %}
</dd>
</dl>
</div>
</div>
<!--{% if Product.freearea %}
<div class="ec-productRole__description">
{{ include(template_from_string(Product.freearea)) }}
</div>
{% endif %}-->
</div>
</div>
{% endblock %}