{% sw_extends '@Storefront/storefront/base.html.twig' %}
{% block base_script_hmr_mode %}
{% block base_script_maxia_tax_switch %}
{% set maxiaTaxSwitch = context.extensions.maxiaTaxSwitch %}
{%- if maxiaTaxSwitch is defined -%}
{%- if maxiaTaxSwitchConfig is not defined -%}
{% set maxiaTaxSwitchConfig = {
'preselectAccountType': maxiaTaxSwitch.preselectAccountType,
'showPopup': maxiaTaxSwitch.showPopup,
'popupTestMode': maxiaTaxSwitch.popupTestMode,
'isNet': maxiaTaxSwitch.isNet,
'showOverlay': maxiaTaxSwitch.showOverlay,
'cookieRequired': maxiaTaxSwitch.cookieRequired,
'cookieExpirationDays': maxiaTaxSwitch.cookieExpirationDays,
'updateSettingUrl': path('frontend.plugins.maxia-tax-switch.update'),
'urlParameterName': maxiaTaxSwitch.urlParameterName,
'urlParameterHideModal': maxiaTaxSwitch.urlParameterHideModal,
} -%}
{% if maxiaTaxSwitch.showPopup -%}
{% set maxiaTaxSwitchConfig = maxiaTaxSwitchConfig|merge({
'popupUrl': path('frontend.plugins.maxia-tax-switch.popup')
}) %}
{% endif %}
{%- endif -%}
{%- block base_script_maxia_tax_switch_inline -%}
<script>
window.maxiaTaxSwitch = {{ maxiaTaxSwitchConfig|json_encode|raw }};
</script>
{%- endblock -%}
{% endif -%}
{% endblock %}
{{ parent() }}
{% endblock %}
{# Doofinder support: Override prices by net state #}
{% block base_body_script %}
{{ parent() }}
{% set maxiaTaxSwitch = context.extensions.maxiaTaxSwitch %}
{% if maxiaTaxSwitch is defined and maxiaTaxSwitch.activateDoofinder
and config('IntediaDoofinderSW6.config.doofinderEnabled') %}
<script>
dfClassicLayers = dfClassicLayers || {};
dfClassicLayers.push({
callbacks: {
loaded: function(instance) {
var controller = instance.layer.controller;
var netState = (window.maxiaTaxSwitch.isNet ? '_net' : '');
var userGroup = '_{{ context.currentCustomerGroup.id }}';
var userGroupWithNetState = userGroup + netState;
controller.processors.push(function(response) {
response.results = response.results.map(function(result) {
if (result['price' + userGroupWithNetState !== undefined]) {
result.price = result['price' + userGroupWithNetState];
result.sale_price = result['sale_price' + userGroupWithNetState];
} else if (result['price' + userGroup !== undefined]) {
result.price = result['price' + userGroup];
result.sale_price = result['sale_price' + userGroup];
} else if (result['price' + netState] !== undefined) {
result.price = result['price' + netState];
result.sale_price = result['sale_price' + netState];
}
});
return response;
});
}
}
});
</script>
{% endif %}
{% endblock %}