custom/plugins/MaxiaTaxSwitch6/src/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.     {% block base_script_maxia_tax_switch %}
  4.         {% set maxiaTaxSwitch = context.extensions.maxiaTaxSwitch %}
  5.         {%- if maxiaTaxSwitch is defined -%}
  6.             {%- if maxiaTaxSwitchConfig is not defined -%}
  7.                 {% set maxiaTaxSwitchConfig = {
  8.                     'preselectAccountType': maxiaTaxSwitch.preselectAccountType,
  9.                     'showPopup': maxiaTaxSwitch.showPopup,
  10.                     'popupTestMode': maxiaTaxSwitch.popupTestMode,
  11.                     'isNet': maxiaTaxSwitch.isNet,
  12.                     'showOverlay': maxiaTaxSwitch.showOverlay,
  13.                     'cookieRequired': maxiaTaxSwitch.cookieRequired,
  14.                     'cookieExpirationDays': maxiaTaxSwitch.cookieExpirationDays,
  15.                     'updateSettingUrl': path('frontend.plugins.maxia-tax-switch.update'),
  16.                     'urlParameterName': maxiaTaxSwitch.urlParameterName,
  17.                 } -%}
  18.                 {% if maxiaTaxSwitch.showPopup -%}
  19.                     {% set maxiaTaxSwitchConfig = maxiaTaxSwitchConfig|merge({
  20.                         'popupUrl': path('frontend.plugins.maxia-tax-switch.popup')
  21.                     }) %}
  22.                 {% endif %}
  23.             {%- endif -%}
  24.             <script>
  25.                 {%- block base_script_maxia_tax_switch_inline -%}
  26.                     window.maxiaTaxSwitch = {{ maxiaTaxSwitchConfig|json_encode|raw }};
  27.                 {%- endblock -%}
  28.             </script>
  29.         {% endif -%}
  30.     {% endblock %}
  31.     {{ parent() }}
  32. {% endblock %}
  33. {# Doofinder support: Override prices by net state #}
  34. {% block base_body_script %}
  35.     {{ parent() }}
  36.     {% set maxiaTaxSwitch = context.extensions.maxiaTaxSwitch %}
  37.     {% if maxiaTaxSwitch is defined and maxiaTaxSwitch.activateDoofinder
  38.         and config('IntediaDoofinderSW6.config.doofinderEnabled') %}
  39.         <script>
  40.             dfClassicLayers = dfClassicLayers || {};
  41.             dfClassicLayers.push({
  42.                 callbacks: {
  43.                     loaded: function(instance) {
  44.                         var controller = instance.layer.controller;
  45.                         var netState = (window.maxiaTaxSwitch.isNet ? '_net' : '');
  46.                         var userGroup = '_{{ context.currentCustomerGroup.id }}';
  47.                         var userGroupWithNetState = userGroup + netState;
  48.                         controller.processors.push(function(response) {
  49.                             response.results = response.results.map(function(result) {
  50.                                 if (result['price' + userGroupWithNetState !== undefined]) {
  51.                                     result.price = result['price' + userGroupWithNetState];
  52.                                     result.sale_price = result['sale_price' + userGroupWithNetState];
  53.                                 } else if (result['price' + userGroup !== undefined]) {
  54.                                     result.price = result['price' + userGroup];
  55.                                     result.sale_price = result['sale_price' + userGroup];
  56.                                 } else if (result['price' + netState] !== undefined) {
  57.                                     result.price = result['price' + netState];
  58.                                     result.sale_price = result['sale_price' + netState];
  59.                                 }
  60.                             });
  61.                             return response;
  62.                         });
  63.                     }
  64.                 }
  65.             });
  66.         </script>
  67.     {% endif %}
  68. {% endblock %}