diff --git a/Model/MailEvent.php b/Model/MailEvent.php index c4e041b..5eedfff 100644 --- a/Model/MailEvent.php +++ b/Model/MailEvent.php @@ -124,13 +124,14 @@ public function dispatch($message) /** @var Order|Invoice|Shipment|Creditmemo $obj */ $obj = $templateVars[$emailType]; - if (in_array($emailType, $this->dataHelper->getAttachPdf($storeId), true)) { + if ($this->dataHelper->isEnabledAttachPdf($storeId) + && in_array($emailType, $this->dataHelper->getAttachPdf($storeId), true)) { $this->setPdfAttachment($emailType, $message, $obj); } 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')) { @@ -203,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(); + [$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; @@ -225,7 +227,7 @@ private function setTACAttachment($message) $mimeType, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, - 'terms_and_conditions.' . $ext + __('terms_and_conditions') . '.' . $ext ); } @@ -241,6 +243,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); @@ -254,12 +257,14 @@ 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); 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