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