WP-Feld-Mapping robuster + Logging; Muster ohne Direktdruck; Kontakte-Fixes
- skrift-orders: sample-/offer-request nehmen viele Feldnamen-Varianten an (feldWert-Helfer) und loggen eingehende + gefüllte Feldnamen zur Diagnose. - skrift-produktion: „Direkt drucken" bei Musteranfragen entfernt (nur noch „In manuellen Druck übernehmen"). - skrift-kontakte: Bulk-Status-Dropdown lesbar (weiße Schrift auf weiß behoben); Shift-Klick wählt den ganzen Bereich zwischen zwei Checkboxen. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -163,6 +163,14 @@ async function paypalToken() {
|
||||
// Auslandsländer als GANZE Wörter (\b) – sonst matchte „schweiz" in „Schweizer
|
||||
// Straße", „usa" in „Neusass", „polen" in „Polenz" usw. und flaggte fälschlich Ausland.
|
||||
const AUSLAND_RE = /\b(österreich|schweiz|austria|switzerland|frankreich|france|italien|italy|niederlande|netherlands|belgien|belgium|luxemburg|luxembourg|spanien|spain|portugal|usa|vereinigte staaten|united states|kanada|canada|england|großbritannien|grossbritannien|united kingdom|dänemark|denmark|schweden|sweden|norwegen|norway|finnland|finland|polen|poland|tschechien|czech|ungarn|hungary|griechenland|greece|irland|ireland|australien|australia|liechtenstein)\b/i;
|
||||
// Erstes nicht-leeres Feld aus mehreren möglichen Namen (App + WordPress-Varianten).
|
||||
function feldWert(body, ...keys) {
|
||||
for (const k of keys) {
|
||||
const v = body && body[k];
|
||||
if (v != null && String(v).trim()) return String(v).trim();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
function zielInland(e) {
|
||||
const land = String(e?.country || '').trim();
|
||||
if (land) {
|
||||
@@ -1426,15 +1434,15 @@ const handler = (router, { services, getSchema, logger }) => {
|
||||
// ── Angebotsanfrage („Individuelles Angebot") ────────────────────────────
|
||||
router.post('/offer-request', async (req, res) => {
|
||||
const body = req.body || {};
|
||||
// Feld-Aliase (auch WordPress): vorname→first_name, name→last_name, telefon→phone,
|
||||
// produkt_interesse→product. App-Feldnamen haben Vorrang.
|
||||
const vorname = String(body.first_name ?? body.vorname ?? '').trim();
|
||||
const nachname = String(body.last_name ?? body.name ?? '').trim();
|
||||
try { logger.info('[skrift-orders] offer-request Felder: ' + JSON.stringify(Object.keys(body))); } catch { /* egal */ }
|
||||
// Feld-Aliase (App + WordPress + Varianten). App-Feldnamen haben Vorrang.
|
||||
const vorname = feldWert(body, 'first_name', 'vorname', 'firstname', 'first', 'given_name');
|
||||
const nachname = feldWert(body, 'last_name', 'nachname', 'name', 'lastname', 'surname', 'familienname');
|
||||
const name = [vorname, nachname].filter(Boolean).join(' ');
|
||||
const phone = String(body.phone ?? body.telefon ?? '').trim();
|
||||
const product = String(body.product ?? body.produkt_interesse ?? '').trim();
|
||||
const email = norm(body.email);
|
||||
const message = String(body.message || '').trim();
|
||||
const phone = feldWert(body, 'phone', 'telefon', 'tel', 'telephone', 'telefonnummer');
|
||||
const product = feldWert(body, 'product', 'produkt_interesse', 'produkt', 'produkt_interese');
|
||||
const email = norm(feldWert(body, 'email', 'e_mail', 'e-mail', 'mail'));
|
||||
const message = String(body.message || body.nachricht || body.vorhaben || '').trim();
|
||||
|
||||
const errors = [];
|
||||
if (!name) errors.push('Name fehlt.');
|
||||
@@ -1486,18 +1494,22 @@ const handler = (router, { services, getSchema, logger }) => {
|
||||
// ── Musterbestellung (kostenlos) ─────────────────────────────────────────
|
||||
router.post('/sample-request', async (req, res) => {
|
||||
const body = req.body || {};
|
||||
const email = norm(body.email);
|
||||
// Feld-Aliase, damit auch das WordPress-Formular direkt anlegen kann:
|
||||
// vorname→first_name, name→last_name, telefon→phone, zipcode→zip, ort→city,
|
||||
// produkt_interesse→product. Die App-Feldnamen haben Vorrang.
|
||||
const first = String(body.first_name ?? body.vorname ?? '').trim();
|
||||
const last = String(body.last_name ?? body.name ?? '').trim();
|
||||
const product = String(body.product ?? body.produkt_interesse ?? '').trim();
|
||||
const phone = String(body.phone ?? body.telefon ?? '').trim();
|
||||
const street = String(body.street ?? '').trim();
|
||||
const zip = String(body.zip ?? body.zipcode ?? '').trim();
|
||||
const city = String(body.city ?? body.ort ?? '').trim();
|
||||
const country = String(body.country ?? '').trim();
|
||||
// Diagnose: welche Feldnamen kommen rein + welche davon GEFÜLLT (Werte selbst
|
||||
// NICHT loggen – Datenschutz). So sieht man, ob WP z. B. name/ort leer schickt.
|
||||
try {
|
||||
logger.info('[skrift-orders] sample-request Felder: ' + JSON.stringify(Object.keys(body))
|
||||
+ ' | gefüllt: ' + JSON.stringify(Object.keys(body).filter((k) => String(body[k] ?? '').trim())));
|
||||
} catch { /* egal */ }
|
||||
const email = norm(feldWert(body, 'email', 'e_mail', 'e-mail', 'mail'));
|
||||
// Feld-Aliase (App + WordPress + gängige Varianten). App-Feldnamen haben Vorrang.
|
||||
const first = feldWert(body, 'first_name', 'vorname', 'firstname', 'first', 'given_name');
|
||||
const last = feldWert(body, 'last_name', 'nachname', 'name', 'lastname', 'surname', 'familienname');
|
||||
const product = feldWert(body, 'product', 'produkt_interesse', 'produkt', 'produkt_interese');
|
||||
const phone = feldWert(body, 'phone', 'telefon', 'tel', 'telephone', 'telefonnummer');
|
||||
const street = feldWert(body, 'street', 'strasse', 'straße', 'adresse', 'address', 'strasse_hausnummer');
|
||||
const zip = feldWert(body, 'zip', 'zipcode', 'plz', 'postleitzahl', 'postal_code');
|
||||
const city = feldWert(body, 'city', 'ort', 'stadt', 'wohnort');
|
||||
const country = feldWert(body, 'country', 'land');
|
||||
const vollName = [first, last].filter(Boolean).join(' ');
|
||||
const errors = [];
|
||||
if (!product) errors.push('Produkt fehlt.');
|
||||
|
||||
Reference in New Issue
Block a user