custom/apps/DmitsShippingCountdown/Resources/views/storefront/base.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/base.html.twig' %}
  2. {% block base_header %}
  3.     {% if config('DmitsShippingCountdown.config.active')  and config('DmitsShippingCountdown.config.showheader') %}
  4.         {% sw_include "@Storefront/storefront/shippingholiday.html.twig" with { 'DmitsShippingCountdownBlock': 'header'} %}
  5.     {% endif %}
  6.     {{ parent() }} 
  7. {% endblock %}
  8. {% block base_script_hmr_mode %}
  9.    
  10.     {% if config('DmitsShippingCountdown.config.active') %}
  11.          <script>
  12.              {% set holidays=[] %}
  13.             {% set holiday_german=["01.01.2021","02.04.2021","04.04.2021","05.04.2021","01.05.2021","13.05.2021","23.05.2021","24.05.2021","03.10.2021","25.12.2021","26.12.2021",
  14.         "01.01.2022","15.04.2022","17.04.2022","18.04.2022","01.05.2022","26.05.2022","05.06.2022","06.06.2022","03.10.2022","25.12.2022","26.12.2022",
  15.         "01.01.2023","07.04.2023","09.04.2023","10.04.2023","01.05.2023","18.05.2023","28.05.2023","29.05.2023","03.10.2023","25.12.2023","26.12.2023",
  16.         "01.01.2024","29.03.2024","30.03.2024","01.04.2024","01.05.2024","09.05.2024","19.05.2024","20.05.2024","03.10.2024","25.12.2024","26.12.2024",
  17.         "01.01.2025","18.04.2025","20.04.2025","21.04.2025","01.05.2025","29.05.2025","08.06.2025","09.06.2025","03.10.2025","25.12.2025","26.12.2025"] %}
  18.             {% set holidaythreekings=["06.01.2021","06.01.2022","06.01.2023","06.01.2024","06.01.2025"]%}
  19.     
  20.             {% set holidaycorpuschristi=["03.06.2021","16.06.2022","08.06.2023","30.05.2024","19.06.2025"]%}
  21.     
  22.             {% set holidayassumptionday=["15.08.2021","15.08.2022","15.08.2023","15.08.2024","15.08.2025",]%}
  23.             
  24.             {% set holidayreformation=["31.10.2021","31.10.2022","31.10.2023","31.10.2024","31.10.2025"]%}
  25.             
  26.             {% set holidayallsaints=["01.11.2021","01.11.2022","01.11.2023","01.11.2024","01.11.2025"]%}
  27.             
  28.             {% set holidayprayerrepentance=["17.11.2021","16.11.2022","15.11.2023","20.11.2024","19.11.2025",]%}
  29.     
  30.             {%  if config('DmitsShippingCountdown.config.holidaygerman') %}
  31.                  {% set holidays=holidays|merge(holiday_german) %}
  32.             {% endif %}
  33.     
  34.             {%  if config('DmitsShippingCountdown.config.holidaythreekings') %}
  35.                  {% set holidays=holidays|merge(holidaythreekings) %}
  36.             {% endif %}
  37.     
  38.             {%  if config('DmitsShippingCountdown.config.holidaycorpuschristi') %}
  39.                 {% set holidays=holidays|merge(holidaycorpuschristi) %}
  40.             {% endif %}
  41.             
  42.             {%  if config('DmitsShippingCountdown.config.holidayassumptionday') %}
  43.                    {% set holidays=holidays|merge(holidayassumptionday) %}
  44.             {% endif %}
  45.         
  46.             {%  if config('DmitsShippingCountdown.config.holidayreformation') %}
  47.                 {% set holidays=holidays|merge(holidayreformation) %}
  48.             {% endif %}
  49.         
  50.             {%  if config('DmitsShippingCountdown.config.holidayallsaints') %}
  51.                 {% set holidays=holidays|merge(holidayallsaints) %}
  52.             {% endif %}
  53.             
  54.         
  55.             {%  if config('DmitsShippingCountdown.config.holidayprayerrepentance') %}
  56.                 {% set holidays=holidays|merge(holidayprayerrepentance) %}
  57.             {% endif %}
  58.             {%  if config('DmitsShippingCountdown.config.holidaymoredays') %}
  59.                 {% set holidays=holidays|merge((config('DmitsShippingCountdown.config.holidaymoredays')|split(";"))) %}
  60.             {% endif %}
  61.             var shippingtext= "{{"dmits.shippingcountdown.custom.shippingtext"|trans|replace({"\n": "<br>", "\r": "<br>", "\t": "<br>"})|raw }}";
  62.             var dmitsOnlyhours=1;
  63.             
  64.             {% if config('DmitsShippingCountdown.config.onlyhours') %}
  65.                 dmitsOnlyhours=0;
  66.             {% endif %}
  67.             
  68.             function getShippingCountdownValue(){
  69.                 {% set currentday=0 %}
  70.                 {% set shipdayToday=0 %}
  71.                 {% set shipday=0 %}
  72.                 {% set shipTime=0 %}
  73.                 {% set days=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] %}
  74.                 {% set runLoop= true %}
  75.                 {%  for key, day in days %}
  76.                     {% if  runLoop%}
  77.                         {%  if day|lower in (config('DmitsShippingCountdown.config.ordernoshipping')) %}
  78.     
  79.                         {% endif %}
  80.                         {%  if  now|date("l") ==day %}
  81.     
  82.     
  83.                         {% if  now|date("d.m.Y") in holidays%}
  84.     
  85.                         {% else %}
  86.                         
  87.                                 {% if config('DmitsShippingCountdown.config.dailyconfig')%}
  88.                                      {% set shipTime=config('DmitsShippingCountdown.config.ordertill'~day|lower)|date('H:i') %}
  89.                                      {% set runLoop= false %}
  90.                                  {% else  %}
  91.                                      {%  if day|lower not in (config('DmitsShippingCountdown.config.ordernoshipping')) %}
  92.                                         {% if  config('DmitsShippingCountdown.config.ordertillwe') and (day=="Saturday" or day=="Sunday")%}
  93.                                             {% set shipTime=config('DmitsShippingCountdown.config.ordertillwe')|date('H:i') %}
  94.                                         {% else %}
  95.                                             {% set shipTime=config('DmitsShippingCountdown.config.ordertill')|date('H:i') %}
  96.                                         {% endif %}
  97.                                         {% set runLoop= false %}
  98.                                     {% endif %}
  99.                                 {%  endif%}  
  100.                                      
  101.                              {% if config('DmitsShippingCountdown.config.showdayname')%}
  102.                             
  103.                                  {% set shipdayToday=("dmits.shippingcountdown.custom."~day|lower)|trans %}
  104.                              {% else %}
  105.                                  {% set shipdayToday=("dmits.shippingcountdown.custom.today")|trans %}
  106.                              {% endif %}
  107.                             {% set currentday=key %}
  108.                         {%  endif%} 
  109.                           {% endif %}
  110.         
  111.                       {% endif %}
  112.                 {% endfor %}
  113.                 {%  if  shipTime>now|date('H:i')%}
  114.                     {% set shipday=shipdayToday %}
  115.                     {% set nextDayTime=shipTime %}
  116.                 {% else %}
  117.                  
  118.                     {% set nextDayTime=0%}
  119.                     {%  if currentday==6 %}
  120.                         {% set nextDayArray=days|slice(0,7) %}
  121.                     {%  elseif currentday==0 %}
  122.                         {% set nextDayArray=days|slice(1,7)|merge(days|slice(0,1)) %}
  123.                     {% else %}
  124.                         {% set nextDayArray=days|slice((currentday+1),7)|merge(days|slice(0,(currentday+1))) %}
  125.                     {% endif %}
  126.     
  127.                     {% set runLoop= true %}
  128.                     {% set nextDayloop=1 %}
  129.                     {%  for key, day in nextDayArray %}
  130.                         {% if  runLoop%}
  131.                         {% set nextday=(now|date('U')+(60*60*24*nextDayloop))|date("d.m.Y") %}
  132.                         
  133.                         {% if  nextday in holidays%}
  134.                         
  135.                         {% else %}        
  136.                                 {%  if config('DmitsShippingCountdown.config.ordertill'~day|lower) or not config('DmitsShippingCountdown.config.dailyconfig') %}
  137.                              {% if config('DmitsShippingCountdown.config.showdayname') or nextDayloop>1%}
  138.                                      {% set shipday=("dmits.shippingcountdown.custom."~day|lower)|trans %}
  139.                                  {% else %}
  140.                                      {% set shipday=("dmits.shippingcountdown.custom.tomorrow")|trans %}
  141.                                  {% endif %}
  142.                             
  143.                                     {% if config('DmitsShippingCountdown.config.dailyconfig')%}
  144.                                         {% set nextDayTime=nextday~" "~config('DmitsShippingCountdown.config.ordertill'~day|lower)|date('H:i')%}
  145.     
  146.                                           {% set runLoop= false %}
  147.                                     {% else %}
  148.                                         {%  if day|lower not in (config('DmitsShippingCountdown.config.ordernoshipping')) %}
  149.                                             {% if  config('DmitsShippingCountdown.config.ordertillwe') and (day=="Saturday" or day=="Sunday")%}
  150.                                                 {% set nextDayTime=nextday~" "~config('DmitsShippingCountdown.config.ordertillwe')|date('H:i')%}
  151.                                                 {% set runLoop= false %}
  152.                                             {% elseif config('DmitsShippingCountdown.config.ordertill') %}
  153.                                                 {% set nextDayTime=nextday~" "~config('DmitsShippingCountdown.config.ordertill')|date('H:i')%}
  154.                                                 {% set runLoop= false %}
  155.                                             {% endif %}
  156.                                             
  157.                                         {% endif %}
  158.                                     {% endif %}
  159.                                    
  160.                                     {% endif %}
  161.                         
  162.                             {% endif %}
  163.                         
  164.                         {% endif %}
  165.                         {% set nextDayloop=nextDayloop+1 %}
  166.                         {% if (config('DmitsShippingCountdown.config.maximumdays'))<nextDayloop%}
  167.                             {% set runLoop= false %}
  168.                         {% endif %}
  169.                     {% endfor %}
  170.                 {% endif %}
  171.                 
  172.                 var shiptoday="{{shipdayToday}}";
  173.                 var shipday="{{shipday}}";
  174.                 var livecountdown=0;
  175.                 {% if config('DmitsShippingCountdown.config.livecountdown')%}
  176.                 livecountdown=1;
  177.                 {% endif %}
  178.                 var shipTime="{{shipTime|date('U',"UTC")}}";
  179.                 var nextDayTime="{{nextDayTime|date('U',"UTC")}}";
  180.                 var timestampnextday="{{nextDayTime|date('U',"UTC")-now|date('U')}}";
  181.                 return {"timestamp":"{{shipTime|date('U')-now|date('U')}}",
  182.                     "timestampnextday":timestampnextday,
  183.                     "shipday":shipday,
  184.                     "livecountdown":livecountdown,
  185.                     "shipTime":shipTime,
  186.                     "nextDayTime":nextDayTime,
  187.                     "timestampnextday":timestampnextday
  188.                     };
  189.            }  
  190.       </script>
  191.     {% endif %}
  192.     {{ parent() }}
  193. {% endblock %}