Skip to content
This repository was archived by the owner on Feb 20, 2023. It is now read-only.

Commit 1cf31fc

Browse files
Merge pull request #19 from mageplaza/develop
Develop
2 parents 9281796 + 016de26 commit 1cf31fc

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

Model/MailEvent.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,14 @@ public function dispatch($message)
124124
/** @var Order|Invoice|Shipment|Creditmemo $obj */
125125
$obj = $templateVars[$emailType];
126126

127-
if (in_array($emailType, $this->dataHelper->getAttachPdf($storeId), true)) {
127+
if ($this->dataHelper->isEnabledAttachPdf($storeId)
128+
&& in_array($emailType, $this->dataHelper->getAttachPdf($storeId), true)) {
128129
$this->setPdfAttachment($emailType, $message, $obj);
129130
}
130131

131132
if ($this->dataHelper->getTacFile($storeId)
132133
&& in_array($emailType, $this->dataHelper->getAttachTac($storeId), true)) {
133-
$this->setTACAttachment($message);
134+
$this->setTACAttachment($message, $storeId);
134135
}
135136

136137
if ($this->dataHelper->versionCompare('2.2.9')) {
@@ -203,17 +204,18 @@ private function setPdfAttachment($emailType, $message, $obj)
203204

204205
/**
205206
* @param MailMessageInterface|Zend_Mail $message
207+
* @param null $storeId
206208
*/
207-
private function setTACAttachment($message)
209+
private function setTACAttachment($message, $storeId = null)
208210
{
209-
list($content, $ext, $mimeType) = $this->getTacFile();
211+
[$content, $ext, $mimeType] = $this->getTacFile($storeId);
210212

211213
if ($this->dataHelper->versionCompare('2.2.9')) {
212214
$attachment = new Part($content);
213215
$attachment->type = $mimeType;
214216
$attachment->encoding = Zend_Mime::ENCODING_BASE64;
215217
$attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
216-
$attachment->filename = 'terms_and_conditions.' . $ext;
218+
$attachment->filename = __('terms_and_conditions') . '.' . $ext;
217219

218220
$this->parts[] = $attachment;
219221

@@ -225,7 +227,7 @@ private function setTACAttachment($message)
225227
$mimeType,
226228
Zend_Mime::DISPOSITION_ATTACHMENT,
227229
Zend_Mime::ENCODING_BASE64,
228-
'terms_and_conditions.' . $ext
230+
__('terms_and_conditions') . '.' . $ext
229231
);
230232
}
231233

@@ -241,6 +243,7 @@ private function setBodyAttachment($message)
241243

242244
$part = new Part($body);
243245
$part->setCharset('utf-8');
246+
$part->setEncoding(Mime::ENCODING_BASE64);
244247
if ($this->dataHelper->versionCompare('2.3.3')) {
245248
$part->setEncoding(Mime::ENCODING_QUOTEDPRINTABLE);
246249
$part->setDisposition(Mime::DISPOSITION_INLINE);
@@ -254,12 +257,14 @@ private function setBodyAttachment($message)
254257
}
255258

256259
/**
260+
* @param null $storeId
261+
*
257262
* @return array
258263
*/
259-
private function getTacFile()
264+
private function getTacFile($storeId = null)
260265
{
261266
$mediaDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
262-
$tacPath = $this->dataHelper->getTacFile();
267+
$tacPath = $this->dataHelper->getTacFile($storeId);
263268
$filePath = $mediaDirectory->getAbsolutePath('mageplaza/email_attachments/' . $tacPath);
264269
$content = file_get_contents($filePath);
265270
$ext = (string) substr($filePath, strrpos($filePath, '.') + 1);

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"mageplaza/module-core": "^1.4.5"
66
},
77
"type": "magento2-module",
8-
"version": "1.0.3",
8+
"version": "1.0.4",
99
"license": "proprietary",
1010
"authors": [
1111
{

i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Invoice,Invoice
22
Shipment,Shipment
33
"Credit Memo","Credit Memo"
44
Order,Order
5+
terms_and_conditions,terms_and_conditions
56
"Email Attachments","Email Attachments"
67
"General Configuration","General Configuration"
78
Enable,Enable

0 commit comments

Comments
 (0)