{#
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.productsClassCategories = {
{% for PinpointProduct in pagination %}
{% set Product = PinpointProduct.ProductClass.Product %}
"{{ 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();
$('#orderby').val(orderBy);
$('#pageno').val(1);
$("#form1").submit();
});
var modalTimer;
$('.add-cart').on('click', function(e) {
var self = $(this);
onAddCart(e, $(this), 1, function() {
var $form = self.parents('li');
$form.find(".ec-productRole__btn--only").addClass("d-none");
$form.find(".ec-productRole__btn--group").removeClass("d-none");
window.clearTimeout(modalTimer);
$('.ec-modal').show()
modalTimer = window.setTimeout(function() {
$('.ec-modal').hide();
}, 1500)
});
});
$('.minus__btn').on('click', function(e) {
onAddCart(e, $(this), -1);
})
$('.plus__btn').on('click', function(e) {
onAddCart(e, $(this));
})
function onAddCart(e, self, quantity = 1, callback) {
var $form = $(self).parents('li').find('form.productForm');
// 個数フォームのチェック
$form.parent().find('.quantity').val(quantity);
e.preventDefault();
$.ajax({
url: $form.attr('action'),
type: $form.attr('method'),
data: $form.serialize(),
dataType: 'json',
beforeSend: function(xhr, settings) {
// Buttonを無効にする
$(self).prop('disabled', true);
}
}).done(function(data) {
// レスポンス内のメッセージをalertで表示
$.each(data.messages, function() {
$('#ec-modal-header').text(this);
});
var $quantityLabelEl = $(self).parents('li').find('.quantity_label');
$quantityLabelEl.text($quantityLabelEl.text() * 1 + quantity * 1);
if(callback) {
callback();
}
// カートブロックを更新する
$.ajax({
url: '{{ url('block_cart') }}',
type: 'GET',
dataType: 'html'
}).done(function(html) {
$('.ec-headerRole__cart').html(html);
});
}).fail(function(data) {
alert('{{ 'カートへの追加に失敗しました。'|trans }}');
$(self).prop('disabled', false);
}).always(function(data) {
var $parent = $(self).parents('li');
let stockVal = $parent.find('.stock').val() * 1;
var $quantityLabelEl = $parent.find('.quantity_label');
var _quantity = $quantityLabelEl.text() * 1;
if(_quantity == 0) {
// enable minus button
$(self).prop('disabled', false);
$parent.find(".ec-productRole__btn--only").removeClass("d-none");
$parent.find(".ec-productRole__btn--group").addClass("d-none");
}
if(_quantity > 0 && _quantity < stockVal) {
// Buttonを有効にする
$(self).prop('disabled', false);
$parent.find('.plus__btn').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 %}
<ul class="breadcrumb w-p">
<li class="breadcrumb__item">
<a href="{{ url('homepage') }}" class="breadcrumb__item__link">
ホーム
</a>
</li>
<li class="breadcrumb__item">
<p class="breadcrumb__item__arrow">></p>
</li>
<li class="breadcrumb__item">
<p class="breadcrumb__item__text">セール商品一覧</p>
</li>
</ul>
<div class="ec-pageHeader contentHeader">
<h1>{{ 'セール商品一覧'|trans }}</h1>
</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">
<ol class="ec-topicpath">
<li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
</li>
{% if Category is not null %}
{% for Path in Category.path %}
<li class="ec-topicpath__divider">|</li>
<li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
</li>
{% endfor %}
{% endif %}
{% if search_form.vars.value and search_form.vars.value.name %}
<li class="ec-topicpath__divider">|</li>
<li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
{% endif %}
</ol>
</div> #}
<div class="ec-searchnavRole__infos">
<div class="ec-searchnavRole__counter">
{% if pagination.totalItemCount > 0 %}
<p class="ec-searchnavRole__counter__title">検索結果</p>
{{ '<p class="ec-searchnavRole__counter__number">%count%件</p>'|trans({ '%count%': pagination.totalItemCount })|raw }}
{% else %}
<span class="">{{ 'お探しの商品は見つかりませんでした'|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>
<ul class="stockList">
<li class="stockList__block">
<p class="stockList__block__text">在庫あり:</p>
<p class="stockList__block__mark">◎</p>
</li>
<li class="stockList__block">
<p class="stockList__block__text">残りわずか:</p>
<p class="stockList__block__mark">○</p>
</li>
<li class="stockList__block">
<p class="stockList__block__text">取り寄せ:</p>
<p class="stockList__block__mark">■</p>
</li>
</ul>
{% if pagination.totalItemCount > 0 %}
<div class="ec-shelfRole">
<ul class="ec-shelfGrid">
{% for PinpointProduct in pagination %}
{% set Product = PinpointProduct.ProductClass.Product %}
<li class="ec-shelfGrid__item">
<a href="{{ url('product_detail', {'id': Product.id}) }}">
<div 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 %}>
{% if Product.Tags|length > 0 %}
<ul class="ec-shelfGrid__item-tags">
{% for Tag in Product.Tags %}
<li class="ec-shelfGrid__item-tags__tag tag_{{ Tag.id }}">{{ Tag }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
<p class="ec-shelfGrid__item-name">{{ Product.name }}</p>
{% if is_granted('ROLE_USER') %}
<div class="ec-shelfGrid__item-stock">
<div class="ec-shelfGrid__item-stock__block">
<p class="ec-shelfGrid__item-stock__block__title">
【発送目安】
</p>
<p class="ec-shelfGrid__item-stock__block__detail">
{% if Product.getDeliveryDuration %}
{{Product.getDeliveryDuration.name}}
{% else %}
指定なし
{% endif %}
</p>
</div>
<div class="ec-shelfGrid__item-stock__block">
<p class="ec-shelfGrid__item-stock__block__title">
【在庫】
</p>
{# 在庫をマークで表示何個から何個か◎等はこれから確認 #}
<p class="ec-shelfGrid__item-stock__block__detail">
{% if Product.getStockUnlimitedMin or Product.getStockMin >= 10 %}
◎
{% else %}
{% if Product.getStockMin >= 1 and Product.getStockMin <= 9 %}
○
{% endif %}
{% if Product.getStockMin <= 0 %}
■
{% endif %}
{% endif %}
</p>
</div>
</div>
{# {% if not Product.getStockUnlimitedMin %}
<p>
発送可能{{Product.getStockMin}}個
</p>
{% endif %} #}
{% if Product.description_list %}
<p>{{ Product.description_list|raw|nl2br }}</p>
{% endif %}
<div class="ec-shelfGrid__item-flex">
<p class="price02-default ec-shelfGrid__item-price">
{% if Product.isInSale %}
<span class="ec-shelfGrid__item-price__sale">セール商品</span>
{% endif %}
{% if Product.hasProductClass %}
{% if Product.getPrice02Min == Product.getPrice02Max %}
{{ Product.getPrice02IncTaxMin|price }}
{% else %}
{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
{% endif %}
{% else %}
{{ Product.getPrice02IncTaxMin|price }}
{% endif %}
</p>
<div class="ec-shelfGrid__item-flex__favorite">
<form class="ec-favoriteForm" action="?" method="?">
<div class="ec-productRole__btn">
<button data-method="POST" data-action="{{ url('product_add_favorite', {id:Product.id}) }}" id="favorite" class="{% if isFavorite[Product.id] is defined and isFavorite[Product.id] == true %} d-none {% endif %} ec-blockFavoriteBtn ec-blockBtn--cancel ec-shelfGrid__item-flex__favorite__btn">
<img src="{{ asset('assets/img/favorite/before.svg') }}" alt="お気に入り" width="24" height="24" loading="lazy">
</button>
<button data-method="DELETE" data-action="{{ url('product_favorite_delete', {id:Product.id}) }}" id="favorite" class="{% if isFavorite[Product.id] is defined and isFavorite[Product.id] == false %} d-none {% endif %}ec-blockFavoriteBtnDisable ec-blockBtn--cancel ec-shelfGrid__item-flex__favorite__btn">
<img src="{{ asset('assets/img/favorite/after.svg') }}" alt="お気に入り" width="24" height="24" loading="lazy">
</button>
</div>
</form>
</div>
</div>
</a>
{% if not Product.getStockUnlimitedMin and Product.getStockMin <= 0 and Product.isStockDiscontinued %}
<div class="ec-productRole__btn">
<button type="button" class="ec-disabled__btn" disabled="disabled">
{{ '在庫なし'|trans }}
</button>
</div>
{% else %}
{% set form = forms[Product.id] %}
<form class="productForm" 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 d-none"><span>{{ '数量'|trans }}</span>
{{ form_widget(form.quantity, {'attr': {'class': 'quantity'}} ) }}
{{ form_errors(form.quantity) }}
</div>
</div>
{{ form_rest(form) }}
</form>
{% set default = 0 %}
{% if itemInCart[Product.id] is defined %}
{% set default = itemInCart[Product.id] %}
{% endif %}
{% set disabled = false %}
{% if not Product.isStockDiscontinued %}
<input type="hidden" name="stock" class="stock" value="999999999999">
{% else %}
{% if Product.getStockMin <= default %}
{% set disabled = true %}
{% endif %}
<input type="hidden" name="stock" class="stock" value="{{Product.getStockMin}}">
{% endif %}
<div class="ec-productRole__btn--group ec-productRole__btn {% if itemInCart[Product.id] is defined %} d-block {% else %} d-none {% endif %}">
<div class="d-flex align-items-center ec-productRole__btn-wrapper">
<button class="minus__btn" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
<span>−</span>
</button>
<span class="quantity_label">{{ default }}</span>
<button class="plus__btn" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}" {% if disabled %}disabled{% endif %}>
<span>+</span>
</button>
</div>
</div>
<div class="ec-productRole__btn--only ec-productRole__btn {% if itemInCart[Product.id] is defined %} d-none {% else %} d-block {% endif %}">
<button type="submit" class="ec-regular__btn add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
{{ 'カートに入れる'|trans }}
</button>
</div>
{% endif %}
{% else %}
<a href="{{ url('entry_contact') }}" class="ec-blockProductBtn--action">会員登録はこちら</a>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
<div class="ec-modal">
<div class="ec-modal-overlay">
<div class="ec-modal-wrap">
<div class="ec-modal-box">
<div class="ec-role">
<div class="ec-modal-icon">
<img src="{{ asset('assets/img/icon/icon_cart.png', 'user_data') }}" alt="">
</div>
</div>
</div>
<div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
</div>
</div>
</div>
<ul class="stockList bottom">
<li class="stockList__block">
<p class="stockList__block__text">在庫あり:</p>
<p class="stockList__block__mark">◎</p>
</li>
<li class="stockList__block">
<p class="stockList__block__text">残りわずか:</p>
<p class="stockList__block__mark">○</p>
</li>
<li class="stockList__block">
<p class="stockList__block__text">取り寄せ:</p>
<p class="stockList__block__mark">■</p>
</li>
</ul>
<div class="ec-pagerRole">
{% include "pager.twig" with {'pages': pagination.paginationData} %}
</div>
{% endif %}
{% endif %}
{% endblock %}