diff --git a/composer.json b/composer.json index df8db71..526dbf4 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "slinicraftet204/notifyifavail", "description": "benachrichtigt Kunden, sobald ein Produkt wieder verfügbar ist", - "version": "0.1.507", + "version": "0.1.519", "type": "shopware-platform-plugin", "license": "MIT", "authors": [ diff --git a/src/Resources/app/storefront/src/main.js b/src/Resources/app/storefront/src/main.js deleted file mode 100644 index 534c774..0000000 --- a/src/Resources/app/storefront/src/main.js +++ /dev/null @@ -1,4 +0,0 @@ -import PluginManager from 'src/plugin-system/plugin.manager'; -import NotifyMe from './plugin/notify-me.plugin'; - -PluginManager.register('NotifyMe', NotifyMe, '[data-notify-me]'); diff --git a/src/Resources/public/js/notify-me.plugin.js b/src/Resources/public/js/notify-me.plugin.js deleted file mode 100644 index e108432..0000000 --- a/src/Resources/public/js/notify-me.plugin.js +++ /dev/null @@ -1,54 +0,0 @@ -import Plugin from 'src/plugin-system/plugin.class'; - -export default class NotifyMe extends Plugin { - init() { - this.notifyButton = this.el; - this.emailInput = document.getElementById('notify-me-email'); - this.submitButton = document.getElementById('submit-notify'); - - this.registerEvents(); - console.log("Hello this is NotifyMe Plugin JS init"); - } - - registerEvents() { - console.log("Hello this is NotifyMe Plugin JS registerevents"); - if (this.notifyButton) { - this.notifyButton.addEventListener('click', () => this.submitForm(true)); - } - - if (this.submitButton) { - this.submitButton.addEventListener('click', () => this.submitForm(false)); - } - } - - validateEmail(email) { - console.log("Hello this is NotifyMe Plugin JS validateEmail"); - const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; - return emailRegex.test(email); - } - - submitForm(isLoggedIn) { - console.log("Hello this is NotifyMe Plugin JS submitForm"); - let email; - const productId = this.notifyButton.dataset.productId; - - if (isLoggedIn) { - email = this.notifyButton.dataset.customerEmail; - } else { - email = this.emailInput.value; - if (!this.validateEmail(email)) { - alert("Bitte geben Sie eine gültige E-Mail-Adresse ein."); - return; - } - } - - fetch('/notification/subscribe', { - method: 'POST', - headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - body: `email=${encodeURIComponent(email)}&productId=${encodeURIComponent(productId)}` - }) - .then(response => response.json()) - .then(data => alert(data.message)) - .catch(error => console.error('Error:', error)); - } -} diff --git a/src/Resources/views/storefront/component/buy-widget/buy-widget.html.twig b/src/Resources/views/storefront/component/buy-widget/buy-widget.html.twig index 74e5621..76ff334 100644 --- a/src/Resources/views/storefront/component/buy-widget/buy-widget.html.twig +++ b/src/Resources/views/storefront/component/buy-widget/buy-widget.html.twig @@ -3,28 +3,61 @@ {% block buy_widget_price %} {{ parent() }} - -
Produkt verfügbar? {{ product.available ? 'Ja' : 'Nein' }}
-Lagerbestand: {{ product.stock }}
+ - {% endif %} + {% endblock %}