From a286d8ae7b0c9e871a40c6a21e5c0195e5c9741b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 24 May 2023 21:35:13 +1000 Subject: [PATCH] Set text_body cleanly and don't reference existing reference --- app/Helpers/Invoice/InvoiceItemSum.php | 2 +- app/Services/Email/EmailDefaults.php | 2 ++ app/Services/Email/EmailMailable.php | 2 +- app/Services/Email/EmailObject.php | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 2e5cca8bd00c..ff176ad6a762 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -169,7 +169,7 @@ class InvoiceItemSum private function shouldCalculateTax(): self { - // + if (!$this->invoice->company->calculate_taxes || !$this->invoice->company->account->isFreeHostedClient()) { $this->calc_tax = false; return $this; diff --git a/app/Services/Email/EmailDefaults.php b/app/Services/Email/EmailDefaults.php index 47d80f5702b0..156bcceefa99 100644 --- a/app/Services/Email/EmailDefaults.php +++ b/app/Services/Email/EmailDefaults.php @@ -180,6 +180,8 @@ class EmailDefaults $this->email->email_object->body = EmailTemplateDefaults::getDefaultTemplate($this->email->email_object->email_template_body, $this->locale); } + $this->email->email_object->text_body = strip_tags($this->email->email_object->body); + if ($this->template == 'email.template.custom') { $this->email->email_object->body = (str_replace('$body', $this->email->email_object->body, str_replace(["\r","\n"], "", $this->email->email_object->settings->email_style_custom))); } diff --git a/app/Services/Email/EmailMailable.php b/app/Services/Email/EmailMailable.php index 91c0ea407121..d25ae3b3654d 100644 --- a/app/Services/Email/EmailMailable.php +++ b/app/Services/Email/EmailMailable.php @@ -68,7 +68,7 @@ class EmailMailable extends Mailable view: $this->email_object->html_template, text: $this->email_object->text_template, with: [ - 'text_body' => strip_tags($this->email_object->body), //@todo this is a bit hacky here. + 'text_body' => $this->email_object->text_body, //@todo this is a bit hacky here. 'body' => $this->email_object->body, 'settings' => $this->email_object->settings, 'whitelabel' => $this->email_object->whitelabel, diff --git a/app/Services/Email/EmailObject.php b/app/Services/Email/EmailObject.php index 74334965f6d4..4eb7c0b28e13 100644 --- a/app/Services/Email/EmailObject.php +++ b/app/Services/Email/EmailObject.php @@ -50,6 +50,8 @@ class EmailObject public ?string $body = null; + public string $text_body = ''; + /** @var array{key: value} $args */ public array $attachments = [];