{% sw_extends '@Storefront/storefront/layout/meta.html.twig' %}
{% block layout_head_meta_tags %}
<script>
if (undefined === window.EnderecoIntegrator) {
window.EnderecoIntegrator = {};
}
if (!window.EnderecoIntegrator.onLoad) {
window.EnderecoIntegrator.onLoad = [];
}
window.EnderecoIntegrator.countryCodeToNameMapping = JSON.parse('{{ page.endereco_config.countryCodeToNameMapping|raw }}');
window.EnderecoIntegrator.countryMapping = JSON.parse('{{ page.endereco_config.countryMapping|raw }}');
window.EnderecoIntegrator.countryMappingReverse = JSON.parse('{{ page.endereco_config.countryMappingReverse|raw }}');
window.EnderecoIntegrator.subdivisionCodeToNameMapping = JSON.parse('{{ page.endereco_config.subdivisionCodeToNameMapping|raw }}');
window.EnderecoIntegrator.subdivisionMapping = JSON.parse('{{ page.endereco_config.subdivisionMapping|raw }}');
window.EnderecoIntegrator.subdivisionMappingReverse = JSON.parse('{{ page.endereco_config.subdivisionMappingReverse|raw }}');
function enderecoInitAMS(prefix, config, cb) {
if (undefined !== window.EnderecoIntegrator.initAMS) {
var EAO = window.EnderecoIntegrator.initAMS(prefix, config);
if (cb) {
cb(EAO);
}
} else {
window.EnderecoIntegrator.onLoad.push(function () {
var EAO = window.EnderecoIntegrator.initAMS(prefix, config);
if (cb) {
cb(EAO);
}
});
}
}
function enderecoInitES(prefix, config) {
if (undefined !== window.EnderecoIntegrator.initEmailServices) {
window.EnderecoIntegrator.initEmailServices(prefix, config);
} else {
window.EnderecoIntegrator.onLoad.push(function () {
window.EnderecoIntegrator.initEmailServices(prefix, config);
});
}
}
function enderecoInitPS(prefix, config) {
if (undefined !== window.EnderecoIntegrator.initEmailServices) {
window.EnderecoIntegrator.initPersonServices(prefix, config);
} else {
window.EnderecoIntegrator.onLoad.push(function () {
window.EnderecoIntegrator.initPersonServices(prefix, config);
});
}
}
function enderecoSetConfigValues() {
window.EnderecoIntegrator.themeName = '';
window.EnderecoIntegrator.defaultCountrySelect = !!('{{ page.endereco_config.defaultCountrySelect }}');
window.EnderecoIntegrator.defaultCountry = '{{ page.endereco_config.defaultCountry }}';
window.EnderecoIntegrator.config.agentName = '{{ page.endereco_config.enderecoAgentInfo }}';
window.EnderecoIntegrator.config.apiUrl = '{{ asset('bundles/enderecoshopware6clientstore/io.php') }}';
window.EnderecoIntegrator.config.apiKey = '{{ page.endereco_config.enderecoApiKey }}';
window.EnderecoIntegrator.config.showDebugInfo = false;
window.EnderecoIntegrator.config.remoteApiUrl = '{{ page.endereco_config.enderecoRemoteUrl }}';
window.EnderecoIntegrator.config.trigger.onblur = !!('{{ page.endereco_config.enderecoTriggerOnBlur }}');
window.EnderecoIntegrator.config.trigger.onsubmit = !!('{{ page.endereco_config.enderecoTriggerOnSubmit }}');
window.EnderecoIntegrator.config.ux.smartFill = false;
window.EnderecoIntegrator.config.ux.checkExisting = false;
window.EnderecoIntegrator.config.ux.resumeSubmit = !!('{{ page.endereco_config.enderecoContinueSubmit }}');
window.EnderecoIntegrator.config.ux.useStandardCss = true;
window.EnderecoIntegrator.config.ux.showEmailStatus = false;
window.EnderecoIntegrator.config.ux.allowCloseModal = !!('{{ page.endereco_config.enderecoAllowCloseIcon }}');
window.EnderecoIntegrator.config.ux.confirmWithCheckbox = !!('{{ page.endereco_config.enderecoConfirmWithCheckbox }}');
window.EnderecoIntegrator.config.ux.changeFieldsOrder = true;
window.EnderecoIntegrator.config.splitStreet = false;
window.EnderecoIntegrator.countryMappingUrl = '';
window.EnderecoIntegrator.config.templates.primaryButtonClasses = 'btn btn-primary btn-lg';
window.EnderecoIntegrator.config.templates.secondaryButtonClasses = 'btn btn-secondary btn-lg';
window.EnderecoIntegrator.config.texts = {
popUpHeadline: '{{ "enderecoshopware6clientstore.texts.popUpHeadline"|trans|sw_sanitize|escape }}',
popUpSubline: '{{ "enderecoshopware6clientstore.texts.popUpSubline"|trans|sw_sanitize|escape }}',
mistakeNoPredictionSubline: '{{ "enderecoshopware6clientstore.texts.mistakeNoPredictionSubline"|trans|sw_sanitize|escape }}',
confirmMyAddressCheckbox: '{{ "enderecoshopware6clientstore.texts.confirmMyAddressCheckbox"|trans|sw_sanitize|escape }}',
notFoundSubline: '{{ "enderecoshopware6clientstore.texts.notFoundSubline"|trans|sw_sanitize|escape }}',
yourInput: '{{ "enderecoshopware6clientstore.texts.yourInput"|trans|sw_sanitize|escape }}',
editYourInput: '{{ "enderecoshopware6clientstore.texts.editYourInput"|trans|sw_sanitize|escape }}',
ourSuggestions: '{{ "enderecoshopware6clientstore.texts.ourSuggestions"|trans|sw_sanitize|escape }}',
useSelected: '{{ "enderecoshopware6clientstore.texts.useSelected"|trans|sw_sanitize|escape }}',
confirmAddress: '{{ "enderecoshopware6clientstore.texts.confirmAddress"|trans|sw_sanitize|escape }}',
editAddress: '{{ "enderecoshopware6clientstore.texts.editAddress"|trans|sw_sanitize|escape }}',
warningText: '{{ "enderecoshopware6clientstore.texts.warningText"|trans|sw_sanitize|escape }}',
popupHeadlines: {
general_address: '{{ "enderecoshopware6clientstore.texts.general_address"|trans|sw_sanitize|escape }}',
billing_address: '{{ "enderecoshopware6clientstore.texts.billing_address"|trans|sw_sanitize|escape }}',
shipping_address: '{{ "enderecoshopware6clientstore.texts.shipping_address"|trans|sw_sanitize|escape }}',
},
statuses: {
email_not_correct: '{{ "enderecoshopware6clientstore.statuses.email_not_correct"|trans|sw_sanitize|escape }}',
email_cant_receive: '{{ "enderecoshopware6clientstore.statuses.email_cant_receive"|trans|sw_sanitize|escape }}',
email_syntax_error: '{{ "enderecoshopware6clientstore.statuses.email_syntax_error"|trans|sw_sanitize|escape }}',
email_no_mx: '{{ "enderecoshopware6clientstore.statuses.email_no_mx"|trans|sw_sanitize|escape }}',
building_number_is_missing: '{{ "enderecoshopware6clientstore.statuses.building_number_is_missing"|trans|sw_sanitize|escape }}',
building_number_not_found: '{{ "enderecoshopware6clientstore.statuses.building_number_not_found"|trans|sw_sanitize|escape }}',
street_name_needs_correction: '{{ "enderecoshopware6clientstore.statuses.street_name_needs_correction"|trans|sw_sanitize|escape }}',
locality_needs_correction: '{{ "enderecoshopware6clientstore.statuses.locality_needs_correction"|trans|sw_sanitize|escape }}',
postal_code_needs_correction: '{{ "enderecoshopware6clientstore.statuses.postal_code_needs_correction"|trans|sw_sanitize|escape }}',
country_code_needs_correction: '{{ "enderecoshopware6clientstore.statuses.country_code_needs_correction"|trans|sw_sanitize|escape }}',
}
};
window.EnderecoIntegrator.activeServices = {
ams: true,
emailService: false,
personService: false
}
// Execute all function that have been called throughout the page.
window.EnderecoIntegrator.onLoad.forEach(function (callback) {
callback();
});
window.EnderecoIntegrator.ready = true;
(function() {
window.EnderecoIntegrator.$formScanner = {
loop: null,
start: function() {
this.loop = setInterval( function() {
document.querySelectorAll('[name="endereco_data_marker"][data-has-object="no"]').forEach( function(MarkerElement) {
var formElement = MarkerElement.closest('form');
var formId = '';
if (formElement.getAttribute('data-endereco-ams-form-id')) {
formId = formElement.getAttribute('data-endereco-ams-form-id');
} else {
formId = (Math.floor(Math.random() * 100) * Date.now()).toString(16);
formElement.setAttribute('data-endereco-ams-form-id', formId);
}
if ('ams' === MarkerElement.value) {
var prefix = MarkerElement.getAttribute('data-used-prefix');
var countryCodeSelector = MarkerElement.getAttribute('data-country-code-selector');
var postalCodeSelector = MarkerElement.getAttribute('data-postal-code-selector');
var localitySelector = MarkerElement.getAttribute('data-locality-selector');
var streetFullSelector = MarkerElement.getAttribute('data-street-full-selector');
var subdivisionCodeSelector = MarkerElement.getAttribute('data-subdivision-code-selector');
var isAjax = false;
var EAO = window.EnderecoIntegrator.initAMS(
{
countryCode: `[data-endereco-ams-form-id="${formId}"] [name="${countryCodeSelector}"]`,
subdivisionCode: `[data-endereco-ams-form-id="${formId}"] [name="${subdivisionCodeSelector}"]`,
postalCode: `[data-endereco-ams-form-id="${formId}"] [name="${postalCodeSelector}"]`,
locality: `[data-endereco-ams-form-id="${formId}"] [name="${localitySelector}"]`,
streetFull: `[data-endereco-ams-form-id="${formId}"] [name="${streetFullSelector}"]`,
}, {
name: `ams_${prefix}_${formId}`,
addressType: 'general_address'
}
);
// If ajax, add click listener.
isAjax = 'true' === formElement.getAttribute('data-form-ajax-submit');
if (isAjax) {
formElement.querySelector('[type="submit"]').addEventListener('click', function(e) {
if (EAO.util.shouldBeChecked()) {
e.preventDefault();
// Resume click after ac is done.
window.EnderecoIntegrator.submitResume = function() {
EAO.waitUntilReady().then( function() {
if(e.target.dispatchEvent(
new EAO.util.CustomEvent(
'click',
{
'bubbles': true,
'cancelable': true
}
)
)) {
e.target.click();
}
}).catch();
}
EAO.util.checkAddress().then().catch(function() {
EAO.waitUntilReady().then( function() {
if(e.target.dispatchEvent(
new EAO.util.CustomEvent(
'click',
{
'bubbles': true,
'cancelable': true
}
)
)) {
e.target.click();
}
}).catch();
});
return false;
}
});
}
}
MarkerElement.setAttribute('data-has-object', 'yes');
});
}, 1);
},
stop: function() {
}
}
window.EnderecoIntegrator.$formScanner.start();
})();
}
function enderecoLoadAMSConfig() {
var $interval = setInterval( function() {
if (!!window.EnderecoIntegrator.config) {
enderecoSetConfigValues();
clearInterval($interval);
}
}, 1);
}
</script>
{{ parent() }}
{% endblock %}