app/template/HF4002/Product/list.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  4. http://www.ec-cube.co.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {#
  9.     キャンペーン用設定
  10.     ↓↓↓ここから↓↓↓
  11. #}
  12. {% set start_date = '2021-09-06'|date('Y-m-d') %}
  13. {% set end_date = '2021-09-27'|date('Y-m-d') %}
  14. {% set campaign_category_id = "174" %}
  15. {% set coupon_code = "eio100anniv" %}
  16. {% if start_date <= date()|date('Y-m-d') and date()|date('Y-m-d') <= end_date %}
  17.     {% set campaign_valid = true %}
  18. {% else %}
  19.     {% set campaign_valid = false %}
  20. {% endif %}
  21. {% extends 'default_frame.twig' %}
  22. {% set body_class = 'product_page' %}
  23. {#
  24.     ↑↑↑ここまで↑↑↑
  25.     固定バナー対応
  26.     ↓↓↓ここから↓↓↓
  27. #}
  28. {% set jytp_id = "75" %}
  29. {% set jytp_url = '/html/user_data/top/top-slider_20210603_2_PC.jpg' %}
  30. {#
  31.     ↑↑↑ここまで↑↑↑
  32. #}
  33. {% block javascript %}
  34.     <script>
  35.         eccube.productsClassCategories = {
  36.             {% for Product in pagination %}
  37.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  38.             {% endfor %}
  39.         };
  40.         $(function() {
  41.             // 表示件数を変更
  42.             $('.disp-number').change(function() {
  43.                 var dispNumber = $(this).val();
  44.                 $('#disp_number').val(dispNumber);
  45.                 $('#pageno').val(1);
  46.                 $("#form1").submit();
  47.             });
  48.             // 並び順を変更
  49.             $('.order-by').change(function() {
  50.                 var orderBy = $(this).val();
  51.                 $('#orderby').val(orderBy);
  52.                 $('#pageno').val(1);
  53.                 $("#form1").submit();
  54.             });
  55.             $('.add-cart').on('click', function(e) {
  56.                 var $form = $(this).parents('li').find('form');
  57.                 // 個数フォームのチェック
  58.                 var $quantity = $form.parent().find('.quantity');
  59.                 if ($quantity.val() < 1) {
  60.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  61.                     setTimeout(function() {
  62.                         loadingOverlay('hide');
  63.                     }, 100);
  64.                     return true;
  65.                 } else {
  66.                     $quantity[0].setCustomValidity('');
  67.                 }
  68.                 e.preventDefault();
  69.                 $.ajax({
  70.                     url: $form.attr('action'),
  71.                     type: $form.attr('method'),
  72.                     data: $form.serialize(),
  73.                     dataType: 'json',
  74.                     beforeSend: function(xhr, settings) {
  75.                         // Buttonを無効にする
  76.                         $('.add-cart').prop('disabled', true);
  77.                     }
  78.                 }).done(function(data) {
  79.                     // レスポンス内のメッセージをalertで表示
  80.                     $.each(data.messages, function() {
  81.                         $('#ec-modal-header').html(this);
  82.                     });
  83.                     $('#ec-modal-checkbox').prop('checked', true);
  84.                     // カートブロックを更新する
  85.                     $.ajax({
  86.                         url: '{{ url('block_cart') }}',
  87.                         type: 'GET',
  88.                         dataType: 'html'
  89.                     }).done(function(html) {
  90.                         $('.ec-headerRole__cart').html(html);
  91.                     });
  92.                 }).fail(function(data) {
  93.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  94.                 }).always(function(data) {
  95.                     // Buttonを有効にする
  96.                     $('.add-cart').prop('disabled', false);
  97.                 });
  98.             });
  99.         });
  100.     </script>
  101. {% endblock %}
  102. {% block main %}
  103. <style>
  104.     .list_title {
  105.         font-size: 1.2em!important;
  106.         line-height: 1.5em;
  107.     }
  108.     .ec-layoutRole__mainBottom{
  109.         margin-top: 20px!important;
  110.     }
  111.     .campaign_img {
  112.         margin-bottom: 1em;
  113.     }
  114.     @media only screen and (min-width: 768px){
  115.         .campaign_img{
  116.             width: 80%;
  117.             margin: 0 auto 1em;
  118.         }
  119.     }
  120.     @media only screen and (max-width: 767px){
  121.         .campaign_img{
  122.             width: 100%;
  123.         }
  124.     }
  125. </style>
  126.     {%if campaign_valid == false and search_form.category_id.vars.value == "90" %}
  127.     <script type="text/javascript" id="list_script">
  128.         document.title = "全商品 / コスモピア・オンラインショップ";
  129.         document.getElementById("list_script").remove();
  130.     </script>
  131.     {% endif %}
  132.     {% if search_form.category_id.vars.errors|length > 0 or (campaign_valid == false and search_form.category_id.vars.value == campaign_category_id) %}
  133.         <div class="ec-searchnavRole">
  134.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  135.         </div>
  136.     {% else %}
  137.         <div class="ec-searchnavRole">
  138.             <form name="form1" id="form1" method="get" action="?">
  139.                 {% for item in search_form %}
  140.                     <input type="hidden" id="{{ item.vars.id }}"
  141.                            name="{{ item.vars.full_name }}"
  142.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  143.                 {% endfor %}
  144.             </form>
  145.             <div class="ec-searchnavRole__topicpath">
  146.                 <ol class="ec-topicpath">
  147.                     {% if Category is not null %}
  148.                         {% for Path in Category.path %}
  149.                             {% if loop.last %}
  150.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}">
  151.                                 <h1 class="list_title">
  152.                                     {% if campaign_valid == true and search_form.category_id.vars.value == campaign_category_id %}
  153.                                         <a href="{{ url('product_list') }}?category_id={{ Path.id }}">通巻100号記念 マガジン電子版バックナンバー半額セール</a>
  154.                                     {% else %}
  155.                                         <a href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  156.                                     {% endif %}
  157.                                 </h1>
  158.                             </li>
  159.                             {% endif %}
  160.                         {% endfor %}
  161.                     {% else %}
  162.                         <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a></li>
  163.                     {% endif %}
  164.                     {% if search_form.vars.value and search_form.vars.value.name %}
  165.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  166.                     {% endif %}
  167.                 </ol>
  168.                 {#
  169.                     キャンペーン用ヘッダー
  170.                 #}
  171.                 {% if campaign_valid == true and search_form.category_id.vars.value == campaign_category_id %}
  172.                     <div class="ec-topicpath__item" style="line-height:1.5em;font-size:1.4em;">
  173.                         <div class="campaign_img"><img src="/html/user_data/assets/img/sale_20210906/os_sale_no_detail.jpg" style="width:100%"></div>
  174.                         <p style="text-align: left;font-size: 0.8em;color: black;margin:0 1em;font-weight: normal;">
  175.                             多聴多読マガジン通巻100号を記念して、一部のバックナンバー電子版の半額セールを実施しております。<br>
  176.                             購入する商品に悩んだら、<a href="https://www.cosmopier.com/shopping-guide/?utm_source=cp_shop&utm_medium=magazine_sale&utm_content=sale_list" style="color:#337ab7!important;font-weight:bold;" target="_blank">お買い物ガイド</a>もご覧ください。<br>
  177.                             <span class="campaign_alert" style="font-weight: bold;color: red;">購入時、クーポンコード「{{coupon_code}}」を必ずご使用ください。<br/>
  178.                             また、本クーポンをご利用いただけるのは【お一人様1回のみ】です。
  179.                             </span><br/>
  180.                             <span class="copy_button" onclick="copyToClipboard()">★クーポンコードをコピー</span><br/>
  181.                             ※商品購入時のクーポンコード画面でペーストしてください。<br/>
  182.                         </p>
  183.                         <p style="text-align: left;font-size: 0.8em;margin: 1em 1em 0;font-weight: bold;">
  184.                             <span style="color: white;background-color: #000 !important;font-weight: normal;border-radius: 5px;padding:5px 10px;">セール実施期間:2021/9/6 ~ 2021/9/27</span>
  185.                         </p>
  186.                     </div>
  187.                 {% endif %}
  188.                 {#
  189.                     ページごとの固定バナー
  190.                 #}
  191.                 {% if search_form.category_id.vars.value == jytp_id %}
  192.                     <div class="ec-topicpath__item" style="line-height:1.5em;font-size:1.4em;">
  193.                         <div class="campaign_img"><img src="{{jytp_url}}" style="width:100%"></div>
  194.                         <p style="text-align: left;font-size: 0.8em;color: black;margin:0 1em;font-weight: normal;">
  195.                             ★表紙をクリックすると、立ち読み・CD試聴ができます!
  196.                         </p>
  197.                     </div>
  198.                 
  199.                 {% endif %}
  200.             </div>
  201.             
  202.             {{ include('Block/category_nav.twig') }}
  203.             
  204.             <div class="ec-searchnavRole__infos">
  205.                 <div class="ec-searchnavRole__counter">
  206.                     {% if pagination.totalItemCount > 0 %}
  207.                         {{ '<span>対象商品:</span><span class="ec-font-bold">%count%</span><span class="mini">件</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  208.                     {% else %}
  209.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  210.                     {% endif %}
  211.                 </div>
  212.                 {% if pagination.totalItemCount > 0 %}
  213.                     <div class="ec-searchnavRole__actions">
  214.                         <div class="ec-select">
  215.                             {{ form_widget(disp_number_form, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  216.                             {{ form_widget(order_by_form, {'id': '', 'attr': {'class': 'order-by'}}) }}
  217.                         </div>
  218.                     </div>
  219.                 {% endif %}
  220.             </div>
  221.         </div>
  222.         {% if pagination.totalItemCount > 0 %}
  223.             <div class="ec-shelfRole">
  224.                 <ul class="ec-shelfGrid">
  225.                     {% for Product in pagination %}
  226.                         <li class="ec-shelfGrid__item">
  227.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  228.                                 <p class="ec-shelfGrid__item-image">
  229.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}">
  230.                                 </p>
  231.                                 {# タグ #}
  232.                                 <ul class="ec-productRole__tags">
  233.                                     {% for Tag in Product.Tags %}
  234.                                         <li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  235.                                     {% endfor %}
  236.                                 </ul>
  237.                                 <p class="ttl">{{ Product.name }}</p>
  238.                                 {% if Product.description_list %}
  239.                                     <p class="subtext">{{ Product.description_list|raw|nl2br }}</p>
  240.                                 {% endif %}
  241.                                 <p class="price02-default">
  242.                                     {% if Product.hasProductClass %}
  243.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  244.                                             {{ Product.getPrice02IncTaxMin|price }}
  245.                                         {% else %}
  246.                                             {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  247.                                         {% endif %}
  248.                                     {% else %}
  249.                                         {{ Product.getPrice02IncTaxMin|price }}
  250.                                     {% endif %}<span>(税込)</span>
  251.                                 </p>
  252.                             </a>
  253.                             {% if Product.stock_find %}
  254.                                 {% set form = forms[Product.id] %}
  255.                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  256.                                     <div class="ec-productRole__actions">
  257.                                         {% if form.classcategory_id1 is defined %}
  258.                                             <div class="ec-select">
  259.                                                 {{ form_widget(form.classcategory_id1) }}
  260.                                                 {{ form_errors(form.classcategory_id1) }}
  261.                                             </div>
  262.                                             {% if form.classcategory_id2 is defined %}
  263.                                                 <div class="ec-select">
  264.                                                     {{ form_widget(form.classcategory_id2) }}
  265.                                                     {{ form_errors(form.classcategory_id2) }}
  266.                                                 </div>
  267.                                             {% endif %}
  268.                                         {% endif %}
  269.                                         <div class="ec-numberInput">
  270.                                             {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  271.                                             {{ form_errors(form.quantity) }}
  272.                                         </div>
  273.                                     </div>
  274.                                     {{ form_rest(form) }}
  275.                                 </form>
  276.                                 <div class="ec-productRole__btn">
  277.                                     <button type="submit" class="ec-blockBtn--cancel add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  278.                                         {{ 'カートに入れる'|trans }}
  279.                                     </button>
  280.                                 </div>
  281.                             {% else %}
  282.                                 <div class="ec-productRole__btn">
  283.                                     <button type="button" class="ec-blockBtn--action zero" disabled="disabled">
  284.                                         {{ '品切れ中です'|trans }}
  285.                                     </button>
  286.                                 </div>
  287.                             {% endif %}
  288.                         </li>
  289.                     {% endfor %}
  290.                 </ul>
  291.             </div>
  292.             <div class="ec-modal">
  293.                 <input type="checkbox" id="ec-modal-checkbox" class="checkbox">
  294.                 <div class="ec-modal-overlay">
  295.                     <label for="ec-modal-checkbox" class="ec-modal-overlay-close"></label>
  296.                     <div class="ec-modal-wrap">
  297.                         <label for="ec-modal-checkbox" class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></label>
  298.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  299.                         <div class="ec-modal-box">
  300.                             <div class="ec-role">
  301.                                 <label for="ec-modal-checkbox" class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</label>
  302.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  303.                             </div>
  304.                         </div>
  305.                     </div>
  306.                 </div>
  307.             </div>
  308.             <div class="ec-pagerRole">
  309.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  310.             </div>
  311.         {% endif %}
  312.     {% endif %}
  313. {% endblock %}