From 542596b5a089622fd177d5391e4bc2250335d02d Mon Sep 17 00:00:00 2001 From: Jeppe Bundgaard Date: Thu, 27 Nov 2025 10:50:49 +0100 Subject: [PATCH] Refactor customer email retrieval logic in booking and email handling - Replace direct wash certificate email retrieval with `getWashCertificateEmail` method. - Fallback to default email if no certificate-specific email exists. - Adjust email assignment in booking notifications to use consistent logic. --- services/nginx/app/classes/email.php | 3 ++- services/nginx/app/objects/order_bookings_o.php | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/nginx/app/classes/email.php b/services/nginx/app/classes/email.php index 7a704acf..45fea45e 100644 --- a/services/nginx/app/classes/email.php +++ b/services/nginx/app/classes/email.php @@ -348,6 +348,7 @@ class email implements email_i $customer->requireSelected(); $recipient_name = $customer->getCustomerName((int)$customer->customer_number->value()); $recipient_email = $customer->email->value(); + $customer_contact_email = ($recipient_email ?: ''); // Check if the customer has a booking-specific email provided if (!empty($customer->wash_certificate_email->value())) { $recipient_email = (string)$customer->wash_certificate_email->value(); @@ -362,7 +363,7 @@ class email implements email_i $order_booking->id, $recipient_name, $customer->customer_number->value(), - $customer->email->value(), + $customer_contact_email, $order_booking->reference->value(), $order_booking->reg_1->value(), $order_booking->reg_2->value(), diff --git a/services/nginx/app/objects/order_bookings_o.php b/services/nginx/app/objects/order_bookings_o.php index 4606bb8b..e4bd7377 100644 --- a/services/nginx/app/objects/order_bookings_o.php +++ b/services/nginx/app/objects/order_bookings_o.php @@ -185,9 +185,10 @@ class order_bookings_o extends db // Check if the customer has a phone number $country_code = $customer->phone_country_code->value(); $customer_phone = $customer->phone->value(); - $customer_email = !empty($customer->wash_certificate_email->value()) - ? $customer->wash_certificate_email->value() - : $customer->email->value(); + $customer_email = $customer->getWashCertificateEmail(); + if (!$customer_email) { + $customer_email = $customer->email->value(); + } if (empty($customer_phone) && empty($customer_email)) { return; }