diff --git a/src/Resources/config/services/subscriber.xml b/src/Resources/config/services/subscriber.xml
index ba25c3490..d13a6baa1 100644
--- a/src/Resources/config/services/subscriber.xml
+++ b/src/Resources/config/services/subscriber.xml
@@ -42,6 +42,7 @@
+ %kernel.shopware_version%
diff --git a/src/Resources/views/storefront/layout/meta.html.twig b/src/Resources/views/storefront/layout/meta.html.twig
index 206b3868e..41063cc5b 100644
--- a/src/Resources/views/storefront/layout/meta.html.twig
+++ b/src/Resources/views/storefront/layout/meta.html.twig
@@ -29,6 +29,14 @@
{% 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 %}
+
diff --git a/src/Subscriber/StorefrontBuildSubscriber.php b/src/Subscriber/StorefrontBuildSubscriber.php
index 07bbbe9fc..f8192cba6 100644
--- a/src/Subscriber/StorefrontBuildSubscriber.php
+++ b/src/Subscriber/StorefrontBuildSubscriber.php
@@ -2,6 +2,7 @@
namespace Kiener\MolliePayments\Subscriber;
+use Kiener\MolliePayments\Compatibility\VersionCompare;
use Kiener\MolliePayments\Service\SettingsService;
use Shopware\Storefront\Event\StorefrontRenderEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -13,13 +14,20 @@ class StorefrontBuildSubscriber implements EventSubscriberInterface
*/
private $settingsService;
+ /**
+ * @var VersionCompare
+ */
+ private $versionCompare;
+
/**
* @param SettingsService $settingsService
+ * @param string $shopwareVersion
*/
- public function __construct(SettingsService $settingsService)
+ public function __construct(SettingsService $settingsService, string $shopwareVersion)
{
$this->settingsService = $settingsService;
+ $this->versionCompare = new VersionCompare($shopwareVersion);
}
/**
@@ -43,5 +51,6 @@ public function onStorefrontRender(StorefrontRenderEvent $event): void
$useJsValue = (int)$settings->isUseShopwareJavascript();
$event->setParameter('mollie_javascript_use_shopware', $useJsValue);
+ $event->setParameter('mollie_javascript_check_duplicate', $this->versionCompare->gte('6.6'));
}
}