{#
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 product_list' %}
{% block stylesheet %}
<link rel="stylesheet" href="{{ asset('assets/css/game-category-layout.css', 'user_data') }}">
{% 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();
$('#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').html(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()
});
// ゲーム別おすすめPC 親カテゴリ専用レイアウト (ID=46)
{% if Category and Category.id == 46 %}
(function() {
console.log('=== Game category parent layout: Started ===');
// 子カテゴリの定義
var gameCategories = [
{
id: 47,
name: 'ARC Raiders',
icon: '/html/user_data/game_icons/arc_raiders.jpg'
},
{
id: 48,
name: 'APEX LEGENDS',
icon: '/html/user_data/game_icons/apex_legends.jpg'
},
{
id: 49,
name: 'Valorant',
icon: '/html/user_data/game_icons/valorant.jpg'
},
{
id: 50,
name: '原神',
icon: '/html/user_data/game_icons/genshin.jpg'
}
];
var $shelfGrid = $('.ec-shelfGrid');
var $items = $shelfGrid.find('.ec-shelfGrid__item');
if ($items.length === 0) {
console.warn('No products found');
return;
}
// 商品をカテゴリごとに分類
var productsByCategory = {};
$items.each(function() {
var $item = $(this);
var categoryIds = $item.attr('data-category-ids');
if (!categoryIds) return;
var categories = categoryIds.split(',').map(function(id) {
return parseInt(id.trim());
});
gameCategories.forEach(function(game) {
if (categories.indexOf(game.id) !== -1) {
if (!productsByCategory[game.id]) {
productsByCategory[game.id] = [];
}
productsByCategory[game.id].push($item.clone());
}
});
});
// 新しいレイアウトを構築
var $newLayout = $('<div class="game-category-parent-layout"></div>');
gameCategories.forEach(function(game) {
var products = productsByCategory[game.id] || [];
var $section = $('<div class="game-section" data-game-id="' + game.id + '"></div>');
var $title = $('<h2 class="game-section-title">' +
'<a href="{{ url("product_list") }}?category_id=' + game.id + '">' +
game.name + ' 推奨PC</a>' +
'</h2>');
var $layout = $('<div class="game-section-layout"></div>');
var $iconSection = $('<a href="{{ url("product_list") }}?category_id=' + game.id + '" class="game-icon-section">' +
'<img src="' + game.icon + '" alt="' + game.name + '" class="game-icon-image">' +
'</a>');
var $productsSection = $('<div class="game-products-section"></div>');
var $slider = $('<div class="game-products-slider slider-' + game.id + '"></div>');
if (products.length > 0) {
products.forEach(function($product) {
$slider.append($product);
});
} else {
$slider.html('<div class="no-products"><p>商品準備中です</p></div>');
}
$productsSection.append($slider);
$layout.append($iconSection);
$layout.append($productsSection);
$section.append($title);
$section.append($layout);
$newLayout.append($section);
});
$shelfGrid.replaceWith($newLayout);
// スライダー初期化
setTimeout(function() {
gameCategories.forEach(function(game) {
var $sliderElement = $('.slider-' + game.id);
var itemCount = $sliderElement.find('.ec-shelfGrid__item').length;
if (itemCount > 0) {
if ($sliderElement.hasClass('slick-initialized')) {
$sliderElement.slick('unslick');
}
$sliderElement.slick({
slidesToShow: 4,
slidesToScroll: 1,
infinite: false,
arrows: true,
dots: false,
prevArrow: '<button type="button" class="slick-prev"><img src="{{ asset("assets/icon/slick-arrow-left-white.svg") }}" alt="前へ" /></button>',
nextArrow: '<button type="button" class="slick-next"><img src="{{ asset("assets/icon/slick-arrow-right-white.svg") }}" alt="次へ" /></button>',
responsive: [
{
breakpoint: 1200,
settings: { slidesToShow: 3, dots: false }
},
{
breakpoint: 768,
settings: { slidesToShow: 1, slidesToScroll: 1, arrows: false, dots: false }
},
{
breakpoint: 480,
settings: { slidesToShow: 1, slidesToScroll: 1, arrows: false, dots: false }
}
]
});
// スマホでスライド状態を監視
if ($(window).width() <= 768) {
$sliderElement.on('afterChange', function(event, slick, currentSlide) {
var isLast = (currentSlide >= slick.slideCount - 1);
if (isLast) {
$(this).closest('.game-products-section').addClass('no-more-slides');
} else {
$(this).closest('.game-products-section').removeClass('no-more-slides');
}
});
}
}
});
}, 300);
console.log('=== Game category parent layout: Complete ===');
})();
{% endif %}
</script>
{% endblock %}
{% block main %}
{% if search_form.vars.value.category_id.id is defined %}
{{ include('Block/category'~search_form.vars.value.category_id.id~'.twig', ignore_missing = true) }}
{% endif %}
{% 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 %}
<div class="ec-shelfRole">
<ul class="ec-shelfGrid">
{% for Product in pagination %}
<li class="ec-shelfGrid__item"
data-product-id="{{ Product.id }}"
{% if Product.ProductCategories|length > 0 %}
data-category-ids="{% for pc in Product.ProductCategories %}{{ pc.Category.id }}{% if not loop.last %},{% endif %}{% endfor %}"
{% endif %}>
<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 }}" loading="lazy">
</p>
<ul class="ec-shelfRole__tags">
{% for Tag in Product.ProductTag %}
{{ include('@DesignTag42/tag_list.twig', ignore_missing = true) }}
{% if Tag %}
<li class="ec-shelfRole__tag">{{ Tag.Tag }}</li>
{% endif %}
{% endfor %}
</ul>
<p class="ec-shelfGrid__item-name">{{ 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 %}
</p>
</a>
</li>
{% 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 %}
{% endblock %}