From 8d5b031ad6dad2c9f00dacfc67858da8c9c29c22 Mon Sep 17 00:00:00 2001 From: Aleksej Wert Date: Wed, 21 Feb 2024 08:05:26 +0100 Subject: [PATCH 1/3] NTR: show mollie payment js if needed --- src/Resources/views/storefront/base.html.twig | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Resources/views/storefront/base.html.twig b/src/Resources/views/storefront/base.html.twig index 073e5f54b..066fee9b4 100644 --- a/src/Resources/views/storefront/base.html.twig +++ b/src/Resources/views/storefront/base.html.twig @@ -1,10 +1,38 @@ {% sw_extends '@Storefront/storefront/base.html.twig' %} {% block base_main %} + + {% block mollie_payments_js_control %} + {% 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 %} + {% 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 %} + - {% if mollie_javascript_use_shopware != '1' %} + {% if mollie_javascript_use_shopware != '1' and implementJS %} {% endif %} {{ parent() }} From a7c16144e23b0a3bb0ca96a626f64af4079262d9 Mon Sep 17 00:00:00 2001 From: Aleksej Wert Date: Wed, 21 Feb 2024 08:13:09 +0100 Subject: [PATCH 2/3] NTR: added comments --- src/Resources/views/storefront/base.html.twig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Resources/views/storefront/base.html.twig b/src/Resources/views/storefront/base.html.twig index 066fee9b4..12d3fd5c9 100644 --- a/src/Resources/views/storefront/base.html.twig +++ b/src/Resources/views/storefront/base.html.twig @@ -1,8 +1,9 @@ {% 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', @@ -19,6 +20,8 @@ {% 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 %} From e83fc364cc7950f94f0f3dc86f36e664136a524c Mon Sep 17 00:00:00 2001 From: Aleksej Wert Date: Thu, 29 Feb 2024 14:14:11 +0100 Subject: [PATCH 3/3] NTR: Fixes --- src/Resources/views/storefront/base.html.twig | 55 ++++++++++--------- src/Subscriber/ApplePaySubscriber.php | 2 +- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/Resources/views/storefront/base.html.twig b/src/Resources/views/storefront/base.html.twig index 12d3fd5c9..7b2ce1a1d 100644 --- a/src/Resources/views/storefront/base.html.twig +++ b/src/Resources/views/storefront/base.html.twig @@ -2,41 +2,42 @@ {% 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' %} + + {# 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 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 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 %} + {% if 'offcanvas' not in mollie_applepaydirect_restrictions %} + {% set implementJS = true %} {% endif %} - {% endblock %} + {% endif %} - {% if mollie_javascript_use_shopware != '1' and implementJS %} + + {% if mollie_javascript_use_shopware != '1' and implementJS == true %} {% endif %} + {{ parent() }} {% endblock %} \ No newline at end of file diff --git a/src/Subscriber/ApplePaySubscriber.php b/src/Subscriber/ApplePaySubscriber.php index b08efd746..12fa5441a 100644 --- a/src/Subscriber/ApplePaySubscriber.php +++ b/src/Subscriber/ApplePaySubscriber.php @@ -40,7 +40,7 @@ public static function getSubscribedEvents() public function onStorefrontRender(StorefrontRenderEvent $event): void { try { - $applePayEnabled = $this->applePay->getActiveApplePayID($event->getSalesChannelContext()); + $applePayEnabled = (bool) $this->applePay->getActiveApplePayID($event->getSalesChannelContext()); } catch (\Exception $ex) { $applePayEnabled = false; }