{% sw_extends '@Storefront/storefront/base.html.twig' %}
{% block base_script_hmr_mode %}
{{ parent() }}
{% if controllerName|lower!='checkout' %}
{% if app.request.cookies.get('dmits-bruttonetto-cookie-value') %}
{{ app.session.set('dmits-bruttonetto-selectedPriceState', app.request.cookies.get('dmits-bruttonetto-cookie-value')) }}
{% elseif app.request.get('showprice') %}
{{ app.session.set('dmits-bruttonetto-selectedPriceState', app.request.get('showprice')) }}
{% endif %}
<script>
var selectedValue="";
var shopValue="{{context.taxState}}";
var taxTextGross= "{{"general.grossTaxInformation"|trans|sw_sanitize}}";
var taxTextNet= "{{"general.netTaxInformation"|trans|sw_sanitize}}";
var taxTextFooterGross='{{ "footer.includeVat"|trans({'%url%': path('frontend.cms.page',{ id: config('core.basicInformation.shippingPaymentInfoPage') })})|raw }}';
var taxTextFooterNet='{{ "footer.excludeVat"|trans({'%url%': path('frontend.cms.page',{ id: config('core.basicInformation.shippingPaymentInfoPage') })})|raw }}';
var numberTemplate="{{100000.00|currency}}";
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
window.onload = function () {
{% if app.request.cookies.get('dmits-bruttonetto-cookie-value') %}
selectedValue="{{app.request.cookies.get('dmits-bruttonetto-cookie-value')}}";
var d_cookie="";
{% elseif app.request.get('showprice') %}
selectedValue="{{app.request.get('showprice')}}";
var d_get="";
{% else %}
selectedValue="{{app.session.get('dmits-bruttonetto-selectedPriceState')}}";
var d_session="";
{% endif %}
const urlParams = new URLSearchParams(window.location.search);
if(getCookie("dmits-bruttonetto-cookie-value")){
selectedValue=getCookie("dmits-bruttonetto-cookie-value");
}else if(urlParams.get('showprice')){
selectedValue=urlParams.get('showprice');
}
{% if not app.request.cookies.get('dmits-bruttonetto-cookie-popup') %}
{% if (not app.request.cookies.get('cookie-preference')) and (not app.session.get('dmits-bruttonetto-selectedPriceState'))%}
{%if (not config('DmitsBruttoNetto.config.popupnotbot')) or ((config('DmitsBruttoNetto.config.popupnotbot')) and ("bot" not in app.request.headers.get('User-Agent')|lower)) %}
if(typeof selectedValue === "undefined" || selectedValue===null || selectedValue==''){
if(!getCookie("dmits-bruttonetto-cookie-popup") && !getCookie("cookie-preference")){
$("#dmitsbruttonetto").modal();
}
}
{% endif %}
{% endif %}
{% endif %}
if(selectedValue==shopValue){
}else if(selectedValue=="net" || ((typeof selectedValue === "undefined" || selectedValue===null || selectedValue=='') && shopValue=="net")){
$(".product-detail-tax-link").text(taxTextNet);
$(".product-detail-tax-link").prop('title',taxTextNet);
$(".footer-vat p").html(taxTextFooterNet);
}else{
$(".product-detail-tax-link").text(taxTextGross);
$(".product-detail-tax-link").prop('title',taxTextGross);
$(".footer-vat p").html(taxTextFooterGross);
}
if(selectedValue=='gross'){
$('.change-bruttonetto option').removeAttr("selected");
$('.change-bruttonetto option[value="gross"]').attr('selected', 'selected');
$('.change-bruttonetto').val("gross").change();
$( ".change-bruttonetto" ).first().attr("data-dmitsbruttonetto","gross");
}else if(selectedValue=='net'){
$('.change-bruttonetto option').removeAttr("selected");
$('.change-bruttonetto option[value="net"]').attr('selected', 'selected');
$('.change-bruttonetto').val("net").change();
$( ".change-bruttonetto" ).first().attr("data-dmitsbruttonetto","net");
}
}
</script>
{{ app.session.set('dmits-bruttonetto-page', "") }}
{% else %}
{{ app.session.set('dmits-bruttonetto-page', "checkout") }}
{% endif %}
{% endblock %}