{% extends 'default_frame.twig' %}
{% set body_id = 'product_page' %}
{% block javascript %}
<script>
{# eccube.productsClassCategories = {{% for Product in pagination %}"{{ Product.id|escape('js') }}": { { class_categories_as_json(Product) | raw } } {% if loop.last == false %}, {% endif %}{% endfor %}}; #}
$(function () {
// 表示件数を変更
$('.disp-number').change(function () {
console.log("hoge");
var dispNumber = $(this).val();
$('#disp_number').val(dispNumber);
$('#pageno').val(1);
$("#form1").submit();
});
// 並び順を変更
$('.order-by').change(function () {
var orderBy = $(this).val();
$('#orderby').val(orderBy);
$('#pageno').val(1);
$("#form1").submit();
});
$('.add-cart').on('click', function (e) {
var $form = $(this).parents('li').find('form');
// 個数フォームのチェック
var $quantity = $form.parent().find('.quantity');
if ($quantity.val() < 1) {
$quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
setTimeout(function () {
loadingOverlay('hide');
}, 100);
return true;
} else {
$quantity[0].setCustomValidity('');
}
e.preventDefault();
$.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>
{% endblock %}
{% block sub_area %}
<ul class="pankuzu">
<li><a href="{{ url('homepage') }}">トップ</a></li>
{% if Category is not null %}
{% for Path in Category.path %}
<li>
<a href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
</li>
{% endfor %}
{% else %}
<li>
<a href="{{ url('product_list') }}">{{subtitle}}</a>
</li>
{% endif %}
</ul>
{% endblock %}
{% block main %}
{% if search_form.category_id.vars.errors|length > 0 %}
<div class="ec-searchnavRole">
<p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
</div>
{% else %}
<form name="form1" id="form1" method="get" action="?">
{% for item in search_form %}
<input type="hidden" id="{{ item.vars.id }}" name="{{ item.vars.full_name }}" {% if item.vars.value is not empty
%}value="{{ item.vars.value }}" {% endif %} />
{% endfor %}
</form>
<div class="main_ttl_wrap">
{% if Category is not null %}
{% for Path in Category.path %}
{% if loop.last %}
<h2 class="main_ttl">{{ Path.name }}</h2>
{% endif %}
{% endfor %}
{% else %}
<h2 class="main_ttl">商品一覧</h2>
{% endif %}
</div>
<div class="sortarea_wrap">
{% if pagination.totalItemCount > 0 %}
<p><span class="txt_red">{{pagination.totalItemCount}}件</span>の商品がございます。</p>
{% else %}
<p>お探しの商品は見つかりませんでした</p>
{% endif %}
<ul class="sortarea">
<li>並び替え</li>
<li>
{{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
</li>
<li class="selectarea">
{{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
</li>
</ul>
</div>
{% if pagination.totalItemCount > 0 %}
{% include "pager.twig" with {'pages': pagination.paginationData} %}
<ul class="list_item">
{% for Product in pagination %}
{# {% set frame_width = getProduct_field(Product.id,"frame_width") %}
{% set frame_thickness = getProduct_field(Product.id,"frame_thickness") %} #}
{% set minPrice = CustomProductFindWhere(Product,"min_price") %}
{% set maxPrice = CustomProductFindWhere(Product,"max_price") %}
{% set maxTotal = CustomProductFindWhere(Product,"max_total") %}
<li>
<a href="{{ url('product_detail', {'id': Product.id}) }}">
<div class="list_item_img">
<img src="{{ asset(Product.MainListImage|no_image_product, 'save_image') }}" alt="{{ Product.name }}">
</div>
</a>
<p class="list_item_name">{{ Product.name }}</p>
{% if Product.getMinLength %}
<p class="list_item_detail">フレーム幅:{{Product.getMinLength|number_format()}}mm</p>
{% endif %}
{% if Product.getMaxLength %}
<p class="list_item_detail">フレーム厚み:{{Product.getMaxLength|number_format()}}mm</p>
{% endif %}
{% if maxTotal %}
<p class="list_item_detail">ヨコ・タテ合計: {{ maxTotal|number_format() }}mmまで</p>
{% endif %}
<p class="list_item_price">
{% if minPrice != maxPrice and maxPrice is not null %}
{{ minPrice|number_format() }}~{{ maxPrice|number_format()
}}
{% elseif minPrice is not null %}
{{ minPrice|number_format() }}
{% elseif maxPrice is not null %}
{{ maxPrice|number_format() }}
{% elseif Product.hasProductClass %}
{% if Product.getPrice02Min == Product.getPrice02Max %}
{{ Product.getPrice02IncTaxMin|number_format() }}
{% else %}
{{ Product.getPrice02IncTaxMin|number_format() }} ~ {{ Product.getPrice02IncTaxMax|number_format() }}
{% endif %}
{% else %}
{{ Product.getPrice02IncTaxMin|number_format() }}
{% endif %}
<span>円 (税込)</span>
</p>
</li>
{% endfor %}
</ul>
{% include "pager.twig" with {'pages': pagination.paginationData} %}
{% endif %}
{% endif %}
{% endblock %}