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.
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user