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

Feature: make terms and conditions filename configurable #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Mail/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ public function setReplyTo($replyToAddress)
*/
public function getRawMessage()
{
$this->setPartsToBody();
return $this->zendMessage->toString();
}

Expand All @@ -249,4 +250,4 @@ public function setMessageType($type)
{
return $this;
}
}
}
7 changes: 4 additions & 3 deletions Model/MailEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ public function dispatch(Message $message)
foreach ($this->dataHelper->getBccTo($storeId) as $email) {
$message->addBcc(trim($email));
}
$message->setPartsToBody();
}

$this->mail->setTemplateVars(null);
Expand Down Expand Up @@ -191,11 +190,13 @@ private function setPdfAttachment($emailType, Message $message, $obj)
private function setTACAttachment(Message $message, $tacPath)
{
list($filePath, $ext, $mimeType) = $this->getTacFile($tacPath);
$tacFilename = $this->dataHelper->getConfigGeneral('tac_filename');
$tacFilename = ((empty($tacFilename)) ? 'terms_and_conditions' : $tacFilename) . '.'. $ext;
if($this->dataHelper->versionCompare("2.3")) {
$attachment = new \Zend_Mime_Part(file_get_contents($filePath));
$attachment->type = $mimeType;
$attachment->disposition = \Zend_Mime::DISPOSITION_ATTACHMENT;
$attachment->filename = 'terms_and_conditions.'. $ext;
$attachment->filename = $tacFilename;
return $attachment;
}
else{
Expand All @@ -204,7 +205,7 @@ private function setTACAttachment(Message $message, $tacPath)
$mimeType,
\Zend_Mime::DISPOSITION_ATTACHMENT,
\Zend_Mime::ENCODING_BASE64,
'terms_and_conditions.' . $ext
$tacFilename
);
}
}
Expand Down
4 changes: 4 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
<field id="is_enabled_attach_tac">1</field>
</depends>
</field>
<field id="tac_filename" translate="label comment" type="text" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Terms and Conditions filename</label>
<comment>Basename for attachment</comment>
</field>
</group>
</section>
</system>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</module>
<general>
<enabled>1</enabled>
<tac_filename>terms_and_conditions</tac_filename>
</general>
</mp_email_attachments>
</default>
Expand Down