Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NTR: show mollie payment js if needed #712

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion src/Resources/views/storefront/base.html.twig
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
{% sw_extends '@Storefront/storefront/base.html.twig' %}

{% block base_main %}

{% block mollie_payments_js_control %}
{# 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 implementJS = false %}

{# js always required on this pages #}
{% if currentRoute == 'frontend.checkout.cart.page' or currentRoute == 'frontend.checkout.confirm.page' %}
{% set implementJS = true %}
{% endif %}

{# requirement check for apple pay #}
{% if mollie_applepaydirect_enabled %}
{% if currentRoute in onlyShowHere|keys and onlyShowHere[currentRoute] not in mollie_applepaydirect_restrictions %}
{% set implementJS = true %}
{% endif %}
{% if 'offcanvas' not in mollie_applepaydirect_restrictions %}
{% set implementJS = true %}
{% endif %}
{% endif %}
{% endblock %}

<script>
window.mollie_javascript_use_shopware = '{{ mollie_javascript_use_shopware }}'
</script>
{% if mollie_javascript_use_shopware != '1' %}
{% if mollie_javascript_use_shopware != '1' and implementJS %}
<script src="{{ asset('bundles/molliepayments/mollie-payments.js', 'asset') }}"></script>
{% endif %}
{{ parent() }}
Expand Down
Loading