From 4c1ecb82a721166aadca5373b05d73852fd3178a Mon Sep 17 00:00:00 2001 From: Thomas Bartelt Date: Sun, 27 Sep 2026 00:36:03 +0200 Subject: [PATCH] fix(kasse): Gast-/Express-Bestellung ohne Anrede verlor die Adresse -- CustomerAddress::validate() verlangt honorific; leer => Firma/Herr, Fehlschlag jetzt im Log --- modules/website_cashdesk.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/website_cashdesk.php b/modules/website_cashdesk.php index 6602a34..bd843db 100644 --- a/modules/website_cashdesk.php +++ b/modules/website_cashdesk.php @@ -161,6 +161,19 @@ class website_cashdesk { if (count($this->errors) == 0) { if (isset($_GET['guest_order']) && $_GET['guest_order'] == 1) { $this->setup_customer_data(); + + // 27.09.2026 -- Express ohne Anrede: die Anrede ist im Express-Kauf keine Pflicht, + // CustomerAddress::validate() verlangt sie aber. Leere Anrede liess die Adress-Anlage + // still scheitern, die Bestellung wurde OHNE Adresse gespeichert (312153, 312217). + // Leer => Firma (2) bei Firmenname, sonst Herr (0) -- wie customers.honorific es + // ohnehin speichert. Neutrale Anrede bleibt eigenes Thema. + foreach (array('billing', 'shipping') as $blk) { + if (isset($_POST[$blk]) && is_array($_POST[$blk]) + && (!isset($_POST[$blk]['honorific']) || (string)$_POST[$blk]['honorific'] === '')) { + $_POST[$blk]['honorific'] = !empty($_POST[$blk]['company']) ? 2 : 0; + } + } + // check customer already exists by email $customer_id = 0;//$this->base_object->customer->check_email($_POST['billing']['email']); @@ -198,6 +211,11 @@ class website_cashdesk { 'customer_id' => $customer_id ); $res = $customer_address_object->create($billing_address); + if (!$res) { + // bisher stumm -> Bestellung ohne Adresse; jetzt wenigstens sichtbar im PHP-Log + error_log('Checkout: Gast-Rechnungsadresse nicht angelegt (Kunde '.$customer_id.'): ' + . json_encode($customer_address_object->get_validation_errors())); + } $this->billing_address['address'] = $res; $shipping_address = array ( 'honorific' => $_POST['shipping']['honorific'], @@ -213,6 +231,10 @@ class website_cashdesk { ); $res = $customer_address_object->create($shipping_address); + if (!$res) { + error_log('Checkout: Gast-Lieferadresse nicht angelegt (Kunde '.$customer_id.'): ' + . json_encode($customer_address_object->get_validation_errors())); + } $this->shipping_address['address'] = $res; }