diff --git a/src/Resources/views/storefront/base.html.twig b/src/Resources/views/storefront/base.html.twig index 073e5f54b..7b2ce1a1d 100644 --- a/src/Resources/views/storefront/base.html.twig +++ b/src/Resources/views/storefront/base.html.twig @@ -1,11 +1,43 @@ {% sw_extends '@Storefront/storefront/base.html.twig' %} {% block base_main %} + + + {# 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 %} + {% if 'offcanvas' not in mollie_applepaydirect_restrictions %} + {% set implementJS = true %} + {% endif %} + {% endif %} + - {% if mollie_javascript_use_shopware != '1' %} + + {% 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; }