Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/3313-example-template-redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
nfourtythree committed Oct 24, 2023
2 parents 60e3f44 + 4eeb75c commit 06ff2a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Fixed a bug where it was possible to select soft-deleted tax categories.
- Fixed a PHP error that occurred when sending an email with a missing PDF filename format. ([#3309](https://github.com/craftcms/commerce/issues/3309))

## 4.3.1 - 2023-10-18

Expand Down
13 changes: 11 additions & 2 deletions src/services/Emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,18 @@ public function sendEmail(Email $email, Order $order, ?OrderHistory $orderHistor

file_put_contents($tempPath, $renderedPdf);

$fileName = $view->renderObjectTemplate($pdf->fileNameFormat, $order);
$fileName = '';
$defaultFileName = $pdf->handle . '-' . $order->number;
if ($pdf->fileNameFormat) {
try {
$fileName = $view->renderObjectTemplate($pdf->fileNameFormat, $order);
} catch (\Throwable $e) {
$fileName = $defaultFileName;
}
}

if (!$fileName) {
$fileName = $pdf->handle . '-' . $order->number;
$fileName = $defaultFileName;
}

// Attachment information
Expand Down

0 comments on commit 06ff2a6

Please sign in to comment.