fix(kasse): Gast-/Express-Bestellung ohne Anrede verlor die Adresse -- CustomerAddress::validate() verlangt honorific; leer => Firma/Herr, Fehlschlag jetzt im Log

This commit is contained in:
Thomas Bartelt
2026-09-27 00:36:03 +02:00
parent 30c81cae9c
commit 4c1ecb82a7
+22
View File
@@ -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;
}