{#
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 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 () {
$('.slider-detail').slick({
autoplay: true,
centerMode: false,
dots: false,
arrows: false,
slidesToShow: 1,
});
});
</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').html(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, ._prev').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 }},
"availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
}
}
</script>
{% endblock %}
{% block main %}
{#<div class="container">#}
{# {% if Product.ProductCategories is not empty %}#}
{# <div class="breadcrumb">#}
{# <li>#}
{# <a href="{{ url('homepage') }}">#}
{# ホーム#}
{# </a>#}
{# </li>#}
{# {% for ProductCategory in Product.ProductCategories %}#}
{# <li>#}
{# <a href="{{ url('product_list') }}?category_id={{ ProductCategory.Category.id }}">{{ ProductCategory.Category.name }}</a>#}
{# </li>#}
{# {% endfor %}#}
{# <li>#}
{# <span>#}
{# {{ Product.name }}#}
{# </span>#}
{# </li>#}
{# </div>#}
{# {% endif %}#}
{#</div>#}
<div class="ec-productRole">
{# パンくずリスト(関連カテゴリ) #}
<div class="ec-product__detail">
<div class="ec-product__detail-img">
<div class="ec-sliderItemRole">
<div class="slider-detail">
{% for ProductImage in Product.ProductImage %}
<div class="slide-item"><img src="{{ asset(ProductImage, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}"></div>
{% else %}
<div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" /></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=""></div>
{% endfor %}
</div> #}
</div>
</div>
<div class="product__detail-content">
<div class="ec-productRole__profile">
{# 商品名 #}
<div class="ec-productRole__title">
<h2 class="ec-headingTitle">{{ Product.name }}</h2>
</div>
{# 商品説明 #}
<div class="ec-productRole__description">{{ Product.description_detail|raw|nl2br }}
</div>
<dl class="ec-product__dl">
{% if Product.code_min is not empty %}
<div class="item">
<dt>
商品コード
</dt>
<dd>
{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}
</dd>
</div>
{% endif %}
{% if Product.sub_title1 is not empty %}
<div class="item">
<dt>
{{ Product.sub_title1 }}
</dt>
<dd>
{{ Product.sub_comment1 }}
</dd>
</div>
{% endif %}
{% if Product.sub_title2 is not empty %}
<div class="item">
<dt>
{{ Product.sub_title2 }}
</dt>
<dd>
{{ Product.sub_comment2 }}
</dd>
</div>
{% endif %}
{% if Product.sub_title3 is not empty %}
<div class="item">
<dt>
{{ Product.sub_title3 }}
</dt>
<dd>
{{ Product.sub_comment3 }}
</dd>
</div>
{% endif %}
{% if Product.sub_title4 is not empty %}
<div class="item">
<dt>
{{ Product.sub_title4 }}
</dt>
<dd>
{{ Product.sub_comment4 }}
</dd>
</div>
{% endif %}
{% if Product.sub_title5 is not empty %}
<div class="item">
<dt>
{{ Product.sub_title5 }}
</dt>
<dd>
{{ Product.sub_comment5 }}
</dd>
</div>
{% endif %}
{% if Product.author_name is not empty %}
<div class="item">
<dt>
著者
</dt>
<dd>
{{ Product.author_name }}
</dd>
</div>
{% endif %}
{% if Product.maker_name is not empty %}
<div class="item">
<dt>
出版社
</dt>
<dd>
{{ Product.maker_name }}
</dd>
</div>
{% endif %}
<div class="item _price">
<dt>
販売価格(税込み)
</dt>
<dd>
{% if Product.hasProductClass -%}
{% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
{{ Product.getPrice02IncTaxMin|number_format }}円
{% else %}
{{ Product.getPrice02IncTaxMin|number_format }}円 ~ {{ Product.getPrice02IncTaxMax|number_format }}円
{% endif %}
{% else %}
{{ Product.getPrice02IncTaxMin|number_format }}円
{% endif %}
</dd>
</div>
</dl>
<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_widget(form.classcategory_id1) }}
{{ form_errors(form.classcategory_id1) }}
</div>
{% if form.classcategory_id2 is defined %}
<div class="ec-select">
{{ form_widget(form.classcategory_id2) }}
{{ form_errors(form.classcategory_id2) }}
</div>
{% endif %}
{% endif %}
<div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
{{ form_widget(form.quantity) }}
{{ form_errors(form.quantity) }}
</div>
</div>
<div class="ec-productRole__btn">
<button type="submit" class="btn-cart add-cart">
{{ 'カートに入れる'|trans }}
</button>
</div>
{% else %}
<div class="ec-productRole__btn">
<button type="button" class="btn-basic _disable" disabled="disabled">
{{ 'ただいま品切れ中です。'|trans }}
</button>
</div>
{% endif %}
{{ form_rest(form) }}
</form>
{#{% 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="btn-basic">#}
{# {{ 'お気に入りに追加'|trans }}#}
{# </button>#}
{# {% else %}#}
{# <button type="submit" id="favorite" class="btn-basic"#}
{# disabled="disabled">{{ 'お気に入りに追加済です。'|trans }}#}
{# </button>#}
{# {% endif %}#}
{# </div>#}
{# </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="btn-basic _sub _prev">{{ 'お買い物を続ける'|trans }}</span>
<a href="{{ url('cart') }}" class="btn-cart">{{ 'カートへ進む'|trans }}</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% if Product.author_name is not empty or Product.author_profile is not empty %}
<div class="ec-product__author">
<h3 class="title-icon _author">
著者の紹介
</h3>
<div class="ec-product__author-content">
<h4 class="ec-product__author-name">
{{ Product.author_name }}
</h4>
<p class="ec-product__author-text">
{{ Product.author_profile }}
</p>
</div>
</div>
{% endif %}
{% if Product.freearea %}
<div class="ec-productRole__description">
{{ include(template_from_string(Product.freearea)) }}
</div>
{% endif %}
</div>
{% endblock %}