{#
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>
.c_sale {
position: absolute;
top: 0;
background-color: red;
padding: 4px 8px;
color: #fff;
font-size: 12px;
}
</style>
{% endblock %}
{% 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() {
var dispNumber = $(this).val();
$('#disp_number').val(dispNumber);
$('#pageno').val(1);
$("#form1").submit();
});
// 並び順を変更
$('.order-by').change(function() {
var orderBy = $(this).val();
$('#pageno').val(1);
$('#orderby').val(orderBy);
$("#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 main %}
<div class="ec-productRole">
<ol class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a itemprop="item" href="/">
<span itemprop="name">TOP</span>
</a>
<meta itemprop="position" content="1"/>
</li>
{% if Category is not null %}
{% for Path in Category.path %}
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a itemprop="item" href="{{ url('product_list') }}?category_id={{ Path.id }}">
<span itemprop="name">{{ Path.name }}</span>
</a>
<meta itemprop="position" content="2"/>
</li>
{% endfor %}
{% endif %}
</ol>
</div>
{% if search_form.category_id.vars.errors|length > 0 %}
<div class="ec-searchnavRole">
<p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
</div>
{% else %}
<div class="ec-searchnavRole">
<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="ec-searchnavRole__topicpath gnavi__list_sp">
{# カテゴリー一覧 #}
{% set all_categories = [] %}
{# 親カテゴリーを追加 #}
{% if Category is not null and Category.path is not null %}
{% for Path in Category.path %}
{% set category_item = { 'id': Path.id, 'name': Path.name } %}
{% if category_item not in all_categories %}
{% set all_categories = all_categories | merge([category_item]) %}
{% endif %}
{% endfor %}
{% endif %}
{# 子カテゴリーを追加 #}
{% if Category is not null %}
{% set cate_childs = Category.getDescendants %}
{% for cate in cate_childs %}
{% set category_item = { 'id': cate.id, 'name': cate.name } %}
{% if category_item not in all_categories %}
{% set all_categories = all_categories | merge([category_item]) %}
{% endif %}
{% endfor %}
{% endif %}
{# カテゴリーリストSP #}
<div class="ec-itemNav__listSp">
<div class="ec-itemNav gnavi__list_sp">
<span class="ec-itemNav-dropdown js-dropdown">
選択してください<span class="dli-chevron-down"></span>
</span>
{# 全てのカテゴリーを表示 #}
{#
<div class="dropdown__lists_sp js-dropdown-contents">
<ul class="ec-itemNav__nav">
{% for loop_index, category in all_categories %}
{% if loop_index == 0 %}
<li class="ec-topicpath__item dropdown__list_sp{% if category.id == app.request.query.get('category_id') %} ec-topicpath__item--active{% endif %}">
<a href="/products/list?category_id={{ category.id }}">全て</a>
</li>
{% else %}
<li class="ec-topicpath__item dropdown__list_sp{% if category.id == app.request.query.get('category_id') %} ec-topicpath__item--active{% endif %}">
<a href="/products/list?category_id={{ category.id }}">{{ category.name }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
#}
</div>
</div>
{# カテゴリーリストPC #}
<ul class="ec-topicpath ec-topicpath__listPc">
{% for loop_index, category in all_categories %}
{% if loop_index == 0 %}
<li class="ec-topicpath__item dropdown__list_sp{% if category.id == app.request.query.get('category_id') %} ec-topicpath__item--active{% endif %}">
<a href="/products/list?category_id={{ category.id }}">全て</a>
</li>
{% else %}
<li class="ec-topicpath__item dropdown__list_sp{% if category.id == app.request.query.get('category_id') %} ec-topicpath__item--active{% endif %}">
<a href="/products/list?category_id={{ category.id }}">{{ category.name }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
<div class="ec-searchnavRole__infos">
<div class="ec-searchnavRole__counter">
{% if pagination.totalItemCount > 0 %}
{{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
{% else %}
<span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
{% endif %}
</div>
{% if pagination.totalItemCount > 0 %}
<div class="ec-searchnavRole__actions">
<div
class="ec-select">
{# {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}#}
{{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
</div>
</div>
{% endif %}
</div>
</div>
{% if pagination.totalItemCount > 0 %}
<div class="ec-pagerRole">
{% include "pager.twig" with {'pages': pagination.paginationData} %}
</div>
<div class="ec-shelfRole">
<ul class="ec-shelfGrid">
{% for Product in pagination %}
<li class="ec-shelfGrid__item">
<a href="{{ url('product_detail', {'id': Product.id}) }}">
<p class="ec-shelfGrid__item-image">
<img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy" {% endif %}>
</p>
<div class="ec-shelfGrid__item_border"></div>
<p class="ec-shelfGrid__item-title">{{ Product.name }}</p>
{% if Product.description_list %}
<p>{{ Product.description_list|raw|nl2br }}</p>
{% endif %}
<p class="price02-default">
{% if Product.hasProductClass %}
{% if Product.getPrice02Min == Product.getPrice02Max %}
{{ Product.getPrice02IncTaxMin|price }}
{% else %}
{{ Product.getPrice02IncTaxMin|price }}
~
{{ Product.getPrice02IncTaxMax|price }}
{% endif %}
{% else %}
{{ Product.getPrice02IncTaxMin|price }}
{% endif %}
{% if not Product.stock_find %}<span>SOLD OUT</span>{% endif %}
</p>
{% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
<div class="c_sale"><span class="price01-default">SALE</span></div>
{% endif %}
</a>
{{ include('Block/product_list_favorite_block.twig') }}
{#{% if Product.stock_find %}
{% set form = forms[Product.id] %}
<form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
<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, {'attr': {'class': 'quantity'}}) }}
{{ form_errors(form.quantity) }}
</div>
</div>
{{ form_rest(form) }}
</form>
<div class="ec-productRole__btn">
<button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
{{ 'カートに入れる'|trans }}
</button>
</div>
{% else %}
<div class="ec-productRole__btn">
<button type="button" class="ec-blockBtn--action" disabled="disabled">
{{ 'ただいま品切れ中です。'|trans }}
</button>
</div>
{% endif %}#}
</li>
{% endfor %}
</ul>
<div class="ec-pagerRole">
{% include "pager.twig" with {'pages': pagination.paginationData} %}
</div>
</div>
<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>
{% endif %}
{% endif %}
{% endblock %}