Skip to content

Commit

Permalink
Move mollie script & Fix missing 6.4 block
Browse files Browse the repository at this point in the history
  • Loading branch information
akf-bw committed Apr 16, 2024
1 parent 5d99858 commit 77580f0
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 42 deletions.
47 changes: 47 additions & 0 deletions src/Resources/views/mollie/head.html.twig
Original file line number Diff line number Diff line change
@@ -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 %}

<script>
window.mollie_javascript_use_shopware = '{{ mollie_javascript_use_shopware }}'
</script>

{% if mollie_javascript_use_shopware != '1' and includeJsInHeader == true %}
<script type="text/javascript" src="{{ asset('bundles/molliepayments/mollie-payments.js', 'asset') }}" defer></script>
{% endif %}

{% endblock %}
9 changes: 9 additions & 0 deletions src/Resources/views/storefront/base.html.twig
Original file line number Diff line number Diff line change
@@ -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 %}
44 changes: 2 additions & 42 deletions src/Resources/views/storefront/layout/meta.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

<script>
window.mollie_javascript_use_shopware = '{{ mollie_javascript_use_shopware }}'
</script>
{{ parent() }}

{% if mollie_javascript_use_shopware != '1' and includeJsInHeader == true %}
<script type="text/javascript" src="{{ asset('bundles/molliepayments/mollie-payments.js', 'asset') }}" defer></script>
{% endif %}
{% sw_include '@Shopware/mollie/head.html.twig' %}

{{ parent() }}
{% endblock %}

0 comments on commit 77580f0

Please sign in to comment.