app/template/HF4002/Block/band_banner.twig line 1

Open in your IDE?
  1. {# セール実施用設定 #}
  2. {% set start_date = '2021-09-06'|date('Y-m-d') %}
  3. {% set end_date = '2021-09-27'|date('Y-m-d') %}
  4. {% set coupon_code = "eio100anniv" %}
  5. {% set sale_category_id = 90 %}
  6. {% if start_date <= date()|date('Y-m-d') and date()|date('Y-m-d') <= end_date %}
  7.     {% set campain_valid = true %}
  8. {% else %}
  9.     {% set campain_valid = false %}
  10. {% endif %}
  11. {# セール実施用設定 #}
  12. <p class="band_banner clearfix">
  13.     {% if campain_valid %}
  14.         <a href="{{ url('product_list') }}?category_id={{ sale_category_id }}"><span class="left">通巻100号記念マガジン電子版バックナンバー半額セール実施中!</span></a>
  15.         <span class="right" onclick="copyToClipboard()" id="coupon_code_data" value="{{coupon_code}}">クーポンコード「{{coupon_code}}」の入力をお忘れなく!!(お一人様1回のみ、2021/9/27まで)</span>
  16.     {% else %}
  17.         <a href="#">
  18.             <span class="left">2,200円(税込)以上のお買い物で送料無料!</span>
  19.             <span class="right">『多聴多読マガジン2021年8月号』発売しました!!</span>
  20.         </a>
  21.     {% endif %}
  22. </p>
  23. <style>
  24. /*調整用*/
  25. @media only screen and (max-width: 768px){
  26. .ec-headerRole .ec-headerTitle__title{padding-left:0 !important;}
  27. .ec-headerNavSP{top:5px;}
  28. .band_banner span.left {width: 53%;padding-left: 10%;}
  29. .band_banner span.right {width: 47%;}
  30. }
  31. @media only screen and (max-width: 768px){
  32. .band_banner span.left {width: 100%;}
  33. .band_banner span.right {text-align:center; width: 100%;}
  34. }
  35. .copy_button {
  36.     padding: 5px 10px;
  37.     border-radius: 5px;
  38.     background-color: #48382B;
  39.     color: white;
  40.     margin: 0.5em 0;
  41.     line-height: 3em;
  42.     cursor: pointer;
  43.     box-shadow: 1px 1px 2px black;
  44. }
  45. </style>
  46. <script>
  47.     function copyToClipboard() {
  48.         var copyText= "{{coupon_code}}";
  49.         navigator.clipboard.writeText(copyText).then(function(){
  50.             alert("クーポンコード「"+copyText+"」をコピーしました!\n商品購入時、クーポンコードの画面でこちらをペーストしてお使いください。");
  51.         },function(){
  52.             alert("申し訳ございませんが、お使いのブラウザでは対応しておりません。\n直接ページ上のテキストをコピーください。");
  53.         });
  54.     }
  55. </script>