@@ -124,13 +124,14 @@ public function dispatch($message)
124
124
/** @var Order|Invoice|Shipment|Creditmemo $obj */
125
125
$ obj = $ templateVars [$ emailType ];
126
126
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 )) {
128
129
$ this ->setPdfAttachment ($ emailType , $ message , $ obj );
129
130
}
130
131
131
132
if ($ this ->dataHelper ->getTacFile ($ storeId )
132
133
&& in_array ($ emailType , $ this ->dataHelper ->getAttachTac ($ storeId ), true )) {
133
- $ this ->setTACAttachment ($ message );
134
+ $ this ->setTACAttachment ($ message, $ storeId );
134
135
}
135
136
136
137
if ($ this ->dataHelper ->versionCompare ('2.2.9 ' )) {
@@ -203,17 +204,18 @@ private function setPdfAttachment($emailType, $message, $obj)
203
204
204
205
/**
205
206
* @param MailMessageInterface|Zend_Mail $message
207
+ * @param null $storeId
206
208
*/
207
- private function setTACAttachment ($ message )
209
+ private function setTACAttachment ($ message, $ storeId = null )
208
210
{
209
- list ( $ content , $ ext , $ mimeType) = $ this ->getTacFile ();
211
+ [ $ content , $ ext , $ mimeType] = $ this ->getTacFile ($ storeId );
210
212
211
213
if ($ this ->dataHelper ->versionCompare ('2.2.9 ' )) {
212
214
$ attachment = new Part ($ content );
213
215
$ attachment ->type = $ mimeType ;
214
216
$ attachment ->encoding = Zend_Mime::ENCODING_BASE64 ;
215
217
$ attachment ->disposition = Zend_Mime::DISPOSITION_ATTACHMENT ;
216
- $ attachment ->filename = 'terms_and_conditions. ' . $ ext ;
218
+ $ attachment ->filename = __ ( 'terms_and_conditions ' ) . ' . ' . $ ext ;
217
219
218
220
$ this ->parts [] = $ attachment ;
219
221
@@ -225,7 +227,7 @@ private function setTACAttachment($message)
225
227
$ mimeType ,
226
228
Zend_Mime::DISPOSITION_ATTACHMENT ,
227
229
Zend_Mime::ENCODING_BASE64 ,
228
- 'terms_and_conditions. ' . $ ext
230
+ __ ( 'terms_and_conditions ' ) . ' . ' . $ ext
229
231
);
230
232
}
231
233
@@ -241,6 +243,7 @@ private function setBodyAttachment($message)
241
243
242
244
$ part = new Part ($ body );
243
245
$ part ->setCharset ('utf-8 ' );
246
+ $ part ->setEncoding (Mime::ENCODING_BASE64 );
244
247
if ($ this ->dataHelper ->versionCompare ('2.3.3 ' )) {
245
248
$ part ->setEncoding (Mime::ENCODING_QUOTEDPRINTABLE );
246
249
$ part ->setDisposition (Mime::DISPOSITION_INLINE );
@@ -254,12 +257,14 @@ private function setBodyAttachment($message)
254
257
}
255
258
256
259
/**
260
+ * @param null $storeId
261
+ *
257
262
* @return array
258
263
*/
259
- private function getTacFile ()
264
+ private function getTacFile ($ storeId = null )
260
265
{
261
266
$ mediaDirectory = $ this ->filesystem ->getDirectoryRead (DirectoryList::MEDIA );
262
- $ tacPath = $ this ->dataHelper ->getTacFile ();
267
+ $ tacPath = $ this ->dataHelper ->getTacFile ($ storeId );
263
268
$ filePath = $ mediaDirectory ->getAbsolutePath ('mageplaza/email_attachments/ ' . $ tacPath );
264
269
$ content = file_get_contents ($ filePath );
265
270
$ ext = (string ) substr ($ filePath , strrpos ($ filePath , '. ' ) + 1 );
0 commit comments