Repository: tastyigniter/TastyIgniter (language: php)

Issue:
[Feature]: change admin reservation email from variable to customers email or add a replyto field that has customers email
### What is the feature?

Ability to change admin reservation email default from variable to customers email or add a replyto field that has customers email so when a reservation is made, the admin receives the email and shows the customers email as the from address or add in replyto in the email so the admin can reply directly to the customer

I am running tastyigniter 3.4.0

### Version

Other (please detail)


Discussion / hints:

Fix patch:
diff --git a/app/admin/models/Orders_model.php b/app/admin/models/Orders_model.php
index b16299b8d4..e8bb3e7ce5 100644
--- a/app/admin/models/Orders_model.php
+++ b/app/admin/models/Orders_model.php
@@ -340,6 +340,21 @@ public function mailGetRecipients($type)
         return $recipients;
     }
 
+    public function mailGetReplyTo($type)
+    {
+        $replyTo = [];
+        if (in_array($type, (array)setting('order_email', []))) {
+            switch ($type) {
+                case 'location':
+                case 'admin':
+                    $replyTo = [$this->email, $this->customer_name];
+                    break;
+            }
+        }
+
+        return $replyTo;
+    }
+
     /**
      * Return the order data to build mail template
      *
diff --git a/app/admin/models/Reservations_model.php b/app/admin/models/Reservations_model.php
index 9959b41810..31511da5f4 100644
--- a/app/admin/models/Reservations_model.php
+++ b/app/admin/models/Reservations_model.php
@@ -432,6 +432,21 @@ public function getNextBookableTable()
     // Mail
     //
 
+    public function mailGetReplyTo($type)
+    {
+        $replyTo = [];
+        if (in_array($type, (array)setting('reservation_email', []))) {
+            switch ($type) {
+                case 'location':
+                case 'admin':
+                    $replyTo = [$this->email, $this->customer_name];
+                    break;
+            }
+        }
+
+        return $replyTo;
+    }
+
     public function mailGetRecipients($type)
     {
         $emailSetting = setting('reservation_email', []);
diff --git a/app/system/traits/SendsMailTemplate.php b/app/system/traits/SendsMailTemplate.php
index 9ef2fdc1d1..9cfb5f3c64 100644
--- a/app/system/traits/SendsMailTemplate.php
+++ b/app/system/traits/SendsMailTemplate.php
@@ -6,6 +6,11 @@
 
 trait SendsMailTemplate
 {
+    public function mailGetReplyTo()
+    {
+        return [];
+    }
+
     public function mailGetRecipients($type)
     {
         return [];
@@ -32,12 +37,13 @@ protected function mailBuildMessage($recipientType = null)
         if (is_callable($recipientType))
             return $recipientType;
 
+        $replyTo = $this->mailGetReplyTo($recipientType);
         $recipients = $this->mailGetRecipients($recipientType);
 
-        return function ($message) use ($recipients) {
+        return function ($message) use ($recipients, $replyTo) {
             foreach ($recipients as $recipient) {
-                [$email, $name] = $recipient;
-                $message->to($email, $name);
+                $message->to(...$recipient);
+                if ($replyTo) $message->replyTo(...$replyTo);
             }
         };
     }


Test patch: