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