From 77580f098ee8c09c0c58015c3243b344b223d471 Mon Sep 17 00:00:00 2001 From: Benjamin Wittwer Date: Tue, 16 Apr 2024 12:48:06 +0200 Subject: [PATCH] Move mollie script & Fix missing 6.4 block --- src/Resources/views/mollie/head.html.twig | 47 +++++++++++++++++++ src/Resources/views/storefront/base.html.twig | 9 ++++ .../views/storefront/layout/meta.html.twig | 44 +---------------- 3 files changed, 58 insertions(+), 42 deletions(-) create mode 100644 src/Resources/views/mollie/head.html.twig create mode 100644 src/Resources/views/storefront/base.html.twig diff --git a/src/Resources/views/mollie/head.html.twig b/src/Resources/views/mollie/head.html.twig new file mode 100644 index 000000000..4d3168eee --- /dev/null +++ b/src/Resources/views/mollie/head.html.twig @@ -0,0 +1,47 @@ +{% block mollie_head_scripts %} + + {# pages where apple pay requires js with their mollie_applepaydirect_restrictions names as values #} + {% set onlyShowHere = { + 'frontend.checkout.confirm.page' : '', + 'frontend.checkout.cart.page' : 'cart', + 'frontend.navigation.page' : 'plp', + 'frontend.account.edit-order.page' : '', + 'frontend.detail.page' : 'pdp' + } %} + + + {% set currentRoute = app.request.attributes.get('_route') %} + {% set includeJsInHeader = false %} + + {# js always required on this pages #} + {% if currentRoute == 'frontend.checkout.cart.page' or currentRoute == 'frontend.checkout.confirm.page' or currentRoute == 'frontend.account.edit-order.page' %} + {% set includeJsInHeader = true %} + {% endif %} + + {# requirement check for apple pay direct #} + {% if mollie_applepaydirect_enabled == true or mollie_applepay_enabled == true %} + {% if currentRoute in onlyShowHere|keys and onlyShowHere[currentRoute] not in mollie_applepaydirect_restrictions %} + {% set includeJsInHeader = true %} + {% endif %} + {% if 'offcanvas' not in mollie_applepaydirect_restrictions %} + {% set includeJsInHeader = true %} + {% endif %} + {% endif %} + + {% if includeJsInHeader == true and mollie_javascript_check_duplicate === true %} + {% for script in theme_scripts() %} + {% if script == 'js/mollie-payments/mollie-payments.js' %} + {% set includeJsInHeader = false %} + {% endif %} + {% endfor %} + {% endif %} + + + + {% if mollie_javascript_use_shopware != '1' and includeJsInHeader == true %} + + {% endif %} + +{% endblock %} diff --git a/src/Resources/views/storefront/base.html.twig b/src/Resources/views/storefront/base.html.twig new file mode 100644 index 000000000..68c9e7aa0 --- /dev/null +++ b/src/Resources/views/storefront/base.html.twig @@ -0,0 +1,9 @@ +{% sw_extends '@Storefront/storefront/base.html.twig' %} + +{% block base_script_hmr_mode %} + + {{ parent() }} + + {% sw_include '@Shopware/mollie/head.html.twig' %} + +{% endblock %} diff --git a/src/Resources/views/storefront/layout/meta.html.twig b/src/Resources/views/storefront/layout/meta.html.twig index 41063cc5b..ec8ce87c5 100644 --- a/src/Resources/views/storefront/layout/meta.html.twig +++ b/src/Resources/views/storefront/layout/meta.html.twig @@ -2,48 +2,8 @@ {% block layout_head_javascript_hmr_mode %} - {# pages where apple pay requires js with their mollie_applepaydirect_restrictions names as values #} - {% set onlyShowHere = { - 'frontend.checkout.confirm.page' : '', - 'frontend.checkout.cart.page' : 'cart', - 'frontend.navigation.page' : 'plp', - 'frontend.account.edit-order.page' : '', - 'frontend.detail.page' : 'pdp' - } %} - - {% set currentRoute = app.request.attributes.get('_route') %} - {% set includeJsInHeader = false %} - - {# js always required on this pages #} - {% if currentRoute == 'frontend.checkout.cart.page' or currentRoute == 'frontend.checkout.confirm.page' or currentRoute == 'frontend.account.edit-order.page' %} - {% set includeJsInHeader = true %} - {% endif %} - - {# requirement check for apple pay direct #} - {% if mollie_applepaydirect_enabled == true or mollie_applepay_enabled == true %} - {% if currentRoute in onlyShowHere|keys and onlyShowHere[currentRoute] not in mollie_applepaydirect_restrictions %} - {% set includeJsInHeader = true %} - {% endif %} - {% if 'offcanvas' not in mollie_applepaydirect_restrictions %} - {% set includeJsInHeader = true %} - {% endif %} - {% endif %} - - {% if includeJsInHeader == true and mollie_javascript_check_duplicate == true %} - {% for script in theme_scripts() %} - {% if script == 'js/mollie-payments/mollie-payments.js' %} - {% set includeJsInHeader = false %} - {% endif %} - {% endfor %} - {% endif %} - - + {{ parent() }} - {% if mollie_javascript_use_shopware != '1' and includeJsInHeader == true %} - - {% endif %} + {% sw_include '@Shopware/mollie/head.html.twig' %} - {{ parent() }} {% endblock %}