tested some shit with the f theme

//TODO display button on productpage
This commit is contained in:
Nils 2025-03-06 16:36:08 +01:00
parent b755a8ad82
commit 0aaa34f504
Signed by: slinicraftet204
GPG Key ID: 78E12696BAFC2A4B
3 changed files with 17 additions and 18 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "slinicraftet204/notifyifavail", "name": "slinicraftet204/notifyifavail",
"description": "benachrichtigt Kunden, sobald ein Produkt wieder verfügbar ist", "description": "benachrichtigt Kunden, sobald ein Produkt wieder verfügbar ist",
"version": "0.1.48", "version": "0.1.492",
"type": "shopware-platform-plugin", "type": "shopware-platform-plugin",
"license": "MIT", "license": "MIT",
"authors": [ "authors": [

View File

@ -7,19 +7,25 @@ document.addEventListener('DOMContentLoaded', function () {
return; return;
} }
const notifyButton = document.getElementById('notify-me-button'); console.log("✅ NotifyMe: Container gefunden");
const submitButton = document.getElementById('submit-notify');
const emailInput = document.getElementById('notify-me-email'); const notifyButton = document.querySelector('.notify-me-button');
const submitButton = document.querySelector('.notify-me-submit');
const emailInput = document.querySelector('.notify-me-email');
if (notifyButton) { if (notifyButton) {
console.log("✅ NotifyMe: Button gefunden");
notifyButton.addEventListener('click', function () { notifyButton.addEventListener('click', function () {
const email = this.dataset.customerEmail; const email = this.dataset.customerEmail;
const productId = this.dataset.productId; const productId = this.dataset.productId;
sendNotificationRequest(email, productId); sendNotificationRequest(email, productId);
}); });
} else {
console.error("❌ NotifyMe: Button nicht gefunden!");
} }
if (submitButton) { if (submitButton) {
console.log("✅ NotifyMe: Submit-Button gefunden");
submitButton.addEventListener('click', function () { submitButton.addEventListener('click', function () {
const email = emailInput.value; const email = emailInput.value;
const productId = this.dataset.productId; const productId = this.dataset.productId;
@ -31,6 +37,8 @@ document.addEventListener('DOMContentLoaded', function () {
sendNotificationRequest(email, productId); sendNotificationRequest(email, productId);
}); });
} else {
console.error("❌ NotifyMe: Submit-Button nicht gefunden!");
} }
function sendNotificationRequest(email, productId) { function sendNotificationRequest(email, productId) {

View File

@ -1,29 +1,20 @@
{% sw_extends '@Storefront/storefront/page/product-detail/buy-widget.html.twig' %}
{% block page_product_detail_price %} {% block page_product_detail_price %}
{{ parent() }} {{ parent() }}
<div class="product-detail-price-container">
<!-- Standard Preis-Anzeige -->
<p class="product-detail-price with-list-price">
{{ product.calculatedPrice.unitPrice|currency }}*
</p>
</div>
<!-- HIER FÜGE ICH DEN BUTTON DIREKT EIN -->
{% if not product.available or product.stock <= 0 %} {% if not product.available or product.stock <= 0 %}
<div id="notify-me-container" class="product-notify-container mt-3"> <div class="product-notify-container mt-3">
<h3>{{ "NotifyIfAvail.notify_me"|trans }}</h3> <h3>{{ "NotifyIfAvail.notify_me"|trans }}</h3>
{% if app.customer %} {% if app.customer %}
<button class="btn btn-primary w-100" id="notify-me-button" <button class="btn btn-primary w-100" id="notify-me-button" data-product-id="{{ product.id }}" data-customer-email="{{ app.customer.email }}">
data-product-id="{{ product.id }}"
data-customer-email="{{ app.customer.email }}">
{{ "NotifyIfAvail.notify_me"|trans }} {{ "NotifyIfAvail.notify_me"|trans }}
</button> </button>
{% else %} {% else %}
<input type="email" id="notify-me-email" class="form-control mb-2" <input type="email" id="notify-me-email" class="form-control mb-2"
placeholder="{{ 'NotifyIfAvail.email_placeholder'|trans }}" required> placeholder="{{ 'NotifyIfAvail.email_placeholder'|trans }}" required>
<button class="btn btn-primary w-100" id="submit-notify" <button class="btn btn-primary w-100" id="submit-notify" data-product-id="{{ product.id }}">
data-product-id="{{ product.id }}">
{{ "NotifyIfAvail.notify_me"|trans }} {{ "NotifyIfAvail.notify_me"|trans }}
</button> </button>
{% endif %} {% endif %}