{#
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 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();
$('#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 main %}
<div class="main-top">
{# ページタイトル #}
<div id="pagetitle">
<h2>
PRODUCT
<small>商品</small>
</h2>
<div class="image">
<img src="{{ asset('assets/assets/images/pagetitle-image-product.jpg') }}">
</div>
</div>
</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 %}
{{ '<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 %}
<section id="carender">
{# タグ:おすすめ商品の商品を1件表示 #}
{% set recomendTag = 13 %}
{% if Category is not null %}
{# 現在のカテゴリ取得 #}
{% set lastCategoryId = null %}
{% for Path in Category.path %}
{% if loop.last %}
{% set lastCategoryId = Path.id %}
{% endif %}
{% endfor %}
{% set desiTag = repository("Eccube\\Entity\\Category").find(lastCategoryId) %}
{%
set products = repository("Eccube\\Entity\\Product")
.createQueryBuilder('p')
.innerJoin('p.ProductCategories', 'pc')
.where('pc.Category = :category_id')
.andWhere('p.Status = 1')
.setParameter('category_id', desiTag)
.orderBy('p.update_date', 'DESC')
.setMaxResults(9999)
.getQuery()
.getResult()
%}
{% else %}
{% set desiTag = repository("Eccube\\Entity\\Category").find(recomendTag) %}
{%
set products = repository("Eccube\\Entity\\Product")
.createQueryBuilder('p')
.innerJoin('p.ProductCategories', 'pc')
.where('pc.Category = :category_id')
.andWhere('p.Status = 1')
.setParameter('category_id', desiTag)
.orderBy('p.update_date', 'DESC')
.setMaxResults(9999)
.getQuery()
.getResult()
%}
{% endif %}
{% if products %}
<div class="recommendation">
<p class="title">カテゴリ別おすすめ商品</p>
<div class="contents">
{% set break = false %}
{% for Product in products if not break %}
{% set hasCategory = Product.ProductCategories|filter(pc => pc.Category.id == recomendTag)|length > 0 %}
{% if hasCategory %}
<div class="block">
<a href="{{ url('product_detail', {'id': Product.id}) }}">
{% if Product.stock_find %}
<div class="image">
<img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
</div>
{% else %}
<div class="image souldout">
<img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
</div>
{% endif %}
<p class="title">
{{ Product.name }}
</p>
{% if Product.code_min is not empty %}<p class="type">{{ Product.code_min }}</p>{% endif %}
{# 価格表示ここから #}
{# 在庫があるかどうか #}
{% if Product.stock_find %}
{# 販売価格にテキストがあるかどうか #}
{% if Product.ViewData(11) is not empty %}
<p class="price"><span>{{Product.ViewData(11)}}</span></p>
{# 販売価格にテキストがない場合価格を表示 0円の場合は準備中のテキストを表示 #}
{% else %}
{% if Product.hasProductClass -%}
{% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
<p class="price"><span>{% if Product.getPrice02IncTaxMin == 0 %}{{ include('Block/textcampaign.twig') }}</span>{% else %}{{ Product.getPrice02IncTaxMin|price }}</span>/100冊{% endif %}</p>
{% else %}
<p class="price"><span>{{ Product.getPrice02IncTaxMin|price }}
~
{{ Product.getPrice02IncTaxMax|price }}</span>/100冊</p>
{% endif %}
{% else %}
<p class="price"><span>{% if Product.getPrice02IncTaxMin == 0 %}{{ include('Block/textcampaign.twig') }}</span>{% else %}{{ Product.getPrice02IncTaxMin|price }}</span>/100冊{% endif %}</p>
{% endif %}
{% endif %}
{# 在庫がない場合 #}
{% else %}
{# 販売価格にテキストがあるかどうか #}
{% if Product.ViewData(11) is not empty %}
<p class="price"><span>{{Product.ViewData(11)}}</span></p>
{# 販売価格にテキストがない場合 #}
{% else %}
<p class="price"><span>{{ include('Block/textcampaign.twig') }}</span></p>
{% endif %}
{% endif %}
{# 価格表示ここまで #}
</a>
</div>
{% set break = true %}
{% else %}
{% endif %}
{% endfor %}
</div>
</div>
{% endif %}
<div class="contents">
{% for Product in pagination %}
<div class="block">
<a href="{{ url('product_detail', {'id': Product.id}) }}">
{% if Product.stock_find %}
<div class="image">
<img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
</div>
{% else %}
<div class="image souldout">
<img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
</div>
{% endif %}
<p class="title">
{{ Product.name }}
</p>
{% if Product.code_min is not empty %}<p class="type">{{ Product.code_min }}</p>{% endif %}
{# 価格表示ここから #}
{# 在庫があるかどうか #}
{% if Product.stock_find %}
{# 販売価格にテキストがあるかどうか #}
{% if Product.ViewData(11) is not empty %}
<p class="price"><span>{{Product.ViewData(11)}}</span></p>
{# 販売価格にテキストがない場合価格を表示 0円の場合は準備中のテキストを表示 #}
{% else %}
{% if Product.hasProductClass -%}
{% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
<p class="price"><span>{% if Product.getPrice02IncTaxMin == 0 %}{{ include('Block/textcampaign.twig') }}</span>{% else %}{{ Product.getPrice02IncTaxMin|price }}</span>/100冊{% endif %}</p>
{% else %}
<p class="price"><span>{{ Product.getPrice02IncTaxMin|price }}
~
{{ Product.getPrice02IncTaxMax|price }}</span>/100冊</p>
{% endif %}
{% else %}
<p class="price"><span>{% if Product.getPrice02IncTaxMin == 0 %}{{ include('Block/textcampaign.twig') }}</span>{% else %}{{ Product.getPrice02IncTaxMin|price }}</span>/100冊{% endif %}</p>
{% endif %}
{% endif %}
{# 在庫がない場合 #}
{% else %}
{# 販売価格にテキストがあるかどうか #}
{% if Product.ViewData(11) is not empty %}
<p class="price"><span>{{Product.ViewData(11)}}</span></p>
{# 販売価格にテキストがない場合 #}
{% else %}
<p class="price"><span>{{ include('Block/textcampaign.twig') }}</span></p>
{% endif %}
{% endif %}
{# 価格表示ここまで #}
</a>
</div>
{% endfor %}
</div>
</section>
<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="ec-pagerRole">
{% include "pager.twig" with {'pages': pagination.paginationData} %}
</div>
{% endif %}
{% endif %}
{% endblock %}