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

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/base.html.twig' %}
  2. {% block base_script_hmr_mode %}
  3.     {{ parent() }}
  4.     {% if controllerName|lower!='checkout' %}
  5.         {% if app.request.cookies.get('dmits-bruttonetto-cookie-value') %}
  6.             {{ app.session.set('dmits-bruttonetto-selectedPriceState', app.request.cookies.get('dmits-bruttonetto-cookie-value')) }}
  7.         {% elseif app.request.get('showprice') %}
  8.             {{ app.session.set('dmits-bruttonetto-selectedPriceState', app.request.get('showprice')) }}
  9.         {% endif %}
  10.          <script>
  11.   
  12.          var selectedValue="";
  13.          var shopValue="{{context.taxState}}";
  14.  
  15.          var taxTextGross=  "{{"general.grossTaxInformation"|trans|sw_sanitize}}";
  16.          var taxTextNet=  "{{"general.netTaxInformation"|trans|sw_sanitize}}";
  17.  
  18.          var taxTextFooterGross='{{ "footer.includeVat"|trans({'%url%': path('frontend.cms.page',{ id: config('core.basicInformation.shippingPaymentInfoPage') })})|raw }}';
  19.          var taxTextFooterNet='{{ "footer.excludeVat"|trans({'%url%': path('frontend.cms.page',{ id: config('core.basicInformation.shippingPaymentInfoPage') })})|raw }}';
  20.          var numberTemplate="{{100000.00|currency}}";
  21.          
  22.          
  23.           function getCookie(name) {
  24.             const value = `; ${document.cookie}`;
  25.             const parts = value.split(`; ${name}=`);
  26.             if (parts.length === 2) return parts.pop().split(';').shift();
  27.           }
  28.             window.onload = function () {
  29.                 
  30.                 {% if app.request.cookies.get('dmits-bruttonetto-cookie-value') %}
  31.                      selectedValue="{{app.request.cookies.get('dmits-bruttonetto-cookie-value')}}";
  32.                      var d_cookie="";
  33.                 {% elseif app.request.get('showprice') %}
  34.                      selectedValue="{{app.request.get('showprice')}}";
  35.                      var d_get="";
  36.                 {%  else %}
  37.                      selectedValue="{{app.session.get('dmits-bruttonetto-selectedPriceState')}}";
  38.                      var d_session="";
  39.                 {% endif %}
  40.                 const urlParams = new URLSearchParams(window.location.search);
  41.                 if(getCookie("dmits-bruttonetto-cookie-value")){
  42.                      selectedValue=getCookie("dmits-bruttonetto-cookie-value");
  43.                  }else if(urlParams.get('showprice')){
  44.                      selectedValue=urlParams.get('showprice');
  45.                 }
  46.                 {% if not app.request.cookies.get('dmits-bruttonetto-cookie-popup') %}
  47.                     {% if (not app.request.cookies.get('cookie-preference')) and (not app.session.get('dmits-bruttonetto-selectedPriceState'))%}
  48.                         {%if (not config('DmitsBruttoNetto.config.popupnotbot'))  or ((config('DmitsBruttoNetto.config.popupnotbot')) and ("bot" not in app.request.headers.get('User-Agent')|lower)) %}
  49.                             if(typeof selectedValue === "undefined" || selectedValue===null || selectedValue==''){
  50.                                 if(!getCookie("dmits-bruttonetto-cookie-popup") && !getCookie("cookie-preference")){
  51.                                     $("#dmitsbruttonetto").modal();
  52.                                 }
  53.                             }
  54.                         {%  endif %}
  55.                     {% endif %}
  56.                 {% endif %}
  57.                 
  58.                 if(selectedValue==shopValue){
  59.                 }else if(selectedValue=="net" || ((typeof selectedValue === "undefined" || selectedValue===null || selectedValue=='') && shopValue=="net")){
  60.                     $(".product-detail-tax-link").text(taxTextNet);
  61.                     $(".product-detail-tax-link").prop('title',taxTextNet);
  62.                     $(".footer-vat p").html(taxTextFooterNet);
  63.                 }else{
  64.                     $(".product-detail-tax-link").text(taxTextGross);
  65.                     $(".product-detail-tax-link").prop('title',taxTextGross);
  66.                     $(".footer-vat p").html(taxTextFooterGross);
  67.                 }
  68.                 if(selectedValue=='gross'){
  69.                     
  70.                     $('.change-bruttonetto option').removeAttr("selected");
  71.                     $('.change-bruttonetto option[value="gross"]').attr('selected', 'selected');
  72.                     $('.change-bruttonetto').val("gross").change();
  73.                     $( ".change-bruttonetto" ).first().attr("data-dmitsbruttonetto","gross");
  74.                     
  75.                 }else if(selectedValue=='net'){
  76.                     $('.change-bruttonetto option').removeAttr("selected");
  77.                     $('.change-bruttonetto option[value="net"]').attr('selected', 'selected');
  78.                     $('.change-bruttonetto').val("net").change();
  79.                     $( ".change-bruttonetto" ).first().attr("data-dmitsbruttonetto","net");
  80.                     
  81.                 }
  82.             }
  83.             </script>
  84.         {{ app.session.set('dmits-bruttonetto-page', "") }}
  85.     {% else %}
  86.         {{ app.session.set('dmits-bruttonetto-page', "checkout") }}
  87.     {% endif %}
  88. {% endblock %}