From cadb88375f0ca3906d69d137a60ef6c8582220bb Mon Sep 17 00:00:00 2001 From: shin Date: Mon, 20 Apr 2020 18:16:11 +0700 Subject: [PATCH 1/4] Fix email order show html --- Model/MailEvent.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Model/MailEvent.php b/Model/MailEvent.php index c4e041b..85b396a 100644 --- a/Model/MailEvent.php +++ b/Model/MailEvent.php @@ -124,7 +124,7 @@ public function dispatch($message) /** @var Order|Invoice|Shipment|Creditmemo $obj */ $obj = $templateVars[$emailType]; - if (in_array($emailType, $this->dataHelper->getAttachPdf($storeId), true)) { + if (in_array($emailType, $this->dataHelper->getAttachPdf($storeId), true) && $this->dataHelper->isEnabledAttachPdf($storeId)) { $this->setPdfAttachment($emailType, $message, $obj); } @@ -133,7 +133,7 @@ public function dispatch($message) $this->setTACAttachment($message); } - if ($this->dataHelper->versionCompare('2.2.9')) { + if ($this->dataHelper->versionCompare('2.2.9', '<=')) { $this->setBodyAttachment($message); } @@ -241,6 +241,7 @@ private function setBodyAttachment($message) $part = new Part($body); $part->setCharset('utf-8'); + $part->setEncoding(Mime::ENCODING_BASE64); if ($this->dataHelper->versionCompare('2.3.3')) { $part->setEncoding(Mime::ENCODING_QUOTEDPRINTABLE); $part->setDisposition(Mime::DISPOSITION_INLINE); From 62ee162362a60fdb53be0c6bba5ac612063ea92b Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 29 Apr 2020 11:41:30 +0700 Subject: [PATCH 2/4] review update ticket --- Model/MailEvent.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Model/MailEvent.php b/Model/MailEvent.php index 85b396a..a09bebc 100644 --- a/Model/MailEvent.php +++ b/Model/MailEvent.php @@ -124,7 +124,8 @@ public function dispatch($message) /** @var Order|Invoice|Shipment|Creditmemo $obj */ $obj = $templateVars[$emailType]; - if (in_array($emailType, $this->dataHelper->getAttachPdf($storeId), true) && $this->dataHelper->isEnabledAttachPdf($storeId)) { + if ($this->dataHelper->isEnabledAttachPdf($storeId) + && in_array($emailType, $this->dataHelper->getAttachPdf($storeId), true)) { $this->setPdfAttachment($emailType, $message, $obj); } From 566eaa9399677aa827af83f0893428ff6a7e0c3b Mon Sep 17 00:00:00 2001 From: shin Date: Fri, 19 Jun 2020 11:06:01 +0700 Subject: [PATCH 3/4] Fix Bug Ticket: https://mageplaza.freshdesk.com/a/tickets/99039 --- Model/MailEvent.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Model/MailEvent.php b/Model/MailEvent.php index a09bebc..4098f20 100644 --- a/Model/MailEvent.php +++ b/Model/MailEvent.php @@ -131,10 +131,10 @@ public function dispatch($message) if ($this->dataHelper->getTacFile($storeId) && in_array($emailType, $this->dataHelper->getAttachTac($storeId), true)) { - $this->setTACAttachment($message); + $this->setTACAttachment($message, $storeId); } - if ($this->dataHelper->versionCompare('2.2.9', '<=')) { + if ($this->dataHelper->versionCompare('2.2.9')) { $this->setBodyAttachment($message); } @@ -204,17 +204,18 @@ private function setPdfAttachment($emailType, $message, $obj) /** * @param MailMessageInterface|Zend_Mail $message + * @param null $storeId */ - private function setTACAttachment($message) + private function setTACAttachment($message, $storeId = null) { - list($content, $ext, $mimeType) = $this->getTacFile(); + list($content, $ext, $mimeType) = $this->getTacFile($storeId); if ($this->dataHelper->versionCompare('2.2.9')) { $attachment = new Part($content); $attachment->type = $mimeType; $attachment->encoding = Zend_Mime::ENCODING_BASE64; $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT; - $attachment->filename = 'terms_and_conditions.' . $ext; + $attachment->filename = __('terms_and_conditions') . '.' .$ext; $this->parts[] = $attachment; @@ -226,7 +227,7 @@ private function setTACAttachment($message) $mimeType, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, - 'terms_and_conditions.' . $ext + __('terms_and_conditions') . '.' .$ext ); } @@ -256,12 +257,13 @@ private function setBodyAttachment($message) } /** + * @param null $storeId * @return array */ - private function getTacFile() + private function getTacFile($storeId = null) { $mediaDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA); - $tacPath = $this->dataHelper->getTacFile(); + $tacPath = $this->dataHelper->getTacFile($storeId); $filePath = $mediaDirectory->getAbsolutePath('mageplaza/email_attachments/' . $tacPath); $content = file_get_contents($filePath); $ext = (string) substr($filePath, strrpos($filePath, '.') + 1); From 016de2654ea33650849a43734962088b74409ae3 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 23 Jun 2020 15:43:30 +0700 Subject: [PATCH 4/4] Clean code --- Model/MailEvent.php | 7 ++++--- composer.json | 2 +- i18n/en_US.csv | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Model/MailEvent.php b/Model/MailEvent.php index 4098f20..5eedfff 100644 --- a/Model/MailEvent.php +++ b/Model/MailEvent.php @@ -208,14 +208,14 @@ private function setPdfAttachment($emailType, $message, $obj) */ private function setTACAttachment($message, $storeId = null) { - list($content, $ext, $mimeType) = $this->getTacFile($storeId); + [$content, $ext, $mimeType] = $this->getTacFile($storeId); if ($this->dataHelper->versionCompare('2.2.9')) { $attachment = new Part($content); $attachment->type = $mimeType; $attachment->encoding = Zend_Mime::ENCODING_BASE64; $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT; - $attachment->filename = __('terms_and_conditions') . '.' .$ext; + $attachment->filename = __('terms_and_conditions') . '.' . $ext; $this->parts[] = $attachment; @@ -227,7 +227,7 @@ private function setTACAttachment($message, $storeId = null) $mimeType, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, - __('terms_and_conditions') . '.' .$ext + __('terms_and_conditions') . '.' . $ext ); } @@ -258,6 +258,7 @@ private function setBodyAttachment($message) /** * @param null $storeId + * * @return array */ private function getTacFile($storeId = null) diff --git a/composer.json b/composer.json index 530069f..b968383 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "mageplaza/module-core": "^1.4.5" }, "type": "magento2-module", - "version": "1.0.3", + "version": "1.0.4", "license": "proprietary", "authors": [ { diff --git a/i18n/en_US.csv b/i18n/en_US.csv index b208164..241f783 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -2,6 +2,7 @@ Invoice,Invoice Shipment,Shipment "Credit Memo","Credit Memo" Order,Order +terms_and_conditions,terms_and_conditions "Email Attachments","Email Attachments" "General Configuration","General Configuration" Enable,Enable