{#
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 %}
{% set current_category = null %}
{#
<div>
{{CategorySelf.id}} {{CategorySelf.name}} {{CategorySelf.category_picfilename}}
{% for cat in CategoryList %}
<div class="catinfo">
{{cat.id}} {{cat.name}} {{cat.category_picfilename}}
</div>
{% endfor %}
</div>
#}
{#
カテゴリを一覧で一気に表示する
{% if Category !=null and Category.id != null and Category.id == '21' %}
<div>
{% for product in Category21Products %}
{% if current_category != product.category_name %}
{% set current_category = product.category_name %}
<div class="category-header">
<a href="{{ url('product_list') }}?category_id={{ product.category_id }}">{{ current_category }}</a>
</div>
{% endif %}
<div class="product-item">
・<a href="{{ url('product_detail', {'id': product.product_id}) }}">
{{ product.product_name }}
</a>
</div>
{% endfor %}
</div>
{% endif %}
<style>
.category-header {
width: 100%;
border: 1px solid #000; /* 線の色とスタイルを指定 */
padding: 10px; /* 内側の余白を指定 */
box-sizing: border-box; /* ボックスのサイズを含む */
background-color: #f8f8f8; /* 背景色を指定(任意) */
font-weight: bold; /* フォントを太字にする(任意) */
margin-bottom: 10px; /* 下部の余白を指定(任意) */
}
.product-item {
margin-left: 20px; /* 商品名を少しインデントする(任意) */
}
</style>
#}
{% 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="catimgself">
{% if CategorySelf is not empty and CategorySelf.category_picfilename is not empty %}
<img src="{{ asset(CategorySelf.category_picfilename) }}" alt="{{ CategorySelf.category_picalt }}" />
{% endif %}
<div class="catimgchild-container">
{% if CategoryList is not empty %}
{% for cat in CategoryList %}
{% if cat is not empty and cat.category_minipicfilename is not empty and (cat.category_enable is empty or cat.category_enable != '1') %}
<div class="catimgchild">
<a href="{{ url('product_list') }}?category_id={{ cat.id }}">
<img src="{{ asset(cat.category_minipicfilename) }}" alt="{{ cat.category_picalt }}" />
</a>
</div>
{% endif %}
{% endfor %}
{% endif %}
</div>
</div>
<style>
.catimgself {
display: flex;
flex-direction: column;
align-items: center;
}
.catimgself img {
max-width: 100%;
height: auto;
}
.catimgchild-container {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin: 0; /* 親コンテナのマージンをリセット */
}
.catimgchild {
flex: 1 0 33.33%; /* 子要素を3列に分けるために幅を調整 */
max-width: 33.33%; /* 子要素の最大幅を設定 */
text-align: center;
margin: 0; /* 子要素間の間隔をなくす */
box-sizing: border-box; /* パディングとボーダーを含めて要素のサイズを計算 */
}
.catimgchild img {
width: 100%;
height: auto;
}
</style>
{#
{% if Category is not null %}
{% for Path in Category.path %}
{% if loop.last %}
{% if Path.id=='21' %}
<div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/21.jpg') }}" /></div>
{% elseif Path.id=='22' %}
<div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/22.jpg') }}" /></div>
{% elseif Path.id=='24' %}
<div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/24.jpg') }}" /></div>
{% elseif Path.id=='25' %}
<div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/25.jpg') }}" /></div>
{% elseif Path.id=='26' %}
<div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/26.jpg') }}" /></div>
{% elseif Path.id=='27' %}
<div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/27.jpg') }}" /></div>
{% elseif Path.id=='28' %}
<div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/28.jpg') }}" /></div>
{% elseif Path.id=='76' or Path.id=='77' or Path.id=='78' or Path.id=='79' or Path.id=='81' or Path.id=='80' or Path.id=='83' or Path.id=='86' %}
<div class="selectedmenu">「 お米の産地別 」を選択中</div>
{% elseif Path.id=='66' or Path.id=='67' or Path.id=='68' or Path.id=='69' or Path.id=='70' or Path.id=='71' %}
<div class="selectedmenu">「 お米の銘柄別 」を選択中</div>
{% elseif Path.id=='41' or Path.id=='42' or Path.id=='43' %}
<div class="selectedmenu">「 価格帯ごと 」を選択中</div>
{% elseif Path.id=='58' or Path.id=='59' or Path.id=='60' %}
<div class="selectedmenu">「 粒サイズ 」を選択中</div>
{% elseif Path.id=='49' or Path.id=='50' or Path.id=='51' or Path.id=='52' %}
<div class="selectedmenu">「 ロットサイズ 」を選択中</div>
{% elseif Path.id=='116' or Path.id=='117' or Path.id=='117' %}
<div class="selectedmenu">「 精米レベル 」を選択中</div>
{% elseif Path.id=='10' %}
<div class="selectedmenu">「 産直品コーナー 」を選択中</div>
{% elseif Path.id=='12' %}
<div class="selectedmenu">「 産直 畜産品市場 」を選択中</div>
{% elseif Path.id=='13' %}
<div class="selectedmenu">「 産直 水産市場 」を選択中</div>
{% elseif Path.id=='14' %}
<div class="selectedmenu">「 産直 農産品市場 」を選択中</div>
{% elseif Path.id=='15' %}
<div class="selectedmenu">「 産直 加工食品市場 」を選択中</div>
{% elseif Path.id=='19' %}
<div class="selectedmenu">「 産直 訳アリB級品 」を選択中</div>
{% else %}
<div class="selectedmenu">「 {{ Path.name }} 」を選択中</div>
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
#}
<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>
{% if Path.name == '産地で選ぶ' %}
|<a href="/products/list?category_id=76">北海道</a>
|<a href="/products/list?category_id=77">東北</a>
|<a href="/products/list?category_id=78">関東</a>
|<a href="/products/list?category_id=79">信越</a>
|<a href="/products/list?category_id=81">北陸</a>
|<a href="/products/list?category_id=80">中部</a>
|<a href="/products/list?category_id=83">西日本</a>
|<a href="/products/list?category_id=86">国内</a>
{% elseif Path.name == '銘柄で選ぶ' %}
|<a href="/products/list?category_id=66">コシヒカリ</a>
|<a href="/products/list?category_id=67">ひとめぼれ</a>
|<a href="/products/list?category_id=68">あきたこまち</a>
|<a href="/products/list?category_id=69">各他の銘柄</a>
|<a href="/products/list?category_id=70">逸品米</a>
|<a href="/products/list?category_id=71">無洗米</a>
{% elseif Path.name == '価格帯で選ぶ' %}
|<a href="/products/list?category_id=41">299円以下</a>
|<a href="/products/list?category_id=42">239円以下</a>
|<a href="/products/list?category_id=43">329円以上</a>
{% elseif Path.name == '粒サイズで選ぶ' %}
|<a href="/products/list?category_id=58">通常</a>
|<a href="/products/list?category_id=59">やや小粒</a>
|<a href="/products/list?category_id=60">ブレンド</a>
{% elseif Path.name == 'ロットサイズで選ぶ' %}
|<a href="/products/list?category_id=49">小ロット</a>
<a href="/products/list?category_id=50">業務用</a>
|<a href="/products/list?category_id=51">大口割引</a>
|<a href="/products/list?category_id=52">激安</a>
{% elseif Path.name == '精米方法で選ぶ' %}
|<a href="/products/list?category_id=116">上白精米</a>
|<a href="/products/list?category_id=117">精白米</a>
|<a href="/products/list?category_id=118">玄米</a>
{% endif %}
</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>
<div id="flash-area"></div>
{% if pagination.totalItemCount > 0 %}
<div class="ec-shelfRole">
<ul class="ec-shelfGrid">
{% for Product in pagination %}
{% if Product.limited_ids == '' %}
<li class="ec-shelfGrid__item">
<a href="{{ url('product_detail', {'id': Product.id}) }}">
<p class="ec-shelfGrid__item-image">
{# === SDR === #}
{% if eccube_config.app_mode != 'display' %}
{% set image_url = asset(Product.main_list_image, 'save_image') %}
{% elseif Product.mainDisplayImage %}
{% set image_url = eccube_config.img_folder ~ Product.mainDisplayImage.fileName %}
{% endif %}
{% if image_url is defined %}
<img src="{{ image_url }}" alt="{{ Product.name }}" {% if loop.index > 5 %}loading="lazy"{% endif %}>
{% else %}
<div class="ec-shelfGrid__item-noimage">
★画像準備中
</div>
{% endif %}
{# === SDR === #}
</p>
<p>{{ Product.name }}</p>
{% if Product.description_list %}
<p>{{ Product.description_list|raw|nl2br }}</p>
{% endif %}
<p class="price02-default">
{# === SDR === #}
{% if eccube_config.app_mode != 'display' %}
{% if Product.hasProductClass %}
{% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
{{ Product.getPrice02IncTaxMin|price }}
{% else %}
{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
{% endif %}
{% else %}
{{ Product.getPrice02IncTaxMin|price }}
{% endif %}
{% else %}
{#規格あり・規格なしに関係なく、表示対象の ProductClass から価格を取得#}
{% if Product.getPriceSellerInTaxMin == Product.getPriceSellerInTaxMax %}
{{ Product.getPriceSellerInTaxMin|price }}
{% else %}
{{ Product.getPriceSellerInTaxMin|price }} ~ {{ Product.getPriceSellerInTaxMax|price }}
{% endif %}
{% endif %}
</p>
</a>
{# === SDR === #}
{% if eccube_config.app_mode != 'display' %}
{% if Product.stock_find %}
{% if Product.locked_ids is not empty %}
<br>
<button type="button" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" onclick="submitFormAndRedirect('{{ Product.id }}', '{{ url('product_detail', {'id': Product.id}) }}')">
{{ '詳細表示'|trans }}
</button>
{% else %}
{% 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>
{% endif %}
{% else %}
<div class="ec-productRole__btn">
<button type="button" class="ec-blockBtn--action" disabled="disabled">
{{ 'ただいま品切れ中です。'|trans }}
</button>
</div>
{% endif %}
{% endif %}
{# === SDR === #}
</li>
{% endif %}
{% endfor %}
</ul>
</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>
<div class="ec-pagerRole">
{% include "pager.twig" with {'pages': pagination.paginationData} %}
</div>
{% endif %}
{% endif %}
<style>
.selectedmenu {
height: 35px;
margin: 20px;
border: 0px solid;
background-color: #F0FFF0;
display: flex;
align-items: center;
justify-content: center; /* 水平方向にも中央揃えする場合 */
}
.selectedmenu img {
/*height: 50%;*/
}
</style>
<script>
function submitFormAndRedirect(productId, url) {
window.location.href = url;
}
</script>
<style>
.custom-flash {
border: 2px solid #e60000; /* 赤い枠 */
background-color: #ffe6e6; /* 薄いピンク背景 */
color: #900; /* 赤系文字色 */
padding: 12px 16px;
border-radius: 4px;
margin-bottom: 10px;
font-weight: bold;
}
</style>
{% endblock %}