custom/plugins/EnderecoShopware6ClientStore/src/Resources/views/storefront/layout/meta.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/layout/meta.html.twig' %}
  2. {% block layout_head_meta_tags %}
  3.   <script>
  4.     if (undefined === window.EnderecoIntegrator) {
  5.       window.EnderecoIntegrator = {};
  6.     }
  7.     if (!window.EnderecoIntegrator.onLoad) {
  8.       window.EnderecoIntegrator.onLoad = [];
  9.     }
  10.     window.EnderecoIntegrator.countryCodeToNameMapping = JSON.parse('{{ page.endereco_config.countryCodeToNameMapping|raw }}');
  11.     window.EnderecoIntegrator.countryMapping = JSON.parse('{{ page.endereco_config.countryMapping|raw }}');
  12.     window.EnderecoIntegrator.countryMappingReverse = JSON.parse('{{ page.endereco_config.countryMappingReverse|raw }}');
  13.     window.EnderecoIntegrator.subdivisionCodeToNameMapping = JSON.parse('{{ page.endereco_config.subdivisionCodeToNameMapping|raw }}');
  14.     window.EnderecoIntegrator.subdivisionMapping = JSON.parse('{{ page.endereco_config.subdivisionMapping|raw }}');
  15.     window.EnderecoIntegrator.subdivisionMappingReverse = JSON.parse('{{ page.endereco_config.subdivisionMappingReverse|raw }}');
  16.     function enderecoInitAMS(prefix, config, cb) {
  17.       if (undefined !== window.EnderecoIntegrator.initAMS) {
  18.         var EAO = window.EnderecoIntegrator.initAMS(prefix, config);
  19.         if (cb) {
  20.           cb(EAO);
  21.         }
  22.       } else {
  23.         window.EnderecoIntegrator.onLoad.push(function () {
  24.           var EAO = window.EnderecoIntegrator.initAMS(prefix, config);
  25.           if (cb) {
  26.             cb(EAO);
  27.           }
  28.         });
  29.       }
  30.     }
  31.     function enderecoInitES(prefix, config) {
  32.       if (undefined !== window.EnderecoIntegrator.initEmailServices) {
  33.         window.EnderecoIntegrator.initEmailServices(prefix, config);
  34.       } else {
  35.         window.EnderecoIntegrator.onLoad.push(function () {
  36.           window.EnderecoIntegrator.initEmailServices(prefix, config);
  37.         });
  38.       }
  39.     }
  40.     function enderecoInitPS(prefix, config) {
  41.       if (undefined !== window.EnderecoIntegrator.initEmailServices) {
  42.         window.EnderecoIntegrator.initPersonServices(prefix, config);
  43.       } else {
  44.         window.EnderecoIntegrator.onLoad.push(function () {
  45.           window.EnderecoIntegrator.initPersonServices(prefix, config);
  46.         });
  47.       }
  48.     }
  49.     function enderecoSetConfigValues() {
  50.       window.EnderecoIntegrator.themeName = '';
  51.       window.EnderecoIntegrator.defaultCountrySelect = !!('{{ page.endereco_config.defaultCountrySelect }}');
  52.       window.EnderecoIntegrator.defaultCountry = '{{ page.endereco_config.defaultCountry }}';
  53.       window.EnderecoIntegrator.config.agentName = '{{ page.endereco_config.enderecoAgentInfo }}';
  54.       window.EnderecoIntegrator.config.apiUrl = '{{ asset('bundles/enderecoshopware6clientstore/io.php') }}';
  55.       window.EnderecoIntegrator.config.apiKey = '{{ page.endereco_config.enderecoApiKey }}';
  56.       window.EnderecoIntegrator.config.showDebugInfo = false;
  57.       window.EnderecoIntegrator.config.remoteApiUrl = '{{ page.endereco_config.enderecoRemoteUrl }}';
  58.       window.EnderecoIntegrator.config.trigger.onblur = !!('{{ page.endereco_config.enderecoTriggerOnBlur }}');
  59.       window.EnderecoIntegrator.config.trigger.onsubmit = !!('{{ page.endereco_config.enderecoTriggerOnSubmit }}');
  60.       window.EnderecoIntegrator.config.ux.smartFill = false;
  61.       window.EnderecoIntegrator.config.ux.checkExisting = false;
  62.       window.EnderecoIntegrator.config.ux.resumeSubmit = !!('{{ page.endereco_config.enderecoContinueSubmit }}');
  63.       window.EnderecoIntegrator.config.ux.useStandardCss = true;
  64.       window.EnderecoIntegrator.config.ux.showEmailStatus = false;
  65.       window.EnderecoIntegrator.config.ux.allowCloseModal = !!('{{ page.endereco_config.enderecoAllowCloseIcon }}');
  66.       window.EnderecoIntegrator.config.ux.confirmWithCheckbox = !!('{{ page.endereco_config.enderecoConfirmWithCheckbox }}');
  67.       window.EnderecoIntegrator.config.ux.changeFieldsOrder = true;
  68.       window.EnderecoIntegrator.config.splitStreet = false;
  69.       window.EnderecoIntegrator.countryMappingUrl = '';
  70.       window.EnderecoIntegrator.config.templates.primaryButtonClasses = 'btn btn-primary btn-lg';
  71.       window.EnderecoIntegrator.config.templates.secondaryButtonClasses = 'btn btn-secondary btn-lg';
  72.       window.EnderecoIntegrator.config.texts = {
  73.         popUpHeadline: '{{ "enderecoshopware6clientstore.texts.popUpHeadline"|trans|sw_sanitize|escape }}',
  74.         popUpSubline: '{{ "enderecoshopware6clientstore.texts.popUpSubline"|trans|sw_sanitize|escape }}',
  75.         mistakeNoPredictionSubline: '{{ "enderecoshopware6clientstore.texts.mistakeNoPredictionSubline"|trans|sw_sanitize|escape }}',
  76.         confirmMyAddressCheckbox: '{{ "enderecoshopware6clientstore.texts.confirmMyAddressCheckbox"|trans|sw_sanitize|escape }}',
  77.         notFoundSubline: '{{ "enderecoshopware6clientstore.texts.notFoundSubline"|trans|sw_sanitize|escape }}',
  78.         yourInput: '{{ "enderecoshopware6clientstore.texts.yourInput"|trans|sw_sanitize|escape }}',
  79.         editYourInput: '{{ "enderecoshopware6clientstore.texts.editYourInput"|trans|sw_sanitize|escape }}',
  80.         ourSuggestions: '{{ "enderecoshopware6clientstore.texts.ourSuggestions"|trans|sw_sanitize|escape }}',
  81.         useSelected: '{{ "enderecoshopware6clientstore.texts.useSelected"|trans|sw_sanitize|escape }}',
  82.         confirmAddress: '{{ "enderecoshopware6clientstore.texts.confirmAddress"|trans|sw_sanitize|escape }}',
  83.         editAddress: '{{ "enderecoshopware6clientstore.texts.editAddress"|trans|sw_sanitize|escape }}',
  84.         warningText: '{{ "enderecoshopware6clientstore.texts.warningText"|trans|sw_sanitize|escape }}',
  85.         popupHeadlines: {
  86.           general_address: '{{ "enderecoshopware6clientstore.texts.general_address"|trans|sw_sanitize|escape }}',
  87.           billing_address: '{{ "enderecoshopware6clientstore.texts.billing_address"|trans|sw_sanitize|escape }}',
  88.           shipping_address: '{{ "enderecoshopware6clientstore.texts.shipping_address"|trans|sw_sanitize|escape }}',
  89.         },
  90.         statuses: {
  91.           email_not_correct: '{{ "enderecoshopware6clientstore.statuses.email_not_correct"|trans|sw_sanitize|escape }}',
  92.           email_cant_receive: '{{ "enderecoshopware6clientstore.statuses.email_cant_receive"|trans|sw_sanitize|escape }}',
  93.           email_syntax_error: '{{ "enderecoshopware6clientstore.statuses.email_syntax_error"|trans|sw_sanitize|escape }}',
  94.           email_no_mx: '{{ "enderecoshopware6clientstore.statuses.email_no_mx"|trans|sw_sanitize|escape }}',
  95.           building_number_is_missing: '{{ "enderecoshopware6clientstore.statuses.building_number_is_missing"|trans|sw_sanitize|escape }}',
  96.           building_number_not_found: '{{ "enderecoshopware6clientstore.statuses.building_number_not_found"|trans|sw_sanitize|escape }}',
  97.           street_name_needs_correction: '{{ "enderecoshopware6clientstore.statuses.street_name_needs_correction"|trans|sw_sanitize|escape }}',
  98.           locality_needs_correction: '{{ "enderecoshopware6clientstore.statuses.locality_needs_correction"|trans|sw_sanitize|escape }}',
  99.           postal_code_needs_correction: '{{ "enderecoshopware6clientstore.statuses.postal_code_needs_correction"|trans|sw_sanitize|escape }}',
  100.           country_code_needs_correction: '{{ "enderecoshopware6clientstore.statuses.country_code_needs_correction"|trans|sw_sanitize|escape }}',
  101.         }
  102.       };
  103.       window.EnderecoIntegrator.activeServices = {
  104.         ams: true,
  105.         emailService: false,
  106.         personService: false
  107.       }
  108.       // Execute all function that have been called throughout the page.
  109.       window.EnderecoIntegrator.onLoad.forEach(function (callback) {
  110.         callback();
  111.       });
  112.       window.EnderecoIntegrator.ready = true;
  113.       (function() {
  114.         window.EnderecoIntegrator.$formScanner = {
  115.           loop: null,
  116.           start: function() {
  117.             this.loop = setInterval( function() {
  118.               document.querySelectorAll('[name="endereco_data_marker"][data-has-object="no"]').forEach( function(MarkerElement) {
  119.                 var formElement = MarkerElement.closest('form');
  120.                 var formId = '';
  121.                 if (formElement.getAttribute('data-endereco-ams-form-id')) {
  122.                   formId = formElement.getAttribute('data-endereco-ams-form-id');
  123.                 } else {
  124.                   formId = (Math.floor(Math.random() * 100) * Date.now()).toString(16);
  125.                   formElement.setAttribute('data-endereco-ams-form-id', formId);
  126.                 }
  127.                 if ('ams' === MarkerElement.value) {
  128.                   var prefix = MarkerElement.getAttribute('data-used-prefix');
  129.                   var countryCodeSelector = MarkerElement.getAttribute('data-country-code-selector');
  130.                   var postalCodeSelector = MarkerElement.getAttribute('data-postal-code-selector');
  131.                   var localitySelector = MarkerElement.getAttribute('data-locality-selector');
  132.                   var streetFullSelector = MarkerElement.getAttribute('data-street-full-selector');
  133.                   var subdivisionCodeSelector = MarkerElement.getAttribute('data-subdivision-code-selector');
  134.                   var isAjax = false;
  135.                   var EAO = window.EnderecoIntegrator.initAMS(
  136.                           {
  137.                             countryCode: `[data-endereco-ams-form-id="${formId}"] [name="${countryCodeSelector}"]`,
  138.                             subdivisionCode:  `[data-endereco-ams-form-id="${formId}"] [name="${subdivisionCodeSelector}"]`,
  139.                             postalCode: `[data-endereco-ams-form-id="${formId}"] [name="${postalCodeSelector}"]`,
  140.                             locality: `[data-endereco-ams-form-id="${formId}"] [name="${localitySelector}"]`,
  141.                             streetFull: `[data-endereco-ams-form-id="${formId}"] [name="${streetFullSelector}"]`,
  142.                           }, {
  143.                             name: `ams_${prefix}_${formId}`,
  144.                             addressType: 'general_address'
  145.                           }
  146.                   );
  147.                   // If ajax, add click listener.
  148.                   isAjax = 'true' === formElement.getAttribute('data-form-ajax-submit');
  149.                   if (isAjax) {
  150.                     formElement.querySelector('[type="submit"]').addEventListener('click', function(e) {
  151.                       if (EAO.util.shouldBeChecked()) {
  152.                         e.preventDefault();
  153.                         // Resume click after ac is done.
  154.                         window.EnderecoIntegrator.submitResume = function() {
  155.                           EAO.waitUntilReady().then( function() {
  156.                             if(e.target.dispatchEvent(
  157.                                     new EAO.util.CustomEvent(
  158.                                             'click',
  159.                                             {
  160.                                               'bubbles': true,
  161.                                               'cancelable': true
  162.                                             }
  163.                                     )
  164.                             )) {
  165.                               e.target.click();
  166.                             }
  167.                           }).catch();
  168.                         }
  169.                         EAO.util.checkAddress().then().catch(function() {
  170.                           EAO.waitUntilReady().then( function() {
  171.                             if(e.target.dispatchEvent(
  172.                                     new EAO.util.CustomEvent(
  173.                                             'click',
  174.                                             {
  175.                                               'bubbles': true,
  176.                                               'cancelable': true
  177.                                             }
  178.                                     )
  179.                             )) {
  180.                               e.target.click();
  181.                             }
  182.                           }).catch();
  183.                         });
  184.                         return false;
  185.                       }
  186.                     });
  187.                   }
  188.                 }
  189.                 MarkerElement.setAttribute('data-has-object', 'yes');
  190.               });
  191.             }, 1);
  192.           },
  193.           stop: function() {
  194.           }
  195.         }
  196.         window.EnderecoIntegrator.$formScanner.start();
  197.       })();
  198.     }
  199.     function enderecoLoadAMSConfig() {
  200.       var $interval = setInterval( function() {
  201.         if (!!window.EnderecoIntegrator.config) {
  202.           enderecoSetConfigValues();
  203.           clearInterval($interval);
  204.         }
  205.       }, 1);
  206.     }
  207.   </script>
  208.   {{ parent() }}
  209. {% endblock %}